Testcase: Port net-im/toxex @ rev.b261f70d7a8c5bc65839db4f25b9992a4afcf069 Error: > ld: error: cannot open /usr/lib/clang/11.0.1/lib/freebsd/libclang_rt.asan-aarch64.a: No such file or directory
asan runtime support is currently built only for i386, amd64, and riscv.
Yep, upstream doesn't yet support aarch64 for the sanitizers. If I attempt to build it on an aarch64 machine, I see: /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1811:23: error: field has incomplete type 'struct _aarch64_ctx' struct _aarch64_ctx head; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1811:10: note: forward declaration of '__sanitizer::_aarch64_ctx' struct _aarch64_ctx head; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1817:35: error: no member named '__reserved' in '__mcontext' u8 *aux = ucontext->uc_mcontext.__reserved; ~~~~~~~~~~~~~~~~~~~~~ ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1820:12: error: member access into incomplete type '__sanitizer::_aarch64_ctx' if (ctx->size == 0) break; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1811:10: note: forward declaration of '__sanitizer::_aarch64_ctx' struct _aarch64_ctx head; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1821:12: error: member access into incomplete type '__sanitizer::_aarch64_ctx' if (ctx->magic == kEsrMagic) { ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1811:10: note: forward declaration of '__sanitizer::_aarch64_ctx' struct _aarch64_ctx head; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1825:15: error: member access into incomplete type '__sanitizer::_aarch64_ctx' aux += ctx->size; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1811:10: note: forward declaration of '__sanitizer::_aarch64_ctx' struct _aarch64_ctx head; ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:2055:31: error: no member named 'pc' in '__mcontext' *pc = ucontext->uc_mcontext.pc; ~~~~~~~~~~~~~~~~~~~~~ ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:2056:31: error: no member named 'regs' in '__mcontext' *bp = ucontext->uc_mcontext.regs[29]; ~~~~~~~~~~~~~~~~~~~~~ ^ /home/dim/src/main/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:2057:31: error: no member named 'sp' in '__mcontext' *sp = ucontext->uc_mcontext.sp; ~~~~~~~~~~~~~~~~~~~~~ ^ 8 errors generated. `_aarch64_ctx` is a Linux-specific context struct from /usr/include/aarch64-linux-gnu/asm/sigcontext.h: /* * Header to be used at the beginning of structures extending the user * context. Such structures must be placed after the rt_sigframe on the stack * and be 16-byte aligned. The last structure must be a dummy one with the * magic and size set to 0. */ struct _aarch64_ctx { __u32 magic; __u32 size; }; but obviously it doesn't exist in FreeBSD. Similarly, struct ucontext and mcontext have different members, and aren't generally compatible. I think the only way to get this implemented is to have somebody with aarch64 knowledge, who can attempt to fix them up and submit reviews upstream.
I'm not sure how it should be done on aarch64, but fixing sanitizers on powerpc64* was quite easy: https://github.com/llvm/llvm-project/commit/315d792130258a9b7250494be8d002ebb427b08f Based on that commit, a person with aarch64 knowledge and interest could fix aarch64 build.
Is it still the case arm64 is not yet supported? I tested this on 13.2-RELEASE and 14.0-RELEASE. I get the following errors: 14.0 % ... c++ -o xxx.pm -g main.o -L/usr/local/lib -fprofile-instr-generate -fcoverage-map ping -fsanitize=address -fno-omit-frame-pointer -L.. -Wl,--rpath=.. -lpthread - ledit -lboost_program_options -lboost_system -lboost_system -lpthread -ledit ld: error: cannot open /usr/lib/clang/16/lib/freebsd/libclang_rt.asan_static-aar ch64.a: No such file or directory ld: error: cannot open /usr/lib/clang/16/lib/freebsd/libclang_rt.asan-aarch64.a: No such file or directory ld: error: cannot open /usr/lib/clang/16/lib/freebsd/libclang_rt.asan_cxx-aarch6 4.a: No such file or directory c++: error: linker command failed with exit code 1 (use -v to see invocation) 13.2 % ld: error: cannot open /usr/lib/clang/14.0.5/lib/freebsd/libclang_rt.asan_static -aarch64.a: No such file or directory ld: error: cannot open /usr/lib/clang/14.0.5/lib/freebsd/libclang_rt.asan-aarch6 4.a: No such file or directory ld: error: cannot open /usr/lib/clang/14.0.5/lib/freebsd/libclang_rt.asan_cxx-aa rch64.a: No such file or directory c++: error: linker command failed with exit code 1 (use -v to see invocation)
(In reply to ota from comment #4) The Makefile for this (lib/libclang_rt/Makefile) still has only x86 listed for asan, cfi, ubsan and a few other components. I think upstream does support these (or at least part of them) for aarch64, so thanks for the reminder. I will take another look at getting those libraries in.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=e77a1bb2757471ab3fed0750b76eeb15d0c7b10a commit e77a1bb2757471ab3fed0750b76eeb15d0c7b10a Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-12-28 12:57:41 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2023-12-28 12:57:41 +0000 Reorganize libclang_rt Makefile and make more lib/arch combos available Upstream has made more clang runtime libraries available for more architectures, so add them. To make this easier, split up subdir lists into functional parts (asan, tsan, etc), and put each architecture into its own .if block. Effectively, this adds the following libraries for aarch64: asan, cfi, fuzzer, msan, safestack, stats, tsan, ubsan, xray. PR: 262706 MFC after: 3 days lib/libclang_rt/Makefile | 162 ++++++++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 71 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8334205c84cf8fb2006cc9dc9fdeecaa855242b3 commit 8334205c84cf8fb2006cc9dc9fdeecaa855242b3 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-12-28 12:57:41 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-01-01 16:34:04 +0000 Reorganize libclang_rt Makefile and make more lib/arch combos available Upstream has made more clang runtime libraries available for more architectures, so add them. To make this easier, split up subdir lists into functional parts (asan, tsan, etc), and put each architecture into its own .if block. Effectively, this adds the following libraries for aarch64: asan, cfi, fuzzer, msan, safestack, stats, tsan, ubsan, xray. PR: 262706 MFC after: 3 days (cherry picked from commit e77a1bb2757471ab3fed0750b76eeb15d0c7b10a) lib/libclang_rt/Makefile | 162 ++++++++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 71 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5c95aeb90f70a66c75869fa0de44283c04bbd725 commit 5c95aeb90f70a66c75869fa0de44283c04bbd725 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-12-28 12:57:41 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-01-01 16:41:43 +0000 Reorganize libclang_rt Makefile and make more lib/arch combos available Upstream has made more clang runtime libraries available for more architectures, so add them. To make this easier, split up subdir lists into functional parts (asan, tsan, etc), and put each architecture into its own .if block. Effectively, this adds the following libraries for aarch64: asan, cfi, fuzzer, msan, safestack, stats, tsan, ubsan, xray. PR: 262706 MFC after: 3 days (cherry picked from commit e77a1bb2757471ab3fed0750b76eeb15d0c7b10a) lib/libclang_rt/Makefile | 161 ++++++++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 70 deletions(-)
I'm not sure if this is worth an Errata Notice? It's a bit of a pity that 14.0 shipped without most of the sanitizer libraries on arm64, though.
(In reply to Dimitry Andric from comment #9) IMO no, this is a missing feature that should've been there but at the same time there is a suitable replacement in the llvm ports, so without a compelling reason I'm not sure it's worth the overhead to write up the details and roll a build.
Let's close this then. The libraries will be available in the upcoming 14.1-RELEASE (and 13.3-RELEASE, when it's there).
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f0620ceeccf070a69352105c5dbc23cff499a732 commit f0620ceeccf070a69352105c5dbc23cff499a732 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 13:53:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-21 17:05:25 +0000 Fix building of several libclang_rt libraries for powerpc64 and powerp64le I reorganized the libclang_rt Makefile in e77a1bb27574 to make it more readable and maintainable, but the check for 32-bit powerpc was wrong. This caused almost no libclang_rt libraries to be built for powerpc64 and powerpc64le. PR: 262706 Reported by: tuexen Fixes: e77a1bb27574 MFC after: 3 days lib/libclang_rt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=897a485c34464a44b768f13127d94137229eb83d commit 897a485c34464a44b768f13127d94137229eb83d Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 20:44:46 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-21 20:44:46 +0000 Slightly reorganize libclang_rt Makefile again Make a separate .elif section for MACHINE_ARCH==powerpc, and subdivide the MACHINE_CPUARCH values under it. If at some point more sanitizer libraries become available for powerpc CPU architectures, they can be added before the "nothing for other powerpc yet" case. Similar for the MACHINE_ARCH==arm case. PR: 262706 Fixes: e77a1bb27574 MFC after: 3 days lib/libclang_rt/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=35a61f4a25ac5301b83d2c4835081d60de5b8b1e commit 35a61f4a25ac5301b83d2c4835081d60de5b8b1e Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 20:44:46 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-24 00:36:26 +0000 Slightly reorganize libclang_rt Makefile again Make a separate .elif section for MACHINE_ARCH==powerpc, and subdivide the MACHINE_CPUARCH values under it. If at some point more sanitizer libraries become available for powerpc CPU architectures, they can be added before the "nothing for other powerpc yet" case. Similar for the MACHINE_ARCH==arm case. PR: 262706 Fixes: e77a1bb27574 MFC after: 3 days (cherry picked from commit 897a485c34464a44b768f13127d94137229eb83d) lib/libclang_rt/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=880f35eb5d489ae6b8d09da82f577381f24157d2 commit 880f35eb5d489ae6b8d09da82f577381f24157d2 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 13:53:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-24 00:36:18 +0000 Fix building of several libclang_rt libraries for powerpc64 and powerp64le I reorganized the libclang_rt Makefile in e77a1bb27574 to make it more readable and maintainable, but the check for 32-bit powerpc was wrong. This caused almost no libclang_rt libraries to be built for powerpc64 and powerpc64le. PR: 262706 Reported by: tuexen Fixes: e77a1bb27574 MFC after: 3 days (cherry picked from commit f0620ceeccf070a69352105c5dbc23cff499a732) lib/libclang_rt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5c588a23c96b88327f87bb8ef6c795c442d56c2a commit 5c588a23c96b88327f87bb8ef6c795c442d56c2a Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 20:44:46 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-24 00:37:29 +0000 Slightly reorganize libclang_rt Makefile again Make a separate .elif section for MACHINE_ARCH==powerpc, and subdivide the MACHINE_CPUARCH values under it. If at some point more sanitizer libraries become available for powerpc CPU architectures, they can be added before the "nothing for other powerpc yet" case. Similar for the MACHINE_ARCH==arm case. PR: 262706 Fixes: e77a1bb27574 MFC after: 3 days (cherry picked from commit 897a485c34464a44b768f13127d94137229eb83d) lib/libclang_rt/Makefile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=72d9e1e0ca66ca39ca157731a65be32c63916252 commit 72d9e1e0ca66ca39ca157731a65be32c63916252 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-03-21 13:53:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-03-24 00:37:23 +0000 Fix building of several libclang_rt libraries for powerpc64 and powerp64le I reorganized the libclang_rt Makefile in e77a1bb27574 to make it more readable and maintainable, but the check for 32-bit powerpc was wrong. This caused almost no libclang_rt libraries to be built for powerpc64 and powerpc64le. PR: 262706 Reported by: tuexen Fixes: e77a1bb27574 MFC after: 3 days (cherry picked from commit f0620ceeccf070a69352105c5dbc23cff499a732) lib/libclang_rt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
I get the same error here after upgrade from 13.2 => 13.3: ld: error: cannot open /usr/lib/clang/17/lib/freebsd/libclang_rt.asan-x86_64.a: No such file or directory The machine IS a AMD64: FreeBSD bigchief.fehnet.de 13.3-RELEASE-p1 FreeBSD 13.3-RELEASE-p1 GENERIC amd64 All updates installed. regards. --eh.
Sorry: Should say: the same *kind* of error. --eh.
(In reply to feh from comment #19) It looks rather different: this bug was originally about aarch64 not supporting some (or all) of the sanitizers. Later, it became about some refactoring in the Makefiles causing libraries for some architectures to be erroneously skipped. In your case, it looks like you used freebsd-update? And maybe it was not aware that you had the /usr/lib/clang directory at all, so it did not update it? How did you upgrade, exactly?