Opened 5 years ago

Last modified 3 years ago

#59727 closed defect

gcc9: fails to link properly (-lSystem no found) — at Version 4

Reported by: akimd (Akim Demaille) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc:
Port: gcc8 gcc9

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Hi,

It feels wrong to report this: I saw no-one reporting it, yet I have had the problem for about one week, starting when I upgraded to Xcode 11.2.1 on my macOS 10.14.6, and found no ticket about it... I guess I did not look at the right place.

$ cat foo.c
int main () {
  return 42;
}
$ gcc-mp-7 foo.c
$ ./a.out ; echo $?
42
$ gcc-mp-8 foo.c
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
$ gcc-mp-9 foo.c
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

FWIW, gcc7 used to fail too, but since I rerun xcode-select --install it works. I uninstalled gcc9 and reinstall it, to no avail.

I don't know what information might help you.

$ gcc-mp-7 -v
Using built-in specs.
COLLECT_GCC=gcc-mp-7
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin18/7.5.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc7/gcc7/work/gcc-7.5.0/configure --prefix=/opt/local --build=x86_64-apple-darwin18 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc7 --includedir=/opt/local/include/gcc7 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-7 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-7 --with-gxx-include-dir=/opt/local/include/gcc7/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc7 7.5.0_0' --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 7.5.0 (MacPorts gcc7 7.5.0_0) 
$ gcc-mp-8 -v
Using built-in specs.
COLLECT_GCC=gcc-mp-8
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin18/8.3.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc8/gcc8/work/gcc-8.3.0/configure --prefix=/opt/local --build=x86_64-apple-darwin18 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc8 --includedir=/opt/local/include/gcc8 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-8 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-8 --with-gxx-include-dir=/opt/local/include/gcc8/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc8 8.3.0_4' --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 8.3.0 (MacPorts gcc8 8.3.0_4) 
$ gcc-mp-9 -v
Using built-in specs.
COLLECT_GCC=gcc-mp-9
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc9/gcc9/work/gcc-9.2.0/configure --prefix=/opt/local --build=x86_64-apple-darwin18 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc9 --includedir=/opt/local/include/gcc9 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-9 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-9 --with-gxx-include-dir=/opt/local/include/gcc9/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc9 9.2.0_1' --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 9.2.0 (MacPorts gcc9 9.2.0_1) 

Also, port 2.6.2's diagnose reports that Xcode 11.2 is supported, but not Xcode 11.2.1. But...

Finally, there's no "maintainer" registered in the port. Cheers!

Change History (4)

comment:1 Changed 5 years ago by kencu (Ken)

try building your test program while sending a verbose output request to the linker; I think you'll find the linker is looking somewhere other than where it should be looking for the link libraries.

For example:

gcc-mp-7 -Wl,-v foo.c

comment:2 Changed 5 years ago by akimd (Akim Demaille)

Hi Ken,

Yes, you are right, GCC8 and 9 lack /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib.

$ gcc-mp-7 -Wl,-v foo.c
collect2 version 7.5.0
/opt/local/bin/ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/ -dynamic -arch x86_64 -macosx_version_min 10.14.7 -weak_reference_mismatches non-weak -o a.out -L/opt/local/lib/gcc7/gcc/x86_64-apple-darwin18/7.5.0 -L/opt/local/lib/gcc7/gcc/x86_64-apple-darwin18/7.5.0/../../.. -v /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ccvee4AI.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind
@(#)PROGRAM:ld  PROJECT:ld64-520
BUILD 18:38:01 Oct 11 2019
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
        /opt/local/lib/gcc7/gcc/x86_64-apple-darwin18/7.5.0
        /opt/local/lib/gcc7
        /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
        /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/
 /opt/local/bin/nm -n /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//ccvee4AI.o
$ gcc-mp-9 -Wl,-v foo.c
collect2 version 9.2.0
/opt/local/bin/ld -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/ -dynamic -arch x86_64 -macosx_version_min 10.14.0 -weak_reference_mismatches non-weak -o a.out -L/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0 -L/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../.. -v /var/folders/5y/lz6sht194vz_k1p88510k3yc0000gs/T//cc2FOO1B.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem
@(#)PROGRAM:ld  PROJECT:ld64-520
BUILD 18:38:01 Oct 11 2019
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
        /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0
        /opt/local/lib/gcc9
Framework search paths:
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status

comment:3 Changed 5 years ago by kencu (Ken)

now we just have to sort out why. We have attempted to fix this before...thought we did...

comment:4 Changed 5 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Note: See TracTickets for help on using tickets.