From nobody Wed May 18 19:35:37 2022
X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
	by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 33E6D1ADAA05;
	Wed, 18 May 2022 19:35:39 +0000 (UTC)
	(envelope-from brooks@spindle.one-eyed-alien.net)
Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id 4L3NWG1czyz3r30;
	Wed, 18 May 2022 19:35:38 +0000 (UTC)
	(envelope-from brooks@spindle.one-eyed-alien.net)
Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001)
	id BBB0D3C0199; Wed, 18 May 2022 19:35:37 +0000 (UTC)
Date: Wed, 18 May 2022 19:35:37 +0000
From: Brooks Davis <brooks@freebsd.org>
To: Dimitry Andric <dim@FreeBSD.org>
Cc: Konstantin Belousov <kostikbel@gmail.com>,
	John Baldwin <jhb@freebsd.org>, Charlie Li <vishwin@freebsd.org>,
	"src-committers@freebsd.org" <src-committers@freebsd.org>,
	"dev-commits-src-all@freebsd.org" <dev-commits-src-all@freebsd.org>,
	"dev-commits-src-main@freebsd.org" <dev-commits-src-main@freebsd.org>
Subject: Re: git: 349cc55c9796 - main - Merge llvm-project main
 llvmorg-14-init-10186-gff7f2cfa959b
Message-ID: <20220518193537.GH15201@spindle.one-eyed-alien.net>
References: <202205141148.24EBmkZd015765@gitrepo.freebsd.org>
 <e251f1fb-b0c2-1d3a-d9f2-6def1ddb9735@freebsd.org>
 <C45D4583-C972-426A-88F0-42F475D760D2@FreeBSD.org>
 <4b61bdc6-fdc7-57df-e9b7-52543fd083be@freebsd.org>
 <20220516154825.GF15201@spindle.one-eyed-alien.net>
 <e57160f3-5d34-69cb-c249-f4f0f0665282@freebsd.org>
 <5e5281b2-a9d1-3751-b09a-c88d210f4f55@FreeBSD.org>
 <YoQ+8LupA6XG6F/a@kib.kiev.ua>
 <698AE22D-5E95-405E-A8BE-AE67A3A7BE36@FreeBSD.org>
List-Id: Commit messages for the main branch of the src repository <dev-commits-src-main.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main
List-Help: <mailto:dev-commits-src-main+help@freebsd.org>
List-Post: <mailto:dev-commits-src-main@freebsd.org>
List-Subscribe: <mailto:dev-commits-src-main+subscribe@freebsd.org>
List-Unsubscribe: <mailto:dev-commits-src-main+unsubscribe@freebsd.org>
Sender: owner-dev-commits-src-main@freebsd.org
X-BeenThere: dev-commits-src-main@freebsd.org
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="ZPDwMsyfds7q4mrK"
Content-Disposition: inline
In-Reply-To: <698AE22D-5E95-405E-A8BE-AE67A3A7BE36@FreeBSD.org>
User-Agent: Mutt/1.9.4 (2018-02-28)
X-Rspamd-Queue-Id: 4L3NWG1czyz3r30
X-Spamd-Bar: ++
Authentication-Results: mx1.freebsd.org;
	dkim=none;
	dmarc=none;
	spf=none (mx1.freebsd.org: domain of brooks@spindle.one-eyed-alien.net has no SPF policy when checking 199.48.129.229) smtp.mailfrom=brooks@spindle.one-eyed-alien.net
