Opened 5 years ago

Last modified 2 years ago

#58895 reopened defect

gcc9: search path for standard libraries is incomplete/incorrect

Reported by: prbuen Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: rhaas80 (Roland Haas), cooljeanius (Eric Gallager), Serge3leo (Serguei E. Leontiev)
Port: gcc9

Description

Compilation fails due to ld: library not found for -lSystem

Non-native variant compiles fine. Is this because I try to build without XCode?

Thanks!

Attachments (1)

openblas.main.log (3.0 MB) - added by prbuen 5 years ago.
main.log

Change History (39)

Changed 5 years ago by prbuen

Attachment: openblas.main.log added

main.log

comment:1 Changed 5 years ago by mf2k (Frank Schima)

Cc: michaelld added
Owner: set to NicosPavlov
Port: @0.3.7 +native removed
Status: newassigned

comment:2 Changed 5 years ago by prbuen

It seems the linker flag -L/usr/lib is simply missing. It should be added to Makefile.conf, but I am not sure how Makefile.conf is generated from the Portfile. Instead, what I did is symlinking /usr/lib/libSystem.dylib and /usr/lib/libm.dylib in the folder /opt/local/lib/ => makes the compilation succeed.

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

clang knows where to find the system libraries, but it appears your gfortran doesn't know where to look for them when linking:

:info:build /opt/local/bin/gfortran-mp-9 -O3 -m128bit-long-double -Wall -frecursive -fno-optimize-sibling-calls -m64  -mavx2  -o sblat1 sblat1.o ../libopenblas-r1.a -lpthread -lgfortran -lpthread -lgfortran 
:info:build ld: library not found for -lSystem

That's kinda weird, really. But ld needs to know or be passed the location of the system libraries for the link to succeed.

comment:4 Changed 5 years ago by NicosPavlov

In principle, the native variant only removes the possibility of downloading pre-compiled packages to ensure that the build uses the native configuration. Non-native variant probably works because you are then downloading a package and not actually compiling it, which means that the choice of compiler is not applied.

Just for reference, are you actually running the command below ?

sudo port install openblas +native configure.compiler=macports-clang-5.0

I tested it and could not reproduce your problem. It is indeed weird that it cannot find system libraries.

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

Perhaps gfortran was a prebuilt binary from the buildbot, built against a system with xcode installed, and on your system without xcode the system libraries are in a different place?

comment:6 Changed 5 years ago by prbuen

Thanks. I was naively just running

sudo port install openblas +native

without specifying clang-5.0 explicitly (though macports installed it).

Upon closer inspection, it looks as though the compilation is failing during the compilation of tests, since it occurs after:

:info:build make[1]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.7/test'

Maybe these tests are not run for the non-native version?

By the way, I had the same problem trying to install openblas-devel (which has +native by default).

To test your suggestion, I removed my symlinks, uninstalled and cleaned openblas, and reinstalled it with your suggested command

sudo port install openblas +native configure.compiler=macports-clang-5.0

but it failed just the same (same reason, same location)

I have just set up macports newly, and have never installed xcode - only the command-line tools. Not sure why ld doesn't get the system flags?

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

I think you need to check out gfortran here and see where it is going wrong. Try to compile a very simple fortran program, hello.f:

       program hello
          print *, "Hello World!"
       end program hello

be careful, fortan for me was a bit touchy. There are tabs at the start of each line, or it doesn't compile. I know nothing about fortran coding, but I do know compilers now.

Then compile it with:

/opt/local/bin/gfortran-mp-9 -v -o hello hello.f

and try to run it if it compiles

./hello

I get this, with lots of debug info, on 10.6.8 with gcc8:

$ /opt/local/bin/gfortran-mp-8 -v -o hello hello.f
Driving: /opt/local/bin/gfortran-mp-8 -v -o hello hello.f -mmacosx-version-min=10.6.0 -asm_macosx_version_min=10.6 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gfortran-mp-8
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin10/8.3.0/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc8/gcc8/work/gcc-8.3.0/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --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'
Thread model: posix
gcc version 8.3.0 (MacPorts gcc8 8.3.0_4) 
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.6.0' '-asm_macosx_version_min=10.6' '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin10/8.3.0/f951 hello.f -ffixed-form -fPIC -quiet -dumpbase hello.f -mmacosx-version-min=10.6.0 -mtune=core2 -auxbase hello -version -fintrinsic-modules-path /opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/finclude -o /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//ccsx2s89.s
GNU Fortran (MacPorts gcc8 8.3.0_4) version 8.3.0 (x86_64-apple-darwin10)
	compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc8 8.3.0_4) version 8.3.0 (x86_64-apple-darwin10)
	compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.6.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/bin/as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=10.6 -o /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//cc9e8og5.o /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//ccsx2s89.s
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-8.0/bin
 "/opt/local/libexec/llvm-8.0/bin/clang" -cc1as -triple x86_64-apple-macosx10.6.0 -filetype obj -main-file-name ccsx2s89.s -target-cpu core2 -fdebug-compilation-dir /Users/cunningh -dwarf-debug-producer clang version 8.0.0 (tags/RELEASE_800/final) -dwarf-version=2 -mrelocation-model pic -o /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//cc9e8og5.o /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//ccsx2s89.s
