From nobody Fri Sep 3 09:08:34 2021 X-Original-To: freebsd-ports@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 6F34717A3871 for ; Fri, 3 Sep 2021 09:08:43 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H1BmW2W9Vz4ZQf; Fri, 3 Sep 2021 09:08:43 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 04A11D60B; Fri, 3 Sep 2021 09:08:43 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (unknown [IPv6:2001:470:7a58:0:844a:8dea:913f:4cf7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 9DE964018D; Fri, 3 Sep 2021 11:08:40 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_778E539E-B5C6-4EFC-B83F-10ABD2E61294"; protocol="application/pgp-signature"; micalg=pgp-sha1 List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: (solved) Re: undefined symbol: __aarch64_ldadd8_acq_rel since llvm12 (mongodb44) From: Dimitry Andric X-Priority: 3 (Normal) In-Reply-To: <671841132.16.1630657914506@mailrelay> Date: Fri, 3 Sep 2021 11:08:34 +0200 Cc: Michal Meloun , FreeBSD Ports , Ed Maste Message-Id: References: <2089802880.12287.1627193420123@localhost> <671841132.16.1630657914506@mailrelay> To: Ronald Klop X-Mailer: Apple Mail (2.3654.120.0.1.13) X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_778E539E-B5C6-4EFC-B83F-10ABD2E61294 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 3 Sep 2021, at 10:31, Ronald Klop wrote: >=20 > Van: Ronald Klop > Datum: zondag, 25 juli 2021 08:10 > Aan: FreeBSD Ports , Michal Meloun = , Dimitry Andric > Onderwerp: (solved) Re: undefined symbol: __aarch64_ldadd8_acq_rel = since llvm12 (mongodb44) >=20 > Van: Dimitry Andric > Datum: 19 juli 2021 11:01 > Aan: Ronald Klop > CC: FreeBSD Ports , Michal Meloun = > Onderwerp: Re: undefined symbol: __aarch64_ldadd8_acq_rel since llvm12 = (mongodb44) >=20 > > > > > > On 19 Jul 2021, at 09:29, Ronald Klop wrote: > > > > > Does anybody have a clue why I get this error since clang 12 = on aarch64/arm64? > > > Do other ports have the same issue? > > > > > Regards, > > > Ronald. > > > > > Van: Ronald Klop > > > Datum: vrijdag, 16 juli 2021 09:43 > > > Aan: freebsd-arm@freebsd.org > > > Onderwerp: undefined symbol: __aarch64_ldadd8_acq_rel since llvm12 = (mongodb44) > > >> Hi, > > >> I'm also maintaining databases/mongodb44 and this gives undefined = symbols since llvm12 (I think). > > >> See: = http://www.ipv6proxy.net/go.php?u=3Dhttp://ampere2.nyi.freebsd.org/data/ma= in-arm64-default/pf44e1c1de734_s63ca9ea4f3/logs/errors/mongodb44-4.4.6.log= > > >> And look for: > > >> ld.lld: error: undefined symbol: __aarch64_ldadd8_acq_rel > > >> There are a bunch of similar symbols not found while linking. > > >> This compiles fine using llvm11 or on amd64. > > > > It turns out clang 12 now enables -moutline-atomics by default, but = we > > don't yet expose the necessary functions from compiler-rt. As a > > temporary workaround, compile with -mno-outline-atomics. Meanwhile, > > adding these functions to the compiler-rt lib is on my TODO list. ... > Hi Dimitry, >=20 > I upgraded my poudriere and tried building mongodb50 with = -moutline-atomics enabled. > [00:00:56] Host OSVERSION: 1400032 > [00:00:56] Jail OSVERSION: 1400032 > ... >=20 > [09:33:20] ld.lld: error: undefined hidden symbol: = __aarch64_have_lse_atomics > [09:33:20] >>> referenced by outline_atomic_cas1_1.S:121 > [09:33:20] >>> = outline_atomic_cas1_1.o:(__aarch64_cas1_relax) in archive = /usr/lib/libgcc.a > [09:33:20] >>> referenced by outline_atomic_cas1_1.S:121 > [09:33:20] >>> = outline_atomic_cas1_1.o:(__aarch64_cas1_relax) in archive = /usr/lib/libgcc.a > [09:33:20] >>> referenced by outline_atomic_cas1_2.S:121 > [09:33:20] >>> = outline_atomic_cas1_2.o:(__aarch64_cas1_acq) in archive = /usr/lib/libgcc.a > [09:33:20] >>> referenced 57 more times > [09:33:20] c++: error: linker command failed with exit code 1 (use -v = to see invocation) > [09:33:22] scons: *** [build/opt/mongo/shell/mongo] Error 1 > [09:33:58] ld.lld: error: undefined hidden symbol: = __aarch64_have_lse_atomics > [09:33:58] >>> referenced by outline_atomic_cas1_1.S:121 > [09:33:58] >>> = outline_atomic_cas1_1.o:(__aarch64_cas1_relax) in archive = /usr/lib/libgcc.a > [09:33:58] >>> referenced by outline_atomic_cas1_1.S:121 > [09:33:58] >>> = outline_atomic_cas1_1.o:(__aarch64_cas1_relax) in archive = /usr/lib/libgcc.a > [09:33:58] >>> referenced by outline_atomic_cas1_2.S:121 > [09:33:58] >>> = outline_atomic_cas1_2.o:(__aarch64_cas1_acq) in archive = /usr/lib/libgcc.a > [09:33:58] >>> referenced 57 more times > [09:33:59] c++: error: linker command failed with exit code 1 (use -v = to see invocation) > [09:33:59] scons: *** [build/opt/mongo/db/mongod] Error 1 It turns out that this function is defined in contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c, which we have compiled only for x86 until now. But upstream added the __aarch64_have_lse_atomics symbol and an initialization function for it. I tried simply enabling this file for the libcompiler-rt build on aarch64, but it turns out that the implementation is rather Linuxy, and does not compile on FreeBSD: contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c:778:25: error: = implicit declaration of function 'getauxval' is invalid in C99 = [-Werror,-Wimplicit-function-declaration] unsigned long hwcap =3D getauxval(AT_HWCAP); ^ 1 error generated. The implementation looks like: // LSE support detection for out-of-line atomics // using HWCAP and Auxiliary vector _Bool __aarch64_have_lse_atomics __attribute__((visibility("hidden"), nocommon)); #if defined(__has_include) #if __has_include() #include #ifndef AT_HWCAP #define AT_HWCAP 16 #endif #ifndef HWCAP_ATOMICS #define HWCAP_ATOMICS (1 << 8) #endif static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) { unsigned long hwcap =3D getauxval(AT_HWCAP); __aarch64_have_lse_atomics =3D (hwcap & HWCAP_ATOMICS) !=3D 0; } but in FreeBSD we don't have getauxval(), and I'm unsure if AT_HWCAP works on aarch64. As this is all outside my domain of knowledge I'd appreciate if somebody knows how to retrieve this information on our AArch64 implementation. :) -Dimitry --Apple-Mail=_778E539E-B5C6-4EFC-B83F-10ABD2E61294 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYTHmEgAKCRCwXqMKLiCW o4+/AKCsqGetdC2ucosYtbw9a7O5/mKozACgg5LfqrqtkoAHYft7cRBSamoYhiU= =KgtH -----END PGP SIGNATURE----- --Apple-Mail=_778E539E-B5C6-4EFC-B83F-10ABD2E61294--