X-Spamd-Result: default: False [2.09 / 15.00];
	 TO_DN_EQ_ADDR_SOME(0.00)[];
	 ARC_NA(0.00)[];
	 FREEFALL_USER(0.00)[brooks];
	 FROM_HAS_DN(0.00)[];
	 TO_DN_SOME(0.00)[];
	 NEURAL_SPAM_SHORT(1.00)[1.000];
	 MIME_GOOD(-0.20)[multipart/signed,text/plain];
	 DMARC_NA(0.00)[freebsd.org];
	 AUTH_NA(1.00)[];
	 R_SPF_NA(0.00)[no SPF record];
	 NEURAL_SPAM_MEDIUM(1.00)[1.000];
	 TO_MATCH_ENVRCPT_SOME(0.00)[];
	 NEURAL_SPAM_LONG(0.99)[0.988];
	 RCPT_COUNT_SEVEN(0.00)[7];
	 MLMMJ_DEST(0.00)[dev-commits-src-all,dev-commits-src-main];
	 FORGED_SENDER(0.30)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net];
	 RCVD_COUNT_ZERO(0.00)[0];
	 SIGNED_PGP(-2.00)[];
	 R_DKIM_NA(0.00)[];
	 MIME_TRACE(0.00)[0:+,1:+,2:~];
	 ASN(0.00)[asn:36236, ipnet:199.48.128.0/22, country:US];
	 FROM_NEQ_ENVFROM(0.00)[brooks@freebsd.org,brooks@spindle.one-eyed-alien.net];
	 FREEMAIL_CC(0.00)[gmail.com,freebsd.org]
X-ThisMailContainsUnwantedMimeParts: N


--ZPDwMsyfds7q4mrK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, May 18, 2022 at 09:17:58PM +0200, Dimitry Andric wrote:
> On 18 May 2022, at 02:33, Konstantin Belousov <kostikbel@gmail.com> wrote:
> >=20
> > On Tue, May 17, 2022 at 10:56:14AM -0700, John Baldwin wrote:
> >> On 5/16/22 8:09 PM, Charlie Li wrote:
> >>> Brooks Davis wrote:
> >>>> On Mon, May 16, 2022 at 10:47:49AM -0400, Charlie Li wrote:
> >>>>> Dimitry Andric wrote:
> >>>>>> This was also reported by another user, and it turned out they were
> >>>>>> using WITHOUT_CROSS_COMPILER=3D in src.conf. If you also have that=
, try
> >>>>>> removing it and rebuilding.
> >>>>>>=20
> >>>>> Yeah I eventually figured that part out. Worked around (first attem=
pt)
> >>>>> by building with devel/llvm14 CROSS_TOOLCHAIN, but resulted in cert=
ain
> >>>>> kernel modules (zfs and a few more) with malformed relocations.
> >>>>> Subsequent rebuild with the new world's toolchain corrected that.
> >>>>=20
> >>>> Does that mean we're missing patches in the port? Hopefully anything
> >>>> this critical can be merged into LLVM 14.0.3.
> >>>>=20
> >>> Probably:
> >>>=20
> >>> May 15 22:34:08 current-builder kernel: ---<<BOOT>>---
> >>> May 15 22:34:08 current-builder kernel: Copyright (c) 1992-2022 The
> >>> FreeBSD Project.
> >>> May 15 22:34:08 current-builder kernel: Copyright (c) 1979, 1980, 198=
3,
> >>> 1986, 1988, 1989, 1991, 1992, 1993, 1994
> >>> May 15 22:34:08 current-builder kernel: The Regents of the
> >>> University of California. All rights reserved.
> >>> May 15 22:34:08 current-builder kernel: FreeBSD is a registered
> >>> trademark of The FreeBSD Foundation.
> >>> May 15 22:34:08 current-builder kernel: FreeBSD 14.0-CURRENT #121
> >>> main-n255657-48a1a6be196: Sun May 15 21:59:12 EDT 2022
> >>> May 15 22:34:08 current-builder kernel:
> >>> root@current-builder:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG=
 amd64
