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)
Mar 13 2024, 12:24 AM
Unknown Object (File)
Mar 13 2024, 12:24 AM
Unknown Object (File)
Mar 9 2024, 9:36 AM
Unknown Object (File)
Jan 5 2024, 10:34 PM
Unknown Object (File)
Dec 26 2023, 10:16 PM
Unknown Object (File)
Dec 25 2023, 5:25 PM
Unknown Object (File)
Dec 23 2023, 6:44 PM
Unknown Object (File)
Dec 23 2023, 2:17 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.