From nobody Sat Dec 25 11:55:55 2021 X-Original-To: dev-commits-src-branches@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 BD50C18F371B; Sat, 25 Dec 2021 11:55:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JLj7K3wmHz4lLx; Sat, 25 Dec 2021 11:55:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F5A416B58; Sat, 25 Dec 2021 11:55:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BPBttoM006975; Sat, 25 Dec 2021 11:55:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBttUU006974; Sat, 25 Dec 2021 11:55:55 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:55 GMT Message-Id: <202112251155.1BPBttUU006974@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: f379ad3de40c - stable/12 - compiler-rt: add aarch64 init function for LSE atomics List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f379ad3de40c781c9fbb4cf840a9a4b53d9b5254 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rs0gkwvjDw/h3io/eiNCZ6Ha5Y2v52hgVAg0HpMB4HI=; b=k98nnnJk89f3ogvheFNtzKvAMwJL4Mbv05g+295rCUn4pEez6XnCL4hL78L///D9BUdSx4 PkYjryOzZsgDPumuU2eAzHIXwjqBmEc3AH0ICGueAD2Ke2d1Q1WGEdemVZDqDIRi4g2vEw eQw69mfQ80SKV1r1ciBmLWWX9sG7xqOEG+W4djeNvICDFsEOLHE9FonhOdW0dpRK9Bj4VW vgez9w5AjHy3XkQ3afeOuyJX9EccipdSm40+uD1aGkl3rSS2x05jhKce6NAk8gbZHD5Eql +TPn91gV5nO08XE3XR4mTp2jiKY2E4kkoFUK1fRHF/LWiynBOLg8flT9rkd+Sw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433358; a=rsa-sha256; cv=none; b=F3rVVx2Udge0T7vWgcI3jBNHfDr9vfkymppc6BfxYWspsKVrH+mbQQwyS1b8CcaUUE5Qee u4XzaSj8UFujk7fED4DICNpfcD/f+fyrK654XqXk/AmV6rmDZdJUNDDQr9r48YZgeqLxOF GTtuKcSNPIiXP3nTpbDfIXpJc5qTuZnPzAepqquWm3V602V2F+IAoG3e/53e0hJ/y9YRRt ZlU3ZXocRWXfwCcVrP8w/uPN2YRtJ2oPJShbT03PanOrNboEyDyAbZMsYT4Xd8OwnL8tiU sVuUhVLyGtLx0d9H/agqjMyCDBBwOWvrDnqy6aMSOXLfiGf4n05Hf62chZCCIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=f379ad3de40c781c9fbb4cf840a9a4b53d9b5254 commit f379ad3de40c781c9fbb4cf840a9a4b53d9b5254 Author: Dimitry Andric AuthorDate: 2021-09-06 19:23:10 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:25 +0000 compiler-rt: add aarch64 init function for LSE atomics As reported by Ronald, adding the out-of-line LSE atomics helpers for aarch64 to compiler-rt was not sufficient to link programs using these, as they also require a __aarch64_have_lse_atomics global. This is initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar to the x86 CPU model and feature detection in that file. Since upstream does not yet have a FreeBSD specific implementation for getting the required information, add a simple one that should work for now, while I try to get it sorted with the LLVM people. Reported by: Ronald Klop Fixes: cc55ee8009a5 PR: 257392 MFC after: 2 weeks (cherry picked from commit efe67f33c322265eb303ec0ab40275100795b22a) --- contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c | 6 ++++++ lib/libcompiler_rt/Makefile.inc | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c index 51bedd98c3d3..13cfeb05dcb8 100644 --- a/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c +++ b/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model.c @@ -775,8 +775,14 @@ _Bool __aarch64_have_lse_atomics #define HWCAP_ATOMICS (1 << 8) #endif static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) { +#if defined(__FreeBSD__) + unsigned long hwcap; + int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); + __aarch64_have_lse_atomics = result == 0 && (hwcap & HWCAP_ATOMICS) != 0; +#else unsigned long hwcap = getauxval(AT_HWCAP); __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; +#endif } #endif // defined(__has_include) #endif // __has_include() diff --git a/lib/libcompiler_rt/Makefile.inc b/lib/libcompiler_rt/Makefile.inc index 5766e835ea38..e9c63910209e 100644 --- a/lib/libcompiler_rt/Makefile.inc +++ b/lib/libcompiler_rt/Makefile.inc @@ -146,8 +146,9 @@ SRCF+= floatundisf SRCF+= floatundixf .endif -# __cpu_model support, only used on x86 -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +# __cpu_model support, only used on aarch64 and x86 +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "i386" SRCF+= cpu_model .endif