[MacPorts] #38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread -------------------------------+-------------------------------- Reporter: andrew.c.morrow@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Keywords: | Port: clang-3.3 -------------------------------+-------------------------------- I'm using clang-3.3 @3.3-r173279 on OS X 10.8.3: {{{
/opt/local/bin/clang++-mp-3.3 --version clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix }}}
Given a simple program, I'd like to build it with ThreadSanitizer by passing -fsanitize=thread, but the link step fails: {{{
cat ./hello_world.cpp #include <cstdlib> #include <iostream>
int main(int argc, char* argv[]) { std::cout << "Hello, World!\n"; return EXIT_SUCCESS; }
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -o ./hello_world Undefined symbols for architecture x86_64: "___tsan_func_entry", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_func_exit", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_init", referenced from: anon in hello_world-RhjEoO.o "___tsan_write4", referenced from: _main in hello_world-RhjEoO.o "___tsan_write8", referenced from: _main in hello_world-RhjEoO.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 a -### dump of the link line: {{{
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -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=thread" "-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-FGj5NL.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-FGj5NL.o" "-lstdc++" "-lSystem" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.osx.a" }}}
Ideally, clang-3.3 would support ThreadSanitizer out of the box. -- Ticket URL: <https://trac.macports.org/ticket/38528> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+-------------------------------- Reporter: andrew.c.morrow@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.3 | --------------------------------+-------------------------------- Comment (by andrew.c.morrow@…): I realized that a -v dump might be useful too: {{{
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -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=thread -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-zx4JfM.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-zx4JfM.o -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: "___tsan_func_entry", referenced from: _main in hello_world-zx4JfM.o ___cxx_global_var_init in hello_world-zx4JfM.o __GLOBAL__I_a in hello_world-zx4JfM.o "___tsan_func_exit", referenced from: _main in hello_world-zx4JfM.o ___cxx_global_var_init in hello_world-zx4JfM.o __GLOBAL__I_a in hello_world-zx4JfM.o "___tsan_init", referenced from: anon in hello_world-zx4JfM.o "___tsan_read4", referenced from: _main in hello_world-zx4JfM.o "___tsan_write4", referenced from: _main in hello_world-zx4JfM.o "___tsan_write8", referenced from: _main in hello_world-zx4JfM.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) }}}
-- Ticket URL: <https://trac.macports.org/ticket/38528#comment:2> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Changes (by larryv@…): * cc: andrew.c.morrow@… (removed) * owner: macports-tickets@… => jeremyhu@… Comment: Thanks. Please Cc relevant port maintainers in the future. -- Ticket URL: <https://trac.macports.org/ticket/38528#comment:3> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: wontfix | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Changes (by jeremyhu@…): * status: new => closed * resolution: => wontfix -- Ticket URL: <https://trac.macports.org/ticket/38528#comment:4> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: wontfix | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Comment (by jeremyhu@…): tsan isn't supported on darwin -- Ticket URL: <https://trac.macports.org/ticket/38528#comment:5> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: wontfix | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Comment (by egall@…): Replying to [comment:5 jeremyhu@…]:
tsan isn't supported on darwin
so shouldn't the flag just be ignored then when the user tries to use it? -- Ticket URL: <https://trac.macports.org/ticket/38528#comment:6> MacPorts <http://www.macports.org/> Ports system for OS X
#38528: clang-3.3 @3.3-r173279 can't link a C++ program with -fsanitize=thread --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: wontfix | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Old description:
I'm using clang-3.3 @3.3-r173279 on OS X 10.8.3:
{{{
/opt/local/bin/clang++-mp-3.3 --version clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix }}}
Given a simple program, I'd like to build it with ThreadSanitizer by passing -fsanitize=thread, but the link step fails:
{{{
cat ./hello_world.cpp #include <cstdlib> #include <iostream>
int main(int argc, char* argv[]) { std::cout << "Hello, World!\n"; return EXIT_SUCCESS; }
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -o ./hello_world Undefined symbols for architecture x86_64: "___tsan_func_entry", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_func_exit", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_init", referenced from: anon in hello_world-RhjEoO.o "___tsan_write4", referenced from: _main in hello_world-RhjEoO.o "___tsan_write8", referenced from: _main in hello_world-RhjEoO.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 a -### dump of the link line:
{{{
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -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=thread" "-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-FGj5NL.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-FGj5NL.o" "-lstdc++" "-lSystem" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.osx.a" }}}
Ideally, clang-3.3 would support ThreadSanitizer out of the box.
New description: I'm using clang-3.3 @3.3-!r173279 on OS X 10.8.3: {{{
/opt/local/bin/clang++-mp-3.3 --version clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix }}}
Given a simple program, I'd like to build it with ThreadSanitizer by passing -fsanitize=thread, but the link step fails: {{{
cat ./hello_world.cpp #include <cstdlib> #include <iostream>
int main(int argc, char* argv[]) { std::cout << "Hello, World!\n"; return EXIT_SUCCESS; }
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -o ./hello_world Undefined symbols for architecture x86_64: "___tsan_func_entry", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_func_exit", referenced from: _main in hello_world-RhjEoO.o ___cxx_global_var_init in hello_world-RhjEoO.o __GLOBAL__I_a in hello_world-RhjEoO.o "___tsan_init", referenced from: anon in hello_world-RhjEoO.o "___tsan_write4", referenced from: _main in hello_world-RhjEoO.o "___tsan_write8", referenced from: _main in hello_world-RhjEoO.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 a -### dump of the link line: {{{
/opt/local/bin/clang++-mp-3.3 ./hello_world.cpp -fsanitize=thread -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=thread" "-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-FGj5NL.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-FGj5NL.o" "-lstdc++" "-lSystem" "/opt/local/libexec/llvm-3.3/bin/../lib/clang/3.3/lib/darwin/libclang_rt.osx.a" }}}
Ideally, clang-3.3 would support ThreadSanitizer out of the box. -- Comment (by larryv@…): Replying to [comment:6 egall@…]:
Replying to [comment:5 jeremyhu@…]:
tsan isn't supported on darwin
so shouldn't the flag just be ignored then when the user tries to use it?
It should probably throw an error, really. But that’s for upstream to fix. -- Ticket URL: <https://trac.macports.org/ticket/38528#comment:7> MacPorts <http://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts