Re: Missing UBSan libs
On Mon, Jan 31 2022, Greg Steuck wrote: > Patrick Wildt writes: > >> regarding the missing userpace support: Since a few clang updates ago >> we import more than just the builtins of compiler-rt. This means we >> should have at least some related code in our tree, even if it is not >> built/complete. In base this seems to be gnu/llvm/compiler-rt and its subdirs. Something not present right now in the devel/llvm port. >> From the recent static analyzer mail thread it looks >> like people prefer to have such stuff in ports-clang, so, whatever. I only glanced at this thread but there is probably pushback against making clang even bigger and slower to build, which is a thing that I can understand. I'm not sure it would be a problem to build a few more llvm support libraries like ubsan. libclang_rt.profile.a comes to mind as an existing library that is built as part of the make build/release process. > This may or may not be analogous. How hard is it to build a base/ports > program with clang from ports? If it's a simple matter of > make CC=/usr/local/bin/cc CFLAGS=-fsanitize=undefined > then it makes little difference whether the base compiler includes > the libraries for UBSan reporting. > > jca@ WDYT, should I first target devel/llvm to have UBSan working or go > straight to /usr/src? Hard to tell without diving in further. :) My gut feeling is that in the end this should be provided by the base system, just like the rest of the compiler-rt / clang_rt.profile stuff*. And since we seem to already have the code in base but not in ports, I guess the answer is "base". Obviously in that case you have to replace the cmake setup with Makefiles. Those are broad hints, let me know if I can help further. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: Missing UBSan libs
Patrick Wildt writes: > regarding the missing userpace support: Since a few clang updates ago > we import more than just the builtins of compiler-rt. This means we > should have at least some related code in our tree, even if it is not > built/complete. From the recent static analyzer mail thread it looks > like people prefer to have such stuff in ports-clang, so, whatever. This may or may not be analogous. How hard is it to build a base/ports program with clang from ports? If it's a simple matter of make CC=/usr/local/bin/cc CFLAGS=-fsanitize=undefined then it makes little difference whether the base compiler includes the libraries for UBSan reporting. jca@ WDYT, should I first target devel/llvm to have UBSan working or go straight to /usr/src? Thanks Greg
Re: Missing UBSan libs
Am Sun, Jan 30, 2022 at 11:40:29AM -0800 schrieb Greg Steuck: > Greg Steuck writes: > > >> I notice people keep sending fixes to problems reported by UBSan. I > >> wanted to join the club, but the trivial thing listed at > >> https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html doesn't > >> work: > > My confusion is easily resolved. People use UBSan in the kernel where > anton@ did the integration work whereas userspace work is yet to happen. > > Thanks > Greg Hi, regarding the missing userpace support: Since a few clang updates ago we import more than just the builtins of compiler-rt. This means we should have at least some related code in our tree, even if it is not built/complete. From the recent static analyzer mail thread it looks like people prefer to have such stuff in ports-clang, so, whatever. Cheers, Patrick
Re: Missing UBSan libs
Greg Steuck writes: >> I notice people keep sending fixes to problems reported by UBSan. I >> wanted to join the club, but the trivial thing listed at >> https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html doesn't >> work: My confusion is easily resolved. People use UBSan in the kernel where anton@ did the integration work whereas userspace work is yet to happen. Thanks Greg
Re: Missing UBSan libs
To add a bit more color, the same problem happens with ports clang from llvm package: % pkg_info -I llvm llvm-13.0.0 modular, fast C/C++/ObjC compiler, static analyzer and tools % cat a.cc; /usr/local/bin/clang++ -fsanitize=undefined a.cc; ./a.out int main(int argc, char **argv) { int k = 0x7fff; k += argc; return 0; } ld: error: cannot open /usr/local/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory ld: error: cannot open /usr/local/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone_cxx-x86_64.a: No such file or directory clang-13: error: linker command failed with exit code 1 (use -v to see invocation) Greg Steuck writes: > I notice people keep sending fixes to problems reported by UBSan. I > wanted to join the club, but the trivial thing listed at > https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html doesn't > work: > > $ cat a.cc; clang++ -fsanitize=undefined a.cc; ./a.out > int main(int argc, char **argv) { > int k = 0x7fff; > k += argc; > return 0; > } > ld: error: cannot open > /usr/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone-x86_64.a: No > such file or directory > ld: error: cannot open > /usr/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone_cxx-x86_64.a: > No such file or directory > clang++: error: linker command failed with exit code 1 (use -v to see > invocation) > > Did we forget to ship the ubsan libs? The only related files in sets: > > ./usr/lib/clang/13.0.0/lib > ./usr/lib/clang/13.0.0/lib/libclang_rt.profile.a > > Thanks > Greg
Missing UBSan libs
I notice people keep sending fixes to problems reported by UBSan. I wanted to join the club, but the trivial thing listed at https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html doesn't work: $ cat a.cc; clang++ -fsanitize=undefined a.cc; ./a.out int main(int argc, char **argv) { int k = 0x7fff; k += argc; return 0; } ld: error: cannot open /usr/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory ld: error: cannot open /usr/lib/clang/13.0.0/lib/openbsd/libclang_rt.ubsan_standalone_cxx-x86_64.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) Did we forget to ship the ubsan libs? The only related files in sets: ./usr/lib/clang/13.0.0/lib ./usr/lib/clang/13.0.0/lib/libclang_rt.profile.a Thanks Greg