Reading specs from /opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.6.0'  '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin10/8.3.0/:/opt/local/libexec/gcc/x86_64-apple-darwin10/8.3.0/:/opt/local/libexec/gcc/x86_64-apple-darwin10/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/
LIBRARY_PATH=/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.6.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin10/8.3.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o hello -lcrt1.10.6.o -L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0 -L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/../../.. /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//cc9e8og5.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 8.3.0
/opt/local/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.6.0 -weak_reference_mismatches non-weak -o hello -lcrt1.10.6.o -L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0 -L/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0/../../.. /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//cc9e8og5.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-274.2
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
Library search paths:
	/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0
	/opt/local/lib/gcc8
	/usr/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
 /opt/local/bin/nm -n /var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-//cc9e8og5.o

And from this, you should see where gfortan is going wrong.

For now, I'm sticking with my "buildbot builds it differently than your system" theory, but paste back your errors.

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

btw, you want to focus on your system on this part:

Library search paths:
	/opt/local/lib/gcc8/gcc/x86_64-apple-darwin10/8.3.0
	/opt/local/lib/gcc8
	/usr/lib

comment:9 Changed 5 years ago by prbuen

Thanks Ken, you got it right: somehow the Library search paths aren't setup properly on my gfortran. Compiling hello above gives me (gcc9 rather than gcc8):

# gfortran-mp-9 -v -o test test.f 
Driving: gfortran-mp-9 -v -o test test.f -mmacosx-version-min=10.14.0 -asm_macosx_version_min=10.14 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran-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_0' --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_0) 
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/f951 test.f -ffixed-form -fPIC -quiet -dumpbase test.f -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase test -version -fintrinsic-modules-path /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/finclude -o /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//cc1QUpH1.s
GNU Fortran (MacPorts gcc9 9.2.0_0) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc9 9.2.0_0) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/bin/as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=10.14 -o /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//ccKMt2QZ.o /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//cc1QUpH1.s
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
 "/opt/local/libexec/llvm-5.0/bin/clang" -cc1as -triple x86_64-apple-macosx10.14.0 -filetype obj -main-file-name cc1QUpH1.s -target-cpu penryn -fdebug-compilation-dir /Users/pbuenzli/packages/programmation/openblas -dwarf-debug-producer clang version 5.0.2 (tags/RELEASE_502/final) -dwarf-version=4 -mrelocation-model pic -o /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//ccKMt2QZ.o /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//cc1QUpH1.s
Reading specs from /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/
LIBRARY_PATH=/usr/lib/:/usr/local/lib/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'test' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/collect2 -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 test -L/usr/local/lib -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/../../.. /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//ccKMt2QZ.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
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 test -L/usr/local/lib -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/../../.. /var/folders/g6/sbw_4b913pvbfm82xb95jwdh0000gn/T//ccKMt2QZ.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-274.2
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
Library search paths:
	/usr/local/lib
	/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:10 Changed 5 years ago by prbuen

Could this be due to having installed gcc9 rather than gcc8? Is there a way to fix these Library search paths?

Of course, I happen to have exactly the same problem compiling a C hello world program: it fails unless I specify -L/usr/lib -I/usr/include on the command line of gcc-mp-9

Sorry to have bother you with this - should really be another ticket I guess.

Thanks again for your help!

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

on your system it should be gcc9, not gcc8, so that part is OK.

We have to sort out why you don't have /usr/lib in your automatic library search paths, like I do...

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

As a thought, please try installing a different ld64 variant and see if that works for you. This should do it:

sudo port -v -f uninstall ld64
sudo port -v -N install ld64 +ld64_xcode

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

