iains / gcc-13-branch

GCC 13 for Darwin with experimental Arm64 support. Current release 13.3-darwin-r0 [May 2024]
GNU General Public License v2.0
10 stars 1 forks source link

Xcode 15 compatibility (ignoring duplicate libraries) #11

Closed fxcoudert closed 4 months ago

fxcoudert commented 10 months ago

With this branch and Xcode 15, I'm hitting this in testing:

ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'

for all gfortran linking. I know you fixed it on trunk Iain, but I can't find the specific commit. Do you remember where you fixed it? I'd like to backport that to 13…

iains commented 10 months ago

With this branch and Xcode 15, I'm hitting this in testing:

ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'

for all gfortran linking. I know you fixed it on trunk Iain, but I can't find the specific commit. Do you remember where you fixed it? I'd like to backport that to 13…

Actually, I recall the issue, but I cannot point to the exact commit either (it's always possible it was something Rainer fixed) - please could you put an example link-line here; that might help jog my memory.

fxcoudert commented 10 months ago
meau ~/devel/gcc/build_package $ cat a.f90 
  end
meau ~/devel/gcc/build_package $ ./package/usr/local/gfortran/bin/gfortran a.f90 
ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'
iains commented 10 months ago
meau ~/devel/gcc/build_package $ cat a.f90 
  end
meau ~/devel/gcc/build_package $ ./package/usr/local/gfortran/bin/gfortran a.f90 
ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'

ah, sorry, I was not being specific enough; the actual link line (or the output of that command with -v)

fxcoudert commented 10 months ago
Driving: ./package/usr/local/gfortran/bin/gfortran -v a.f90 -mmacosx-version-min=14.0.0 -asm_macosx_version_min=14.0 -nodefaultexport -l gfortran
Using built-in specs.
COLLECT_GCC=./package/usr/local/gfortran/bin/gfortran
COLLECT_LTO_WRAPPER=/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../libexec/gcc/aarch64-apple-darwin23/13.2.0/lto-wrapper
Target: aarch64-apple-darwin23
Configured with: ../gcc-13-branch/configure --prefix=/usr/local/gfortran --with-gmp=/Users/fx/devel/gcc/build_package/deps --enable-languages=c,c++,fortran,jit,lto,objc,obj-c++ --build=aarch64-apple-darwin23 --with-system-zlib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=14.0.0' '-asm_macosx_version_min=14.0' '-nodefaultexport' '-mlittle-endian' '-mabi=lp64'
 /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../libexec/gcc/aarch64-apple-darwin23/13.2.0/f951 a.f90 -fPIC -quiet -dumpbase a.f90 -dumpbase-ext .f90 -mmacosx-version-min=14.0.0 -mlittle-endian -mabi=lp64 -version -fintrinsic-modules-path /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0/finclude -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccIYSXKe.s
GNU Fortran (GCC) version 13.2.0 (aarch64-apple-darwin23)
    compiled by GNU C version 13.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=14.0.0'  '-nodefaultexport' '-mlittle-endian' '-mabi=lp64'
 as -arch arm64 -v -mmacosx-version-min=14.0 -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccbi8Zfj.o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccIYSXKe.s
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple arm64-apple-macosx14.0.0 -filetype obj -main-file-name ccIYSXKe.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +lse -target-feature +rdm -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +neon -target-feature +fp16fml -target-feature +ras -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/fx/devel/gcc/build_package -dwarf-debug-producer "Apple clang version 15.0.0 (clang-1500.1.0.2.5)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccbi8Zfj.o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccIYSXKe.s
Reading specs from /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=14.0.0'  '-nodefaultexport' '-mlittle-endian' '-mabi=lp64'
COMPILER_PATH=/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../libexec/gcc/aarch64-apple-darwin23/13.2.0/:/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../libexec/gcc/
LIBRARY_PATH=/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0/:/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/:/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=14.0.0'  '-nodefaultexport' '-mlittle-endian' '-mabi=lp64' '-dumpdir' 'a.'
 /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../libexec/gcc/aarch64-apple-darwin23/13.2.0/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ -dynamic -arch arm64 -platform_version macos 14.0.0 0.0 -o a.out -L/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0 -L/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc -L/Users/fx/devel/gcc/build_package/package/usr/local/gfortran/bin/../lib/gcc/aarch64-apple-darwin23/13.2.0/../../.. /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccbi8Zfj.o -lgfortran -lemutls_w -lgcc -lquadmath -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/lib/gcc/aarch64-apple-darwin23/13.2.0 -rpath /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/lib/gcc -rpath /Users/fx/devel/gcc/build_package/package/usr/local/gfortran/lib
ld: warning: ignoring duplicate libraries: '-lemutls_w', '-lgcc'
iains commented 10 months ago

also, is this only on aarch64? in which case I've been looking in the wrong place ;)

fxcoudert commented 10 months ago

Cannot say, I don't have a machine with Intel and Xcode 15. My Intel box is old and won't support recent macOS :(

iains commented 10 months ago

I've already fixed it on my 13 branch ... but I need to re-test before pushing.

the fix is to remove:

-/* Hack alert - we want the exported cas etc.  */
-#undef LIB_SPEC
-#define LIB_SPEC "%{!static:-lSystem} -lgcc"

from gcc/config/aarch64/darwin.h

sorry that's not a proper patch (our efforts to make the branch ready to post squashed some of the smaller patches into the main ones). I could probably find a real patch in save older branches - but it's a trivial fix.

fxcoudert commented 10 months ago

That patch wasn't enough. It appears I also need:

diff --git a/libgfortran/libgfortran.spec.in b/libgfortran/libgfortran.spec.in
index 367d485c230..058ee5775bf 100644
--- a/libgfortran/libgfortran.spec.in
+++ b/libgfortran/libgfortran.spec.in
@@ -5,4 +5,4 @@
 #

 %rename lib liborig
-*lib: @LIBQUADSPEC@ @LIBM@ %(libgcc) %(liborig)
+*lib: @LIBQUADSPEC@ @LIBM@ %(liborig)

as per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110651#add_comment

iains commented 10 months ago

indeed, and I suppose we are no closer to understanding why it was in that spec in the first place (we're all busy, of course).

fxcoudert commented 10 months ago

I was the one who authored that commit, 13 years ago, but I don't have any memory of that. I am going to propose removing it, because I don't see what positive effect it could have.

Patch posted upstream at https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640943.html

iains commented 4 months ago

(as far as I know we've addressed all the instances of this in the testsuite) fixed in 13.3-darwin-r0