Opened 14 months ago

Last modified 11 months ago

#58895 assigned 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)
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 14 months ago.
main.log

Change History (31)

Changed 14 months ago by prbuen

Attachment: openblas.main.log added

main.log

comment:1 Changed 14 months ago by mf2k (Frank Schima)

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

comment:2 Changed 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 14 months ago by kencu (Ken)

install xcode?

comment:19 Changed 14 months ago by kencu (Ken)

remove those exports from your profile?

comment:20 Changed 14 months 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 14 months ago by prbuen (previous) (diff)

comment:21 Changed 14 months ago by prbuen

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

comment:22 Changed 14 months 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 14 months 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 14 months 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 14 months 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 14 months 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 13 months ago by rhaas80 (Roland Haas)

Cc: rhaas80 added

comment:28 Changed 12 months 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 12 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:30 Changed 11 months 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.

Note: See TracTickets for help on using tickets.