On Mac OS X 10.8 Mountain Lion, clang-3.1 does not work.
clang-3.1 (MacPorts)
% cat a.c
int main() {
return 0;
}
% clang-mp-3.1 --version # MacPorts port:clang-3.1
clang version 3.1 (branches/release_31)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
% clang-mp-3.1 a.c
Undefined symbols for architecture x86_64:
"start", referenced from:
-u command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
% clang-mp-3.1 -lcrt1.o a.c
% # it looks to be missing "start" in crt1.o.
clang-3.0 (MacPorts)
% clang-mp-3.0 --version # MacPorts port:clang-3.0
clang version 3.0 (tags/RELEASE_30/final)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
% clang-mp-3.0 a.c
% # compile succeed
clang-3.1 (Apple Xcode-4.4.1)
% /usr/bin/clang --version # Xcode 4.4.1
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
% /usr/bin/clang a.c
% # compile succeed
I guess the change of lib/Drivers/Tools.cpp at r152137( https://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?r1=152137&r2=152136&pathrev=152137 ) caused this problem.
@@ -4025,7 +4032,7 @@
CmdArgs.push_back("-lcrt1.o");
else if (getDarwinToolChain().isMacosxVersionLT(10, 6))
CmdArgs.push_back("-lcrt1.10.5.o");
- else
+ else if (getDarwinToolChain().isMacosxVersionLT(10, 8))
CmdArgs.push_back("-lcrt1.10.6.o");
// darwin_crt2 spec is empty.
I think this change should be reverted.