for comparison, here is my test build of hello.f using gcc9 on my 10.14 system (with Xcode installed) and it works fine. I have ld64 +ld64_xcode for my ld.

$ /opt/local/bin/gfortran-mp-9 -v -o hello hello.f
Driving: /opt/local/bin/gfortran-mp-9 -v -o hello hello.f -mmacosx-version-min=10.14.0 -asm_macosx_version_min=10.14 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gfortran-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_0' --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_0) 
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/f951 hello.f -ffixed-form -fPIC -quiet -dumpbase hello.f -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase hello -version -fintrinsic-modules-path /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/finclude -o /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//ccGXS4iK.s
GNU Fortran (MacPorts gcc9 9.2.0_0) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (MacPorts gcc9 9.2.0_0) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/bin/as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=10.14 -o /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//cczWZxaG.o /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//ccGXS4iK.s
clang version 9.0.0 (trunk 365158)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-devel/bin
 "/opt/local/libexec/llvm-devel/bin/clang" -cc1as -triple x86_64-apple-macosx10.14.0 -filetype obj -main-file-name ccGXS4iK.s -target-cpu penryn -fdebug-compilation-dir /Users/cunningh -dwarf-debug-producer "clang version 9.0.0 (trunk 365158)" -dwarf-version=4 -mrelocation-model pic -o /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//cczWZxaG.o /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//ccGXS4iK.s
Reading specs from /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/
LIBRARY_PATH=/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-mmacosx-version-min=10.14.0'  '-shared-libgcc' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/collect2 -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 hello -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/../../.. /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//cczWZxaG.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
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 hello -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/../../.. /var/folders/hp/684rvltd0c127nmt0bh3bpzm0000gn/T//cczWZxaG.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-450.3
BUILD 18:16:53 Apr  5 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
	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
	/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/

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

Cc: michaelld removed
Owner: NicosPavlov deleted
Port: gcc9 added; OpenBLAS removed
Summary: OpenBLAS @0.3.7 +native build failure: ld: library not found for -lSystemgcc9: search path for standard libraries is incomplete/incorrect

comment:15 Changed 5 years ago by prbuen

Thanks for the suggestion. I tried with the ld64_xcode variant of ld64, but that didn't help. I also tried to uninstall, clean, and reinstall gcc9 and clang-5.0 but that also didn't make any difference: my library search paths remain

Library search paths:
	/usr/local/lib
	/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

