meson: "Unable to detect linker for compiler" error in an osx cross-compile environment
Ran into it while trying to build dav1d project for macos/x64, using meson-1.0.2 with python 3.7 on i686-linux. The following copied from meson-log.txt:
-----
Detecting compiler via: /tmp/cc.sh --version
compiler returned <subprocess.Popen object at 0xb70d6e6c>
compiler stdout:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-apple-darwin9
Thread model: posix
compiler stderr:
Running command: /tmp/cc.sh -E -dM -
-----
Detecting linker via: /tmp/cc.sh -Wl,--version
linker returned <subprocess.Popen object at 0xb68dafec>
linker stdout:
linker stderr:
ld: unknown option: --version
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----
Detecting Apple linker via: /tmp/cc.sh -Wl,-v
linker stdout:
linker stderr:
241.9
configured to support archs: armv4t armv5 armv6 armv7 armv7f armv7k armv7s armv6m armv7m armv7em armv8 arm64 arm64v8 i386 x86_64 x86_64h
Library search paths:
/opt/MacOSX10.8.sdk/usr/lib
/opt/MacOSX10.8.sdk/usr/local/lib
Framework search paths:
/opt/MacOSX10.8.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
../meson.build:25:0: ERROR: Unable to detect linker for compiler `/tmp/cc.sh -Wl,--version`
stdout:
stderr: ld: unknown option: --version
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The cross-build file is like this:
[binaries]
c = '/tmp/cc.sh'
cpp = '/tmp/cc.sh'
ld = 'x86_64-apple-darwin9-ld'
ar = 'x86_64-apple-darwin9-ar'
ranlib = 'x86_64-apple-darwin9-ranlib'
strip = 'x86_64-apple-darwin9-strip'
[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
The x86_64-apple-darwin9-XXX
tools are built from cctools-port project.
And, cc.sh
is simply a wrapper around clang
:
#!/bin/sh
exec clang -target x86_64-apple-darwin9 -arch x86_64 -mlinker-version=341.9 -isysroot /opt/MacOSX10.8.sdk -B /opt/cctools-port/bin -mmacosx-version-min=10.6 "$@"
Is there a way around this?
Thanks.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 18 (8 by maintainers)
I just updated my system to macOS 14.1 with the latest CLT/Xcode 15 and meson (1.0.2) can no longer be used with it.
The linker is:
Was this problem addressed in the latest release?
Thanks for the conclusion. Happy it worked for you.
You can also see that I get the same error from version 609 of the linker (as I shown you above), which was released on March 2021: https://github.com/apple-opensource/ld64/tags
The point of my comment is that old or new Apple ld is failing for me, and if I’m at fault somehow I’d like to be shown how.