Page MenuHomeFreeBSD

add asan_static to build
ClosedPublic

Authored by aokblast on Oct 28 2023, 5:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 23, 8:41 AM
Unknown Object (File)
Sep 28 2024, 4:28 AM
Unknown Object (File)
Sep 28 2024, 1:31 AM
Unknown Object (File)
Sep 26 2024, 11:04 PM
Unknown Object (File)
Sep 26 2024, 4:08 PM
Unknown Object (File)
Sep 22 2024, 9:05 AM
Unknown Object (File)
Sep 21 2024, 1:14 PM
Unknown Object (File)
Sep 21 2024, 10:32 AM
Subscribers

Details

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aokblast edited the summary of this revision. (Show Details)EditedOct 28 2023, 5:46 PM
aokblast added a reviewer: lwhsu.

The problem is found when I was looking at this issue.
Currently, -DWITH_ASAN cannot compile successfully before and after this patch.
After applying this patch, the error becomes:

ld: error: duplicate symbol: hexdump
>>> defined at sanitizer_common_interceptors.inc:10361 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:10361)
>>>            asan_interceptors.o:(__interceptor_hexdump) in archive /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/16/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at mpsutil.c:166 (/usr/src/usr.sbin/mpsutil/mpsutil.c:166)
>>>            mpsutil.o:(.text+0x1350)

I think this is because userland has their own hexdump and also hexdump is a library call catched by asan.
I have no idea how to fix it. Maybe add blacklist on program defined their hexdump?
Hope anyone can give me some idea. Thanks!

The problem is found when I was looking at this issue.
Currently, -DWITH_ASAN cannot compile successfully before and after this patch.
After applying this patch, the error becomes:

ld: error: duplicate symbol: hexdump
>>> defined at sanitizer_common_interceptors.inc:10361 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:10361)
>>>            asan_interceptors.o:(__interceptor_hexdump) in archive /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/16/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at mpsutil.c:166 (/usr/src/usr.sbin/mpsutil/mpsutil.c:166)
>>>            mpsutil.o:(.text+0x1350)

I think this is because userland has their own hexdump and also hexdump is a library call catched by asan.
I have no idea how to fix it. Maybe add blacklist on program defined their hexdump?
Hope anyone can give me some idea. Thanks!

Add/copy more details here, in https://github.com/llvm/llvm-project/issues/65532#issuecomment-1754817792 , when building with:

make -DWITH_ASAN -DWITH_UBSAN KERNCONF=GENERIC-NODEBUG buildworld buildkernel -j4

The error message is:

ld: error: cannot open /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/16/lib/freebsd/libclang_rt.asan_static-x86_64.a: No such file or directory

I think it's reasonable to have this patch, and revise the interception of hexdump on FreeBSD?

https://github.com/llvm/llvm-project/commit/b4c840e70b630532325267a3dd81550569c5f0f9
https://reviews.llvm.org/D110471

ld: error: cannot open /usr/obj/usr/src/amd64.amd64/tmp/usr/lib/clang/16/lib/freebsd/libclang_rt.asan_static-x86_64.a: No such file or directory

libclang_rt.asan_static.a is linked when linking an executable (i.e. no -shared). This patch looks reasonable.

clang/16/lib/freebsd/libclang_rt.asan_static-x86_64.a instead of clang/16/lib/$triple/libclang_rt.asan_static.a indicates that FreeBSD does not use LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on. FreeBSD may want to change it. See https://reviews.llvm.org/D140011

This revision is now accepted and ready to land.Oct 29 2023, 6:33 PM

Yes, looks reasonable.

clang/16/lib/freebsd/libclang_rt.asan_static-x86_64.a instead of clang/16/lib/$triple/libclang_rt.asan_static.a indicates that FreeBSD does not use LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on. FreeBSD may want to change it. See https://reviews.llvm.org/D140011

Yes, this is on one of my long TODO lists. I will get to it at some point... :)

This revision was automatically updated to reflect the committed changes.