Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc uses /usr/bin/ld instead of ld64 #803

Open
cebtenzzre opened this issue Apr 21, 2023 · 0 comments
Open

gcc uses /usr/bin/ld instead of ld64 #803

cebtenzzre opened this issue Apr 21, 2023 · 0 comments

Comments

@cebtenzzre
Copy link

cebtenzzre commented Apr 21, 2023

Since version 0.64.0, meson is unable to use the version of gcc installed via tigerbrew. It always calls the linker via the compiler, and uses -Wl,--version and -Wl,-v in order to autodetect the linker type and version so it knows which options are supported.

(Also, meson depends on ninja 1.7 as of 0.54.0 and ninja 1.8.2 as of 0.57.0, but that's a separate issue.)

Unfortunately, gcc is configured to use /usr/bin/ld, and meson does not recognize the output of gcc -Wl,-v. The linker it expects to see on OS X is ld64 (see the code here).

I have these linkers installed on Tiger 10.4.11 PPC with tigerbrew:

$ /usr/bin/ld -v
Apple Computer, Inc. version cctools-622.9~2

$ /usr/bin/ld64 -v
@(#)PROGRAM:ld64  PROJECT:ld64-62.1  DEVELOPER:root  BUILT:Apr 20 2007 01:28:10

$ /usr/local/opt/cctools/bin/ld_classic -v
Apple Computer, Inc. version cctools-806

$ /usr/local/opt/ld64/bin/ld -v
@(#)PROGRAM:ld  PROJECT:ld64-97.17

Actual behavior

The error from meson:

meson.build:1:0: ERROR: Unable to detect linker for compiler `gcc-7 -Wl,--version`
stdout: 
stderr: collect2 version 7.3.0
/usr/bin/ld -dynamic -arch ppc -macosx_version_min 10.4 -weak_reference_mismatches non-weak -o a.out -lcrt1.o -L/usr/local/Cellar/gcc/7.3.0/lib/gcc/7/gcc/powerpc-apple-darwin8.11.0/7.3.0 -L/usr/local/Cellar/gcc/7.3.0/lib/gcc/7/gcc/powerpc-apple-darwin8.11.0/7.3.0/../../.. --version -lgcc_s.10.4 -lgcc_ext.10.4 -lgcc -lSystemStubs -lSystem
/usr/bin/ld: unknown flag: --version
collect2: error: ld returned 1 exit status

The log indicates that it attempted to detect the linker using -Wl,-v:

Detecting Apple linker via: gcc-7 -Wl,-v
linker stdout:
Apple Computer, Inc. version cctools-622.9~2

Running gcc directly gives similar output:

$ /usr/local/bin/gcc-7 -Wl,-v
collect2 version 7.3.0
/usr/bin/ld -dynamic -arch ppc -macosx_version_min 10.4 -weak_reference_mismatches non-weak -o a.out -lcrt1.o -L/usr/local/Cellar/gcc/7.3.0/lib/gcc/7/gcc/powerpc-apple-darwin8.11.0/7.3.0 -L/usr/local/Cellar/gcc/7.3.0/lib/gcc/7/gcc/powerpc-apple-darwin8.11.0/7.3.0/../../.. -v -lgcc_s.10.4 -lgcc_ext.10.4 -lgcc -lSystemStubs -lSystem
Apple Computer, Inc. version cctools-622.9~2/usr/bin/ld: Undefined symbols:
_main
collect2: error: ld returned 1 exit status

Expected behavior

This is the output on Tiger 10.4.8 i386 with MacPorts. It's using ld64 version 97.17:

$ /opt/local/bin/gcc -Wl,-v   
collect2 version 7.5.0
/opt/local/bin/ld -dynamic -arch i386 -macosx_version_min 10.4 -weak_reference_mismatches non-weak -o a.out -lcrt1.o -L/opt/local/lib/gcc7/gcc/i386-apple-darwin8/7.5.0 -L/opt/local/lib/gcc7/gcc/i386-apple-darwin8/7.5.0/../../.. -v -lgcc_s.10.4 -lgcc_ext.10.4 -lgcc -lSystem
@(#)PROGRAM:ld  PROJECT:ld64-97.17
configured to support archs: i386 x86_64 ppc ppc64 armv6 armv7
Library search paths:
	/opt/local/lib/gcc7/gcc/i386-apple-darwin8/7.5.0
	/opt/local/lib/gcc7
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
Undefined symbols:
  "_main", referenced from:
      __start in crt1.o
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant