GCC 5.3: UBSAN versus -static-libstdc++
Paul Smith
paul@mad-scientist.net
Fri Dec 18 20:38:00 GMT 2015
Hi all. I normally build my code with -static-libgcc and -static
-libstdc++, so I don't need to worry about compiler and stdc++ library
versions when I copy programs around. I don't link with any other (non
-locally-built) C++ code so it works for me.
I'm using GNU/Linux with a version of GCC 5.3.0 / binutils 2.25.1 that
I built myself locally, and it works in all other respects.
However today I decided to try to add -fsanitize=undefined to my
compile and link lines, and this caused my link to fail with errors
such as:
/tools/cc/generic/bin/../lib/gcc/x86_64-generic-linux
-gnu/5.3.0/../../../../x86_64-generic-linux
-gnu/lib/../lib64/libubsan.a(ubsan_type_hash.o): In function
`findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)':
(.text+0x3c): undefined reference to `__dynamic_cast'
If I remove the -static-libstdc++ flag then it links fine.
I have used other sanitizers like ASAN for a long time, with static
libstdc++, with no problems.
Is it just the case that UBSAN cannot work with static libstdc++? Or
is my local installation of GCC 5.3 deficient somehow? Or is this a
bug that I should report?
Cheers!
More information about the Gcc-help
mailing list