> >>> May 15 22:34:08 current-builder kernel: clang version 14.0.2
> >>> [...]
> >>> May 15 22:34:08 current-builder kernel: kldload: unexpected relocation
> >>> type 42, symbol index 8321
> >>=20
> >> These are all type 42:
> >>=20
> >> #define	R_X86_64_REX_GOTPCRELX	42
> >>=20
> >> It's not a LLVM bug so much as it is probably missing support in the k=
ernel and/or
> >> loader for this type of relocation. kldxref might also need updating.
> >>=20
> >> I suspect due to a mismatch of old lld with new clang or some such tha=
t the old
> >> lld failed to resolve these relocations to some other type or somethin=
g weird like
> >> that?
> >=20
> > I do think this is a toolchain bug, or at least new and undesired behav=
ior.
> >=20
> > For practical purposes, R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX a=
re
> > same as R_X86_64_GOTPCREL64, I believe, but we do not expect GOT reloca=
tions
> > in the .o object modules on amd64.
>=20
> I don't see this with clang 14.0.3 from base on 14-CURRENT. None of my
> kernel modules has any of these relocations, and I also get no warnings
> from kldxref.
>=20
> Btw, I know that clang from ports will use /usr/local/bin/ld if it is
> available, so this might be GNU ld specific behavior? Charlie, do you
> have the binutils port installed?

I don't believe this is true in all but the weirdest configurations.  I
just tested on a system with binutils installed (providing
/usr/local/bin/ld) and clang13 uses /usr/local/llvm13/bin/ld as I'd
expect.  Because of the foo## wrappers, clang doesn't know it's being
found via /usr/local/bin so doesn't look there by default.  Instead it's
invoked as /usr/local/llvm##/bin/clang and looks for
/usr/local/llvm##/bin/ld.  Maybe if you didn't install LLD it would
eventually look in PATH and find /usr/local/bin/ld.

-- Brooks

$ clang13 -### ~/hello.c=20
clang version 13.0.1
Target: x86_64-portbld-freebsd13.0
Thread model: posix
InstalledDir: /usr/local/llvm13/bin
 "/usr/local/llvm13/bin/clang-13" "-cc1" "-triple" "x86_64-portbld-freebsd1=
3.0" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-dis=
able-llvm-verifier" "-discard-value-names" "-main-file-name" "hello.c" "-mr=
elocation-model" "static" "-mframe-pointer=3Dall" "-fno-rounding-math" "-mc=
onstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "g=
eneric" "-debugger-tuning=3Dgdb" "-fcoverage-compilation-dir=3D/home/bed22/=
git/ports/devel" "-resource-dir" "/usr/local/llvm13/lib/clang/13.0.1" "-fde=
bug-compilation-dir=3D/home/bed22/git/ports/devel" "-ferror-limit" "19" "-f=
gnuc-version=3D4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF=
2_CFI_ASM=3D1" "-o" "/tmp/hello-7a4c72.o" "-x" "c" "/home/bed22/hello.c"
  "/usr/local/llvm13/bin/ld" "--eh-frame-hdr" "-dynamic-linker" "/libexec/l=
d-elf.so.1" "--hash-style=3Dboth" "--enable-new-dtags" "-o" "a.out" "/usr/l=
ib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" "-L/usr/lib" "/tmp/hello=
-7a4c72.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "=
--as-needed" "-lgcc_s" "--no-as-needed" "/usr/lib/crtend.o" "/usr/lib/crtn.=
o"

--ZPDwMsyfds7q4mrK
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEcBAEBAgAGBQJihUqJAAoJEKzQXbSebgfAQzkIAJ1pbYRszctlW8uhfZqE46lJ
WTYkj/4x3/zy/vY38hs2NpGO4O57Ti8JhoAfYY1TExhACpBlysidPW3bxc+84sSl
JdUigqDNGoF0AxrqSnRI7mhyeTa5gUckK3nXXcBuXtH++QYnN471/jo2r/Sj7Fqb
i+t6UwBi5ppPuXuj/fCL8r1UlVL1skhJVxpsERolixORWNkFJ1cSK74ONetughMV
1OnJ4JgjCvoP3faREDyikSMpdt/MtEqLg1bHyNzM3pdZ4cbGRry+cIG28pgrxA9T
gjPuP93HqO10kDgi3DC1HCUPv+dRBsqbY7Cc1Nwe/kRUP+dU+2Cpx8aSl6PhQew=
=Xw81
-----END PGP SIGNATURE-----

--ZPDwMsyfds7q4mrK--