Opened 12 years ago
Closed 11 years ago
#38529 closed defect (wontfix)
clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=undefined
Reported by: | acmorrow (Andrew C. Morrow) | Owned by: | jeremyhu (Jeremy Huddleston Sequoia) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.1.3 |
Keywords: | Cc: | dave_gomboc@… | |
Port: | clang-3.3 |
Description
Clang version:
> /opt/local/bin/clang++-mp-3.3 --version clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix
Here is a simple program (note that this behavior didn't occur without the stream out of argc):
> cat ./hello_world.cpp #include <cstdlib> #include <iostream> int main(int argc, char* argv[]) { std::cout << "Hello, World!\n" << argc; return EXIT_SUCCESS; }
Trying to compile this with ubsan enabled via -fsanitize=undefined causes linking errors:
> /opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=undefined -o ./hello_world Undefined symbols for architecture x86_64: "typeinfo for __cxxabiv1::__class_type_info", referenced from: __ubsan::checkDynamicType(void*, void*, unsigned long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__si_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__vmi_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is the result of passing -###
> /opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=undefined -o ./hello_world -### clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix "/opt/local/libexec/llvm-3.3/bin/clang" "-cc1" "-triple" "x86_64-apple-macosx10.8.0" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "hello_world.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mdisable-fp-elim" "-masm-verbose" "-munwind-tables" "-target-cpu" "core2" "-target-linker-version" "134.9" "-resource-dir" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3" "-fmodule-cache-path" "/var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/clang-module-cache" "-fdeprecated-macro" "-fdebug-compilation-dir" "/Users/andrew/Documents/10gen/dev/src/experiments/hello_world" "-ferror-limit" "19" "-fmessage-length" "167" "-fsanitize=alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,null,object-size,return,shift,signed-integer-overflow,unreachable,vla-bound,vptr" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-10.8.0" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fencode-extended-block-signature" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-backend-option" "-vectorize-loops" "-o" "/var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/hello_world-YCepCL.o" "-x" "c++" "./hello_world.cpp" "/opt/local/libexec/llvm-3.3/bin/ld" "-demangle" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.8.0" "-o" "./hello_world" "/var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/hello_world-YCepCL.o" "-lstdc++" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.ubsan_osx.a" "-lstdc++" "-lSystem" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.osx.a"
And here is the result with -v
> /opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=undefined -o ./hello_world -v clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix "/opt/local/libexec/llvm-3.3/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -main-file-name hello_world.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3 -fmodule-cache-path /var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/clang-module-cache -fdeprecated-macro -fdebug-compilation-dir /Users/andrew/Documents/10gen/dev/src/experiments/hello_world -ferror-limit 19 -fmessage-length 167 -fsanitize=alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,null,object-size,return,shift,signed-integer-overflow,unreachable,vla-bound,vptr -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/hello_world-43INi3.o -x c++ ./hello_world.cpp clang -cc1 version 3.3 based upon LLVM 3.3svn default target x86_64-apple-darwin12.3.0 ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64" ignoring nonexistent directory "/usr/include/c++/4.0.0" ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/" ignoring nonexistent directory "/usr/include/c++/4.0.0/backward" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.2.1 /usr/include/c++/4.2.1/backward /usr/local/include /opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/opt/local/libexec/llvm-3.3/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o ./hello_world /var/folders/n4/y_lrzpxd3n99l4frqx4m8llw0000gt/T/hello_world-43INi3.o -lstdc++ /opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.ubsan_osx.a -lstdc++ -lSystem /opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.osx.a Undefined symbols for architecture x86_64: "typeinfo for __cxxabiv1::__class_type_info", referenced from: __ubsan::checkDynamicType(void*, void*, unsigned long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__si_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__vmi_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Supporting the various sanitize options in clang would be really useful.
Change History (4)
comment:1 Changed 12 years ago by acmorrow (Andrew C. Morrow)
Cc: | andrew.c.morrow@… added |
---|
comment:2 Changed 12 years ago by larryv (Lawrence Velázquez)
Cc: | andrew.c.morrow@… removed |
---|---|
Owner: | changed from macports-tickets@… to jeremyhu@… |
Thanks; please remember to Cc the port maintainer(s). You also don’t have to Cc yourself.
comment:4 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
Resolution: | → wontfix |
---|---|
Status: | new → closed |
upstream
Note: See
TracTickets for help on using
tickets.
Cc Me!