I am not sure how /usr/local/lib got in there, in fact (I like that it's there, but it looks like this would be something I would have setup?). Where does macport get these search paths from?

comment:16 Changed 5 years ago by prbuen

My bash profile exports LD_LIBRARY_PATH and LIBRARY_PATH to /usr/lib:/usr/local/lib. I also tried to set up DYLD_LIBRARY_PATH to /usr/lib, and LDFLAG to -L/usr/lib but none of these seem to affect how gcc-mp-9 calls the linker.

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

you might get a little moe info if you add -Wl,"-v" to your hello.f build line.

try deactivating ld64 and doing your hello.f build.

have you tried building gcc9 fro source on your system?

sudo port uninstall gcc9
sudo port -v -s install gcc9

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

install xcode?

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

remove those exports from your profile?

comment:20 Changed 5 years ago by prbuen

Interestingly, if I split the compilation and the linking, i.e.

/opt/local/bin/gcc-mp-9 -v -c -I/usr/include hello.c

then

/opt/local/bin/ld -v hello.o -lSystem

then my library search paths are ok:

@(#)PROGRAM:ld  PROJECT:ld64-450.3
BUILD 18:16:53 Apr  5 2019
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
ld: warning: No version-min specified on command line
Last edited 5 years ago by prbuen (previous) (diff)

comment:21 Changed 5 years ago by prbuen

Yeah I am a bit reluctant to install XCode just because of a flag issue...

comment:22 Changed 5 years ago by prbuen

Well the library search paths are ok in the sense that they seem to take the values from LIBRARY_PATH or LD_LIBRARY_PATH, but they no longer include the macports paths /opt/local/lib... If I let gcc-mp-9 organise the linking, then the /opt/local/lib paths are there but not /usr/lib...

comment:23 Changed 5 years ago by prbuen

Building gcc9 from source worked!

sudo port -v -s install gcc9

It took a very long time (just under 1h30) but at least now the library search path and the include search path are well set up. I guess the configure scripts were able to tweak the installation properly. Many thanks for the suggestion!

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

that was my first theory--that the buildbot with xcode would build gcc9 differently than your system without it, perhaps. Let's see if it's only you that sees this.

At least you're on your way w OpenBLAS now.

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

I'm not sure, but perhaps recent changes <https://lists.macports.org/pipermail/macports-dev/2019-August/040965.html> will make this issue go away...

comment:26 Changed 5 years ago by prbuen

I see - I wasn't sure what you were referring to with the buildbot, sorry, I am newish to macports :)

OpenBLAS was compiling ok already after adding symlinks to libSystem.dylib and libm.dylib at /opt/local/lib so I wasn't too concerned about that - however, who knows which other package wouldn't install properly either. I can confirm that these symlinks are no longer necessary for OpenBLAS to install out of the box.

Thanks for the link above. For all the ports I installed, XCode has only been a hard requirement for ports that include some Apple-looking GUI, such as the AquaTerm of gnuplot, pallet, etc, which makes sense. My use case of macports is more to install unix-like tools, so I am happy not to install XCode (disk space is cheap, but it still fills quickly on my middle-aged laptop).

Thanks again for helping me through this issue.

comment:27 Changed 5 years ago by rhaas80 (Roland Haas)

Cc: rhaas80 added

comment:28 Changed 5 years ago by tesch1 (Michael Tesch)

I've just had the same problem with plain gcc9. Recompiling gcc9 with the above (onerous) suggestion also fixed the issue for me.

uname -a
Darwin x.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

And now I have:

$ gcc tmp.c  -v
Using built-in specs.
COLLECT_GCC=gcc
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_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_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=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 9.2.0 (MacPorts gcc9 9.2.0_1) 
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.14.0' '-asm_macosx_version_min=10.14' '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/cc1 -quiet -v -D__DYNAMIC__ tmp.c -fPIC -quiet -dumpbase tmp.c -mmacosx-version-min=10.14.0 -mtune=core2 -auxbase tmp -version -o /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccBfmQWr.s
GNU C17 (MacPorts gcc9 9.2.0_1) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/opt/local/include"
ignoring nonexistent directory "/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../../../x86_64-apple-darwin18/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/include
 /opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/include-fixed
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks
End of search list.
GNU C17 (MacPorts gcc9 9.2.0_1) version 9.2.0 (x86_64-apple-darwin18)
	compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 48d9ff446d0fbf05163bfaf9ac8ba459
tmp.c:1:1: warning: return type defaults to 'int' [-Wimplicit-int]
    1 | main(){ return 1; }
      | ^~~~
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.14.0'  '-mtune=core2'
 /opt/local/bin/as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=10.14 -o /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccIp7jxi.o /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccBfmQWr.s
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-8.0/bin
 "/opt/local/libexec/llvm-8.0/bin/clang" -cc1as -triple x86_64-apple-macosx10.14.0 -filetype obj -main-file-name ccBfmQWr.s -target-cpu penryn -fdebug-compilation-dir /Users/michaeltesch/src/turbobadger -dwarf-debug-producer clang version 8.0.1 (tags/RELEASE_801/final) -dwarf-version=4 -mrelocation-model pic -o /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccIp7jxi.o /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccBfmQWr.s
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin18/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/
LIBRARY_PATH=/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.14.0'  '-mtune=core2'
 /opt/local/libexec/gcc/x86_64-apple-darwin18/9.2.0/collect2 -syslibroot /Library/Developer/CommandLineTools/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/../../.. /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccIp7jxi.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 9.2.0
/opt/local/bin/ld -syslibroot /Library/Developer/CommandLineTools/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/../../.. /var/folders/vm/vg3cc4zj117639xwt_zdq4r40000gn/T//ccIp7jxi.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-512.4
BUILD 05:06:53 Aug 16 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
	/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib
Framework search paths:
	/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/

which notably does not include /usr/lib .

comment:29 Changed 4 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:30 Changed 4 years ago by rhaas80 (Roland Haas)

The issue seems to have been resolved when installing on a fresh macOS Catalina (19.0.0) system using macports 2.6.2 from 2019-11-11.

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

Resolution: fixed
Status: assignedclosed

this issue appears fixed; please reopen with new information if not

comment:32 Changed 2 years ago by Serge3leo (Serguei E. Leontiev)

When installing gcc9 from precompiled package "gcc9-9.4.0_1.darwin_19.x86_64.bz2 from https://packages.macports.org/gcc9" error "ld: library not found for -lSystem" persists on some systems.

Installing gcc9 with the build "sudo port -vs install gcc9" is not affected by this error, but is not used by default.

Xcode Version 12.4 (12D4e) (macOS Catalina 10.15.7) don't have /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

Command Line Tools for Xcode 12.4 have /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

Since, according to the documentation, MacPorts depends on "Xcode Command Line Tools", it is probably better that the precompiled package "gcc9-*.bz2" would refer to /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

Workarounds:

sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/.

or

sudo port install MacOSX10.15.sdk
sudo ln -s /opt/local/Developer/SDKs/MacOSX10.15.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/.
Last edited 2 years ago by Serge3leo (Serguei E. Leontiev) (previous) (diff)

comment:33 Changed 2 years ago by Serge3leo (Serguei E. Leontiev)

Cc: Serge3leo added

comment:34 Changed 2 years ago by Serge3leo (Serguei E. Leontiev)

Resolution: fixed
Status: closedreopened

Replying to kencu, ticket 65055:

So the gcc10 log shows it is looking here:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

...

https://github.com/macports/macports-ports/commit/e8866c5019d60832527850b4e50fdc1de8878716

...

I wonder what is wrong with this plan?

IMHO, for a strict reference to the use of Mac OSX 10.15 SDK, you should:

depends_run …\
…
	port:MacOSX10.15.sdk
…
configure.args-append --with-sysroot="${prefix}/Developer/SDKs/MacOSX10.15.sdk”
Last edited 2 years ago by Serge3leo (Serguei E. Leontiev) (previous) (diff)

comment:35 Changed 2 years ago by Serge3leo (Serguei E. Leontiev)

Sorry, I can't add to this defect ports: gcc6, gcc7, gcc8, gcc10

comment:36 Changed 2 years ago by kencu (Ken)

I don't see any gcc ports with this defect at present.

We do not want every gcc port to depend on MacOSX10.15.sdk, certainly. The would be appropriate only for one os version.

comment:37 in reply to:  36 Changed 2 years ago by Serge3leo (Serguei E. Leontiev)

Replying to kencu:

I don't see any gcc ports with this defect at present.

For example:

gcc10-10.3.0_1.darwin_19.x86_64.tbz2:/opt/local/lib/gcc10/gcc/x86_64-apple-darwin19/10.3.0/plugin/include/configargs.h

--with-pkgversion='MacPorts gcc10 10.3.0_1' --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk";

gcc9-9.4.0_1.darwin_19.x86_64.tbz2:/opt/local/lib/gcc9/gcc/x86_64-apple-darwin19/9.4.0/plugin/include/configargs.h

--with-pkgversion='MacPorts gcc9 9.4.0_1' --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk";

gcc8-8.5.0_1.darwin_19.x86_64.tbz2:/opt/local/lib/gcc8/gcc/x86_64-apple-darwin19/8.5.0/plugin/include/configargs.h

--with-pkgversion='MacPorts gcc8 8.5.0_1' --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk";

...

For darwin_19 (macOS Catalina 10.15), which path to the SDK will be correct?

  • /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
  • /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk

For source build package - all right. "configure" correct detect SDK root.

But for precompiled packages, we need the root SDK location on the build machine and on the user's machine to match.

We do not want every gcc port to depend on MacOSX10.15.sdk, certainly. The would be appropriate only for one os version.

We can use "macosx_deployment_target" to choose between port dependencies: MacOSX10.6.sdk ... MacOSX10.15.sdk

Last edited 2 years ago by Serge3leo (Serguei E. Leontiev) (previous) (diff)

comment:38 Changed 2 years ago by kencu (Ken)

there are two different problems you are having, neither of which I’m having or most (but not all) are having. So MacPorts does not need fixing, probably — your installation, possibly heavily modified it seems, needs fixing.

So let’s only talk about one per ticket.

  1. the versioned sdk seems to have somehow crept back into some buildbot builds, I think. Dunno for sure yet if this is true, but the solution to that is to make sure the unversioned sdk is being used, and IF the buildbot build does not use the unversioned sdk, revbump it. Done.
  1. you, and only you I believe, have messed up all the libgcc9, at least, symlinks. Or you don’t have libgcc and libgcc11 installed, or somehow you’ve messed up the system. The probable fix for THAT is going to be to have you uninstall MacPorts, clean out /opt/local until it is bare, and start over without touching any of libgcc* or the symlinks.

So I suggest we talk only about problem 2 in this ticket, to keep it straight.

Last edited 2 years ago by kencu (Ken) (previous) (diff)
Note: See TracTickets for help on using tickets.