Opened 5 years ago
Closed 3 years ago
#59727 closed defect (fixed)
gcc9: fails to link properly (-lSystem no found)
Reported by: | akimd (Akim Demaille) | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.6.2 |
Keywords: | Cc: | cooljeanius (Eric Gallager) | |
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 (13)
comment:1 Changed 5 years ago by kencu (Ken)
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) |
---|
comment:5 follow-up: 6 Changed 5 years ago by kencu (Ken)
I think you'll probably have to rebuild gcc8 and gcc9 on your system from source to get the proper SDK baked into gcc.
It looks like you're building into a prefix that is not /opt/local
, so you're building yourself. I see _opt_bblocal
, so I presume you have it prefixing into /opt/bblocal
.
So uninstall gcc8 and gcc9 (and perhaps all the libgccN versions as well, ugh). And then reinstall gcc9, and it should pick up your proper CLT SDK and then all will (hopefully) be well for you.
BTW, life is 1000% easier if you use /opt/local
and then the buildbot prebuilt binaries, but that is up to you.
comment:6 Changed 5 years ago by akimd (Akim Demaille)
Hi Ken,
Replying to kencu:
I think you'll probably have to rebuild gcc8 and gcc9 on your system from source to get the proper SDK baked into gcc.
I had uninstalled and reinstalled.
It looks like you're building into a prefix that is not
/opt/local
, so you're building yourself. I see_opt_bblocal
, so I presume you have it prefixing into/opt/bblocal
.
I certainly did not. And I would like to point out that 'bb' sounds awfully like "Buildbot".
So uninstall gcc8 and gcc9 (and perhaps all the libgccN versions as well, ugh). And then reinstall gcc9, and it should pick up your proper CLT SDK and then all will (hopefully) be well for you.
BTW, life is 1000% easier if you use
/opt/local
and then the buildbot prebuilt binaries, but that is up to you.
Which is what I do.
I'm (sort of) offline right now, so I will try again at home, but be sure I did nothing specific. And I _do_ remember that GCC9 was pulled prebuilt, it was not compiled on my machine. And I _think_ GCC7 was compiled locally. So I would suggest having a close look at what MacPorts' buildbot does.
Cheers!
comment:7 follow-up: 8 Changed 5 years ago by kencu (Ken)
maybe the gcc8 and gcc9 ports off the buildbot are broken still, and looking into Xcode instead of looking into the CLTs.
What I would do is build them locally from source, like this:
sudo port uninstall gcc8 gcc9 sudo port -v -s install gcc9
and do you really need three different gccs? anyway, if you do,
sudo port -v -s install gcc8
and hopefully that should get you in business, with proper link libraries.
comment:8 Changed 5 years ago by akimd (Akim Demaille)
Hi Ken,
Replying to kencu:
What I would do is build them locally from source, like this:
sudo port uninstall gcc8 gcc9 sudo port -v -s install gcc9
That worked, GCC9 is functional.
and do you really need three different gccs?
I maintain Bison, and I need to make sure with as many compilers as I can that the generated code works properly and triggers no warnings.
Cheers!
comment:9 Changed 5 years ago by cooljeanius (Eric Gallager)
Cc: | cooljeanius added |
---|
comment:10 Changed 5 years ago by jasret
Could someone please fix this problem? I ran into this issue several weeks ago and tried everything including several Xcode reloads and complete MacPorts reinstalls. I finally stumbled across this ticket and found that I needed to build gcc8 on my own system. Two hours of CPU churning later I'm finally whole again.
comment:11 Changed 5 years ago by kencu (Ken)
I see the bullbot version of gcc8 is from May, so it might still be broken. The gcc9 version is from October, probably is fixed.
Can you help us out and tell us was your issue with gcc8 or gcc9?
All that is needed is a rev-bump, but it's long, slow, tedious install unless needed, otherwise we would just revbump them all and be done with this.
comment:12 Changed 5 years ago by jxy (Xiao-Yong)
I had to rebuild gcc9 from source to get it work too. With the pre-built package I have
Library search paths: /opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.2.0 /opt/local/lib/gcc9 Framework search paths: ld: library not found for -lSystem collect2: error: ld returned 1 exit status
after rebuild from source I have
Library search paths: /opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.2.0 /opt/local/lib/gcc9 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib Framework search paths: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
comment:13 Changed 3 years ago by kencu (Ken)
Resolution: | → fixed |
---|---|
Status: | new → closed |
I believe this has been fixed now by changes in base and the noted ports to spec an existing SDK.
please reopen with new information if you find this is still and issue.
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: