I am trying to use --thread-sanitizer option of clang on OSX:
$ clang++ -fthread-sanitizer -fpic tsan1.cc
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
[...]
clang -cc1 version 4.2 based upon LLVM 3.2svn default target x86_64-apple-darwin12.3.0
[...]
Undefined symbols for architecture x86_64:
"___tsan_func_entry", referenced from:
threadfunc(void*) in tsan1-6f7gbr.o
[...]
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Looks like a linkage error. Should I link with some additional libs?
ThreadSanitizer is unsupported on Darwin for C++ yet. This is unlikely to change in at least half a year.
It's been fixed.
According to https://clang.llvm.org/docs/ThreadSanitizer.html
ThreadSanitizer is supported on the following OS:
... Darwin arm64, x86_64, ...
Also I just used it without any problems.
Related
I am trying to compile simple C code on my system. I am running gcc version (4.9.2) on macOS 10.11.6.
ld: library not found for -lgcc
collect2: error: ld returned 1 exit status
I am unable to fix this issue. This problem is not letting me install any ./configure packages as well since they require gcc to work.
Even if there is a program called gcc under macOS, it is not a real gcc compiler. It is just a Clang compiler, as you can prove easily:
gcc --version
will print:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
You should be able to compile and link your program by omitting the -lgcc flag from the command line.
I met a usual error—— symbol(s) not found for architecture x86_64,but for an unusual reason. I have searched for a long time and found some methods,but they didn't work.
Anyone can help me?Thanks.there are some parameter about my Mac below:
# cc -v
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
# gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
THX!!!
I am trying to compile dynamic lib in Mac OS X Mavericks, but when I try to link it, it says:
Undefined symbols for architecture i386:
"operator new(unsigned long, int, char const*, int)", referenced from:
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compile flags I use:
Wall -Wextra -m32 -march=pentium4 -arch i386 -fvisibility=hidden
tried with
-stdlib=libc++ -lstdc++ -lc++
not helping.
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Please help!
EDIT:
Ok, lack of attention:
ld: symbol(s) not found for architecture i386
So, figured out that this is only happening when -g flag is present :)
For release build there is no error.
The question that arises is why there is no debug information symbols on MacOS X for libc++ (operator new). Any clues?
I am trying to compile boost C++ using clang.
./b2 --prefix=~/boost --includedir=~/boost/include --libdir=~/boost/lib toolset=clang cxxflags="-std=c++11 -stdlib=libc++ -isystem ~/libcxx/include/" linkflags="-stdlib=libc++ -L ~/libcxx/lib/"
When I see log file it gives error saying
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
__GLOBAL__I_a in exceptions.o
"boost::system::generic_category()", referenced from:
__GLOBAL__I_a in exceptions.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
my default clang is clang-mp-3.3. Can anyone please help me figure out what this problem is.
After searching for the reason of error in the web I found this which explain about compiling boost with clang. I am not sure why adding define=BOOST_SYSTEM_NO_DEPRECATED made it worked. Please do comment anyone who knows why it worked. I was then able to compile with no error but I still see some warnings but it worked for me for now.
The default clang I am using is (clang-mp-3.3)
$ clang -v
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
./bootstrap.sh --with-toolset=clang --without-libraries=mpi,python,graph_parallel
./b2 clean
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" define=BOOST_SYSTEM_NO_DEPRECATED
I have succesfully compiled the LLVM kalidoscope examples in C.
Now I'm extending the code with:
#include "llvm/Support/CommandLine.h"
static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input file>"), cl::Required);
int mail(...
now i compile using:
clang++ -g toy.cpp llvm-config --cppflags --ldflags --libs all -O3 -o toy
and after this change i receive the following error:
Undefined symbols for architecture x86_64:
"typeinfo for llvm::cl::GenericOptionValue", referenced from:
typeinfo for llvm::cl::OptionValueCopy<std::string> in toy-Pq1GSI.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What could be wrong, and how can i fix it?
Versions:
clang++ -v Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) Target: x86_64-apple-darwin12.2.0 Thread model: posix
brew info llvm llvm: stable 3.2 (bottled), HEAD http://llvm.org/ /usr/local/Cellar/llvm/3.2 (628 files, 106M) * https://github.com/mxcl/homebrew/commits/master/Library/Formula/llvm.rb
==> Options
--all-targets Build all target backends
--universal Build a universal binary
--rtti Build with C++ RTTI
--shared Build LLVM as a shared library
--with-clang Build Clang C/ObjC/C++ frontend
==> Caveats Extra tools and bindings are installed in /usr/local/Cellar/llvm/3.2/share/llvm and /usr/local/Cellar/llvm/3.2/share/clang.
It seems that changing the compile command to this is a fix:
clang++ -g toy.cpp llvm-config --cxxflags --ldflags --libs -O3 -o toy