From owner-svn-src-all@freebsd.org Sun Dec 13 19:22:01 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F6E64C15AD; Sun, 13 Dec 2020 19:22:01 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvDt04pdMz4n3R; Sun, 13 Dec 2020 19:22:00 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mail-qk1-f195.google.com with SMTP id p14so4607357qke.6; Sun, 13 Dec 2020 11:22:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8aUCTBmfPTpB4R8j680QPeHe4WG2rBWHvnTHh9RvBTw=; b=UPw8nsztP2gJ0FbBBsgCewlC6CeaFKE/oscuqe0EOU4OpXYA+x1I22v/ntNIsWGyji V1UMQDK0JUdmVF4Z38P2m/BVKHMP0ay0qAKXa0t9/rA8aQFX36oGKJt6zdKW+V0RdtXb Fm9Q/hwIrF/LjiCh2m2MbvII+ZYKxkkZU4GhOCU27pea5/DKHZAWE8gT8ur8NVgHyjHC yrA3C6sJLbnsHWT3qmTQi4COQVxY3azb1RX2Xgl/xWqe1fEd0OqVYWuGpPOPAQwKcGaj xT7cebZaAPpSNw0IelvCihoE3btiEBzvYGfqtXQE+r1gs0LvKGj+WQYj5BShwmA+QVH9 xYCw== X-Gm-Message-State: AOAM532ZpV7Ynig6FyZ6c8Mv1DNrwO0KTIu9Gr5r7MyIbEOnXSJ6NgiN PQmk+PNu1qSw9MF9qdSfu66HcP8k1JhPkg== X-Google-Smtp-Source: ABdhPJzlJqd+6J1yDkI1Y9Syk6113yJmiP47S25kkO/gs+g4dkzIaU+63Ri/flienlfRyLvCEIZgtQ== X-Received: by 2002:a37:8384:: with SMTP id f126mr28149836qkd.500.1607887319424; Sun, 13 Dec 2020 11:21:59 -0800 (PST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com. [209.85.222.172]) by smtp.gmail.com with ESMTPSA id p58sm13469315qte.38.2020.12.13.11.21.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Dec 2020 11:21:58 -0800 (PST) Received: by mail-qk1-f172.google.com with SMTP id n142so13740507qkn.2; Sun, 13 Dec 2020 11:21:58 -0800 (PST) X-Received: by 2002:a05:620a:531:: with SMTP id h17mr28248022qkh.428.1607887318518; Sun, 13 Dec 2020 11:21:58 -0800 (PST) MIME-Version: 1.0 References: <202008251330.07PDU4WQ055570@repo.freebsd.org> In-Reply-To: <202008251330.07PDU4WQ055570@repo.freebsd.org> From: Ryan Libby Date: Sun, 13 Dec 2020 11:21:47 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r364761 - in head: share/mk sys/conf sys/modules/cloudabi32 sys/modules/cloudabi64 sys/modules/linux sys/modules/linux64 To: Alex Richardson Cc: src-committers , svn-src-all , svn-src-head , Brooks Davis , Ed Maste Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4CvDt04pdMz4n3R X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of rlibby@gmail.com designates 209.85.222.195 as permitted sender) smtp.mailfrom=rlibby@gmail.com X-Spamd-Result: default: False [-2.58 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.58)[-0.577]; FORGED_SENDER(0.30)[rlibby@freebsd.org,rlibby@gmail.com]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.222.195:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[rlibby@freebsd.org,rlibby@gmail.com]; R_DKIM_NA(0.00)[]; ARC_NA(0.00)[]; FREEFALL_USER(0.00)[rlibby]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; SPAMHAUS_ZRD(0.00)[209.85.222.195:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[209.85.222.195:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.222.195:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[svn-src-all,svn-src-head] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 19:22:01 -0000 On Tue, Aug 25, 2020 at 6:30 AM Alex Richardson wrote: > > Author: arichardson > Date: Tue Aug 25 13:30:03 2020 > New Revision: 364761 > URL: https://svnweb.freebsd.org/changeset/base/364761 > > Log: > Pass -fuse-ld=/path/to/ld if ${LD} != "ld" > > This is needed so that setting LD/XLD is not ignored when linking with $CC > instead of directly using $LD. Currently only clang accepts an absolute > path for -fuse-ld= (Clang 12+ will add a new --ld-path flag), so we now > warn when building with GCC and $LD != "ld" since that might result in the > wrong linker being used. > > We have been setting XLD=/path/to/cheri/ld.lld in CheriBSD for a long time and > used a similar version of this patch to avoid linking with /usr/bin/ld. > This change is also required when building FreeBSD on an Ubuntu with Clang: > In that case we set XCC=/usr/lib/llvm-10/bin/clang and since > /usr/lib/llvm-10/bin/ does not contain a "ld" binary the build fails with > `clang: error: unable to execute command: Executable "ld" doesn't exist!` > unless we pass -fuse-ld=/usr/lib/llvm-10/bin/ld.lld. > > This change passes -fuse-ld instead of copying ${XLD} to WOLRDTMP/bin/ld > since then we would have to ensure that this file does not exist while > building the bootstrap tools. The cross-linker might not be compatible with > the host linker (e.g. when building on macos: host-linker= Mach-O /usr/bin/ld, > cross-linker=LLVM ld.lld). > > Reviewed By: brooks, emaste > Differential Revision: https://reviews.freebsd.org/D26055 > > Modified: > head/share/mk/bsd.sys.mk > head/sys/conf/kern.mk > head/sys/conf/kern.post.mk > head/sys/modules/cloudabi32/Makefile > head/sys/modules/cloudabi64/Makefile > head/sys/modules/linux/Makefile > head/sys/modules/linux64/Makefile > > Modified: head/share/mk/bsd.sys.mk > ============================================================================== > --- head/share/mk/bsd.sys.mk Tue Aug 25 13:29:57 2020 (r364760) > +++ head/share/mk/bsd.sys.mk Tue Aug 25 13:30:03 2020 (r364761) > @@ -284,6 +284,19 @@ CFLAGS+= ERROR-tried-to-rebuild-during-make-install > .endif > .endif > > +# Please keep this if in sync with kern.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +LDFLAGS+= -fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported FYI: This causes a huge amount of wrong and irrelevant warnings in the build log for gcc cross compilers with XLD set, such as the toolchain from pkg install amd64-xtoolchain-gcc. That causes XLD to be set (via CROSS_BINUTILS_PREFIX in Makefile.inc1) to a path which is indeed the default linker for the cross compiler. The warnings are harmless, but annoying. Sorry, I don't have a suggestion for a better method. You can see an example in the build log from a gcc build in CI here (although note that the build currently fails for unrelated reasons): https://ci.freebsd.org/job/FreeBSD-head-amd64-gcc6_build/3131 > +.endif > +.endif > + > # Tell bmake not to mistake standard targets for things to be searched for > # or expect to ever be up-to-date. > PHONY_NOTMAIN = analyze afterdepend afterinstall all beforedepend beforeinstall \ > > Modified: head/sys/conf/kern.mk > ============================================================================== > --- head/sys/conf/kern.mk Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/conf/kern.mk Tue Aug 25 13:30:03 2020 (r364761) > @@ -270,6 +270,22 @@ CFLAGS+= -std=iso9899:1999 > CFLAGS+= -std=${CSTD} > .endif # CSTD > > +# Please keep this if in sync with bsd.sys.mk > +.if ${LD} != "ld" && (${CC:[1]:H} != ${LD:[1]:H} || ${LD:[1]:T} != "ld") > +# Add -fuse-ld=${LD} if $LD is in a different directory or not called "ld". > +# Note: Clang 12+ will prefer --ld-path= over -fuse-ld=. > +.if ${COMPILER_TYPE} == "clang" > +# Note: unlike bsd.sys.mk we can't use LDFLAGS here since that is used for the > +# flags required when linking the kernel. We don't need those flags when > +# building the vdsos. However, we do need -fuse-ld, so use ${CCLDFLAGS} instead. > +CCLDFLAGS+= -fuse-ld=${LD:[1]} > +.else > +# GCC does not support an absolute path for -fuse-ld so we just print this > +# warning instead and let the user add the required symlinks. > +.warning LD (${LD}) is not the default linker for ${CC} but -fuse-ld= is not supported > +.endif > +.endif > + > # Set target-specific linker emulation name. > LD_EMULATION_aarch64=aarch64elf > LD_EMULATION_amd64=elf_x86_64_fbsd > > Modified: head/sys/conf/kern.post.mk > ============================================================================== > --- head/sys/conf/kern.post.mk Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/conf/kern.post.mk Tue Aug 25 13:30:03 2020 (r364761) > @@ -228,7 +228,7 @@ kernel-clean: > # in the a.out ld. For now, this works. > hack.pico: Makefile > :> hack.c > - ${CC} -shared ${CFLAGS} -nostdlib hack.c -o hack.pico > + ${CC} ${CCLDFLAGS} -shared ${CFLAGS} -nostdlib hack.c -o hack.pico > rm -f hack.c > > offset.inc: $S/kern/genoffset.sh genoffset.o > > Modified: head/sys/modules/cloudabi32/Makefile > ============================================================================== > --- head/sys/modules/cloudabi32/Makefile Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/modules/cloudabi32/Makefile Tue Aug 25 13:30:03 2020 (r364761) > @@ -33,7 +33,7 @@ BINARY_ARCHITECTURE=i386 > .endif > > cloudabi32_vdso.o: ${VDSO_SRCS} > - ${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib \ > + ${CC} ${CCLDFLAGS} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib \ > -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ > ${VDSO_SRCS} -o ${.TARGET} > > > Modified: head/sys/modules/cloudabi64/Makefile > ============================================================================== > --- head/sys/modules/cloudabi64/Makefile Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/modules/cloudabi64/Makefile Tue Aug 25 13:30:03 2020 (r364761) > @@ -25,7 +25,7 @@ BINARY_ARCHITECTURE=i386 > .endif > > cloudabi64_vdso.o: ${VDSO_SRCS} > - ${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib \ > + ${CC} ${CCLDFLAGS} -x assembler-with-cpp -shared -nostdinc -nostdlib \ > -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ > ${VDSO_SRCS} -o ${.TARGET} > > > Modified: head/sys/modules/linux/Makefile > ============================================================================== > --- head/sys/modules/linux/Makefile Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/modules/linux/Makefile Tue Aug 25 13:30:03 2020 (r364761) > @@ -54,7 +54,7 @@ linux${SFX}_assym.h: linux${SFX}_genassym.o > sh ${SYSDIR}/kern/genassym.sh linux${SFX}_genassym.o > ${.TARGET} > > linux${SFX}_locore.o: linux${SFX}_assym.h assym.inc > - ${CC} -x assembler-with-cpp -DLOCORE -m32 -shared -s \ > + ${CC} ${CCLDFLAGS} -x assembler-with-cpp -DLOCORE -m32 -shared -s \ > -pipe -I. -I${SYSDIR} ${WERROR} -Wall -fno-common -nostdinc -nostdlib \ > -fno-omit-frame-pointer -fPIC \ > -Wl,-T${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX}/${VDSO}.lds.s \ > > Modified: head/sys/modules/linux64/Makefile > ============================================================================== > --- head/sys/modules/linux64/Makefile Tue Aug 25 13:29:57 2020 (r364760) > +++ head/sys/modules/linux64/Makefile Tue Aug 25 13:30:03 2020 (r364761) > @@ -30,7 +30,7 @@ linux_assym.h: linux_genassym.o > sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET} > > linux_locore.o: linux_locore.asm linux_assym.h > - ${CC} -x assembler-with-cpp -DLOCORE -shared -mcmodel=small \ > + ${CC} ${CCLDFLAGS} -x assembler-with-cpp -DLOCORE -shared -mcmodel=small \ > -pipe -I. -I${SYSDIR} ${WERROR} -Wall -fno-common -fPIC -nostdinc \ > -Wl,-T${SRCTOP}/sys/${MACHINE}/linux/${VDSO}.lds.s \ > -Wl,-soname=${VDSO}.so.1,-warn-common -nostdlib \