Opened 8 years ago

Closed 8 years ago

#53600 closed defect (fixed)

clang-4.0 @4.0-r292772_1: cannot build executables on OS X 10.10.5

Reported by: mopihopi Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia), larryv (Lawrence Velázquez)
Port: clang-4.0

Description

On OS X 10.10.5, clang-4.0 @4.0-r292772_1 installs successfully but executables fail to build.

$ cat test.c
int main() { return 0; }
$ clang-mp-4.0 test.c
ld: unknown option: -no_deduplicate
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ 

XCode 7.2.1, ld64-latest @274.1_1+llvmdev

Change History (6)

comment:1 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Works for me:

$ echo 'int main() {return 0;}'  | clang-mp-4.0 -x c - -v -Wl,-v
clang version 4.0.0 (branches/release_40 292772)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-4.0/bin
 "/opt/local/libexec/llvm-4.0/bin/clang" -cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -target-linker-version 274.1 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0 -fdebug-compilation-dir /Users/jeremy -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/c1/7p4m5bx904392j49x1w2vyxh0000gn/T/--73046a.o -x c -
clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target x86_64-apple-darwin16.5.0
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/opt/local/libexec/llvm-4.0/bin/ld" -demangle -lto_library /opt/local/libexec/llvm-4.0/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o a.out /var/folders/c1/7p4m5bx904392j49x1w2vyxh0000gn/T/--73046a.o -v -lSystem /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/lib/darwin/libclang_rt.osx.a
@(#)PROGRAM:ld  PROJECT:ld64-274.1
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
Library search paths:
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/

comment:2 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Please provide the verbose output like I did above. What is the variant of your active ld64 port?

comment:3 Changed 8 years ago by mopihopi

$ clang-mp-4.0 -v test.c
clang version 4.0.0 (branches/release_40 292772)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-4.0/bin
 "/opt/local/libexec/llvm-4.0/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.1 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0 -fdebug-compilation-dir /Users/markh/tmp -ferror-limit 19 -fmessage-length 90 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/pm/6qxfxkcj3bz9k7zpcv82g86h0000gn/T/test-fadeac.o -x c test.c
clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target x86_64-apple-darwin14.5.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/opt/local/libexec/llvm-4.0/bin/ld" -demangle -lto_library /opt/local/libexec/llvm-4.0/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o a.out /var/folders/pm/6qxfxkcj3bz9k7zpcv82g86h0000gn/T/test-fadeac.o -lSystem /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/lib/darwin/libclang_rt.osx.a
ld: unknown option: -no_deduplicate
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ 
$ ls -l /opt/local/libexec/llvm-4.0/bin/ld
lrwxr-xr-x  1 root  admin  26 Feb  3 05:23 /opt/local/libexec/llvm-4.0/bin/ld@ -> /opt/local/libexec/ld64/ld
$ ls -l /opt/local/libexec/ld64/ld
lrwxr-xr-x  1 root  admin  8 Dec 27 10:03 /opt/local/libexec/ld64/ld@ -> ld-xcode
$ ls -l /opt/local/libexec/ld64/ld-xcode 
-rwxr-xr-x  1 root  admin  169 Dec 19 03:38 /opt/local/libexec/ld64/ld-xcode*
$ 
$ port installed 'ld*' and active
The following ports are currently installed:
  ld64 @3_0+ld64_xcode (active)
  ld64-latest @274.1_1+llvmdev (active)
  ld64-xcode @2_0 (active)
$ uname -v
Darwin Kernel Version 14.5.0: Sun Sep 25 22:07:15 PDT 2016; root:xnu-2782.50.9~1/RELEASE_X86_64
$ xcodebuild -version
Xcode 7.2.1
Build version 7C1002
$ 

comment:4 Changed 8 years ago by mopihopi

$ echo 'int main() {return 0;}'  | clang-mp-4.0 -x c - -v -Wl,-v
clang version 4.0.0 (branches/release_40 292772)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-4.0/bin
 "/opt/local/libexec/llvm-4.0/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.1 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0 -fdebug-compilation-dir /Users/markh/tmp -ferror-limit 19 -fmessage-length 90 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/pm/6qxfxkcj3bz9k7zpcv82g86h0000gn/T/--0710ea.o -x c -
clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target x86_64-apple-darwin14.5.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/opt/local/libexec/llvm-4.0/bin/ld" -demangle -lto_library /opt/local/libexec/llvm-4.0/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o a.out /var/folders/pm/6qxfxkcj3bz9k7zpcv82g86h0000gn/T/--0710ea.o -v -lSystem /opt/local/libexec/llvm-4.0/bin/../lib/clang/4.0.0/lib/darwin/libclang_rt.osx.a
@(#)PROGRAM:ld  PROJECT:ld64-253.9
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
ld: unknown option: -no_deduplicate
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ 

comment:5 Changed 8 years ago by mopihopi

I just installed ld64 with no variants (apparently no variants means to use ld64-latest) and it is working now, thanks for the hint!

I think the +ld64_xcode variant was required at some point in the past because the source code had not yet been released for the latest ld64 but it was nevertheless required for some ports. The only way to get it was via xcode. Apparently source was released later but it didn't get switched back.

It would be nice if the clang-4.0 port ensured that it had a new enough ld dependency, but if you don't want to use this ticket for that then I am fine with closing it, as clang-4.0 is now working for me after manually changing the ld64 variant.

comment:6 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: newclosed

Well that'd be why.

Yes, the +ld64_xcode variant is recommended if you have a version of Xcode that provides a linker newer than ld64-latest. You've got Xcode 7.2.1, so your linker is a bit dated. You've taken the appropriate steps to resolve the issue.

The linker version for clang issue is complicated and won't be addressed in this ticket. There are tickets already tracking that upstream.

Note: See TracTickets for help on using tickets.