Skip to content

0_Rootfs: Add GCC 14 #10132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 12, 2025
Merged

0_Rootfs: Add GCC 14 #10132

merged 13 commits into from
Jan 12, 2025

Conversation

eschnett
Copy link
Contributor

@eschnett eschnett commented Dec 26, 2024

@eschnett
Copy link
Contributor Author

I'm looking for comments on these changes. If they look fine I can generate and deploy the artifacts.

@imciner2
Copy link
Member

Have you looked through the patches to see which are already upstream and included in the GCC 14 release? I know for sure that you need to drop the gcc9_vsnprintf-str patch since it is already upstream, and I would suspect also the gcc1220-libgomp-win patch should be dropped.

@eschnett
Copy link
Contributor Author

There is a gazillion patches which don't apply any more. Since most are applied via patch || true that doesn't matter. Should I remove all that are not necessary?

I assume that's only GCC patches you're talking about, not anything related to binutils or glibc?

@imciner2
Copy link
Member

IMO, when adding a new GCC version we should verify all the patches are either being applied or are no longer needed and dropped. Keeping a lot of old patches that don't apply present in the new GCC's directory clutters things up.

@eschnett
Copy link
Contributor Author

This is GCC 14.2. Is that the version we're going to use?

@giordano
Copy link
Member

IMO, when adding a new GCC version we should verify all the patches are either being applied or are no longer needed and dropped.

Agreed, I don't like the patch || true style, it's hard to change it for old versions we should avoid it for new stuff

@eschnett
Copy link
Contributor Author

It's impossible to avoid. There are too many combinations of (GCC, glibc, binutils, architecture), and who knows which patches are necessary for what combination.

So far, the patches are separated by GCC version only. We could separate them by binutils and glibc version as well, but that might not cover all the cases. (For example, the configure flags necessary for glibc 2.17 depend on the GCC version.)

Furthermore, I don't think anyone has tried to re-build an older GCC version in a long time, so I'd assume that's all bit-rotted away.

@eschnett
Copy link
Contributor Author

@giordano
Copy link
Member

Furthermore, I don't think anyone has tried to re-build an older GCC version in a long time, so I'd assume that's all bit-rotted away.

I haven't tried very recently, but the build scripts are surprisingly somewhat robust.

For the benefit of future readers (myself included) what was the problem with JuliaPackaging/BinaryBuilderBase.jl#398 (comment)?

@eschnett
Copy link
Contributor Author

I added this comment to explain:

        # These flags are necessary for GCC 14. GCC 14 defaults to a
        # modern version of C, too modern for the old glibc libraries we are
        # trying to build. Various configure tests would fail otherwise. (Why
        # declare variables or functions if they default to int anyway?)
        GLIBC_CFLAGS="${CFLAGS} -g -O2 -Wno-implicit-int -Wno-implicit-function-declaration -Wno-builtin-declaration-mismatch -Wno-array-parameter"

@giordano
Copy link
Member

I haven't tried very recently, but the build scripts are surprisingly somewhat robust.

JuliaPackaging/BinaryBuilderBase.jl#318 rebuilt gcc 4-12 for *86*-linux-gnu little over one year ago, and since then the only major change was the upgrade to GCC 13. Unless we did something super bad there, the script is supposed to still be working for all those versions.

@imciner2
Copy link
Member

I haven't tried very recently, but the build scripts are surprisingly somewhat robust.

I also rebuilt GCC 11-12 to fix headers and GCC 11-13 for the new Mingw version in January and it worked with no hiccups: #8005

@eschnett
Copy link
Contributor Author

I see this error while building for x86_64-apple-darwin14:

[02:47:00] Assertion failed: targetAtom != NULL (/workspace/srcdir/cctools-port/cctools/ld64/src/ld/ld.hpp: Fixup: 776)
[02:47:00] collect2: fatal error: ld terminated with signal 6 [Aborted], core dumped
[02:47:00] compilation terminated.
[02:47:00] make[1]: *** [Makefile:1005: libgcc_s.dylib] Error 1

What's the likely fix? Update to a newer macOS SDK? Or try a different binutils?

@giordano
Copy link
Member

Cctools more than binutils:

# MacOS doesn't actually use binutils, it uses cctools
binutils_sources = [
GitSource("https://github.com/tpoechtrager/apple-libtapi.git",
"a66284251b46d591ee4a0cb4cf561b92a0c138d8"),
GitSource("https://github.com/tpoechtrager/cctools-port.git",
"634a084377ee2e2932c66459b0396edf76da2e9f"),
]
Maybe it's time to upgrade to a newer version (as we do for binutils), for example https://github.com/tpoechtrager/cctools-port/tree/1010.6-ld64-951.9

@eschnett
Copy link
Contributor Author

Why is there no aarch64-apple-darwin* architecture for GCC?

@giordano
Copy link
Member

For that architecture we build a fork of GCC: https://github.com/iains/gcc-darwin-arm64/. Upstream GCC still doesn't support it, I think.

@eschnett
Copy link
Contributor Author

I'm giving up on building GCC 14 for x86_64-apple-darwin14. I've added my current state to the PR. I cannot figure out how to build the new version of cctools.

@giordano giordano force-pushed the eschnett/GCC-14 branch 2 times, most recently from 0b01778 to a87eaa3 Compare January 3, 2025 18:07

# TODO: Update RootFS to v3.17 or later, and preinstall libdispatch (and libdispatch-dev here only when building for macOS).
if [[ "${GCC_VERSION_MAJOR}" -ge 14 ]]; then
apk add libdispatch libdispatch-dev --repository=http://dl-cdn.alpinelinux.org/alpine/v3.17/community
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, compile https://github.com/tpoechtrager/apple-libdispatch locally

@giordano
Copy link
Member

giordano commented Jan 3, 2025

I saved my progress so far with building gcc 14 for x86_64-darwin, but now I'm stuck at

make all-target-libgcc -j${nproc}

[22:25:57] /bin/sh /workspace/srcdir/gcc-14.2.0/libgcc/../mkinstalldirs .
[22:25:57] /workspace/srcdir/gcc_stage1/./gcc/xgcc -B/workspace/srcdir/gcc_stage1/./gcc/ -B/workspace/destdir/x86_64-apple-darwin14/bin/ -B/workspace/destdir/x86_64-apple-darwin14/lib/ -isystem /workspace/destdir/x86_64-apple-darwin14/include -isystem /workspace/destdir/x86_64-apple-darwin14/sys-include    -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mmacosx-version-min=10.5 -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -dynamiclib -nodefaultlibs -install_name /workspace/destdir/x86_64-apple-darwin14/lib/libgcc_s.1.1.dylib -single_module -o ./libgcc_s.dylib -Wl,-exported_symbols_list,libgcc.map -compatibility_version 1 -current_version 1.1 -nodefaultrpaths -g -O2 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _mulbitint3_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o _divmodbitint4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o fixsfbitint_s.o floatbitintsf_s.o fixdfbitint_s.o floatbitintdf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o fixtfbitint_s.o floatbitinttf_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o floattibf_s.o floatuntibf_s.o eqhf2_s.o fixxfbitint_s.o floatbitinthf_s.o floatbitintbf_s.o floatbitintxf_s.o enable-execute-stack_s.o hardcfr_s.o strub_s.o heap-trampoline_s.o emutls_s.o libgcc.a -lSystem
[22:25:57] Assertion failed: targetAtom != NULL (/workspace/srcdir/cctools-port/cctools/ld64/src/ld/ld.hpp: Fixup: 902)
[22:25:57] collect2: fatal error: ld terminated with signal 6 [Aborted]
[22:25:57] compilation terminated.
[22:25:57] make[1]: *** [Makefile:1005: libgcc_s.dylib] Error 1
[22:25:57] make[1]: *** Waiting for unfinished jobs....
[22:25:58] make[1]: Leaving directory '/workspace/srcdir/gcc_stage1/x86_64-apple-darwin14/libgcc'
[22:25:58] make: *** [Makefile:14143: all-target-libgcc] Error 2

The assertion is https://github.com/tpoechtrager/cctools-port/blob/81f205e8ca6bbf2fdbcb6948132454fd1f97839e/cctools/ld64/src/ld/ld.hpp#L902.

At a quick glance it looks similar to NixOS/nixpkgs#105573, but I have yet to study that bug report and understand how it was resolved. But what's interesting is that NixOS/nixpkgs#105573 (comment) claims they hit the issue on tpoechtrager/cctools-port@43f32a4, which is before tpoechtrager/cctools-port@634a084, the commit we've built so far and we didn't have this problem before.

Any help in debugging this (even in the form of googling or rubber-ducking) would be much appreciated 🙂

@giordano
Copy link
Member

giordano commented Jan 3, 2025

As far as I can tell, all errors mentioned in NixOS/nixpkgs#105573 about the failed assertion are related to -mmacosx-version-min=10.5, which is also the version used in the failed compiler invocation above. That flag was introduced by gcc-mirror/gcc@20b8779, before -mmacosx-version-min=10.4 was used unconditionally. Now I'm wondering if cctools just crashes badly on -mmacosx-version-min=10.5 specifically, that'd be hilarious. I need to investigate this hypothesis.

Edit:

sandbox:${WORKSPACE}/srcdir/gcc_stage1/x86_64-apple-darwin14/libgcc # /workspace/srcdir/gcc_stage1/./gcc/xgcc -B/workspace/srcdir/gcc_stage1/./gcc/ -B/workspace/destdir/x86_64-apple-darwin14/bin/ -B/workspace/destdir/x86_64-apple-darwin14/lib/ -isystem /workspace/destdir/x86_64-apple-darwin14/include -isystem /workspace/destdir/x86_64-apple-darwin14/sys-include    -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mmacosx-version-min=10.5 -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -dynamiclib -nodefaultlibs -install_name /workspace/destdir/x86_64-apple-darwin14/lib/libgcc_s.1.1.dylib -single_module -o ./libgcc_s.dylib -Wl,-exported_symbols_list,libgcc.map -compatibility_version 1 -current_version 1.1 -nodefaultrpaths -g -O2 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _mulbitint3_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o _divmodbitint4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o fixsfbitint_s.o floatbitintsf_s.o fixdfbitint_s.o floatbitintdf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o fixtfbitint_s.o floatbitinttf_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o floattibf_s.o floatuntibf_s.o eqhf2_s.o fixxfbitint_s.o floatbitinthf_s.o floatbitintbf_s.o floatbitintxf_s.o enable-execute-stack_s.o hardcfr_s.o strub_s.o heap-trampoline_s.o emutls_s.o libgcc.a -lSystem
Assertion failed: targetAtom != NULL (/workspace/srcdir/cctools-port/cctools/ld64/src/ld/ld.hpp: Fixup: 902)
collect2: fatal error: ld terminated with signal 6 [Aborted]
compilation terminated.
sandbox:${WORKSPACE}/srcdir/gcc_stage1/x86_64-apple-darwin14/libgcc # /workspace/srcdir/gcc_stage1/./gcc/xgcc -B/workspace/srcdir/gcc_stage1/./gcc/ -B/workspace/destdir/x86_64-apple-darwin14/bin/ -B/workspace/destdir/x86_64-apple-darwin14/lib/ -isystem /workspace/destdir/x86_64-apple-darwin14/include -isystem /workspace/destdir/x86_64-apple-darwin14/sys-include    -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mmacosx-version-min=10.6 -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -dynamiclib -nodefaultlibs -install_name /workspace/destdir/x86_64-apple-darwin14/lib/libgcc_s.1.1.dylib -single_module -o ./libgcc_s.dylib -Wl,-exported_symbols_list,libgcc.map -compatibility_version 1 -current_version 1.1 -nodefaultrpaths -g -O2 -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _mulbitint3_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o _divmodbitint4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o fixsfbitint_s.o floatbitintsf_s.o fixdfbitint_s.o floatbitintdf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o fixtfbitint_s.o floatbitinttf_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o floattibf_s.o floatuntibf_s.o eqhf2_s.o fixxfbitint_s.o floatbitinthf_s.o
floatbitintbf_s.o floatbitintxf_s.o enable-execute-stack_s.o hardcfr_s.o strub_s.o heap-trampoline_s.o emutls_s.o libgcc.a -lSystem
sandbox:${WORKSPACE}/srcdir/gcc_stage1/x86_64-apple-darwin14/libgcc #

Changing -mmacosx-version-min=10.5 to -mmacosx-version-min=10.6 does fix the issue...

I see other people over at conda-forge/gfortran_impl_osx-64-feedstock#82 had exactly the same issue, sigh.

Edit 2: reproducer reduced to ld call only thanks to -Wl,-v:

sandbox:${WORKSPACE}/srcdir/gcc_stage1/x86_64-apple-darwin14/libgcc # /workspace/destdir/bin/x86_64-apple-darwin14-ld -demangle -syslibroot /workspace/destdir/x86_64-apple-darwin14/sys-root/ -dynamic -arch x86_64 -platform_version macos 10.5 0.0 -o ./libgcc_s.dylib -ldylib1.10.5.o -L/workspace/srcdir/gcc_stage1/./gcc -L. -exported_symbols_list libgcc.map _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _mulbitint3_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _divmoddi4_s.o _udivdi3_s.o _umoddi3_s.o _udivmoddi4_s.o _udiv_w_sdiv_s.o _divmodbitint4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o _divhc3_s.o _mulhc3_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o fixsfbitint_s.o floatbitintsf_s.o fixdfbitint_s.o floatbitintdf_s.o extendhfsf2_s.o extendhfdf2_s.o extendhftf2_s.o extendhfxf2_s.o extendsfdf2_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o extendbfsf2_s.o trunctfhf2_s.o truncxfhf2_s.o truncdfhf2_s.o truncsfhf2_s.o trunctfsf2_s.o truncdfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o trunctfbf2_s.o truncxfbf2_s.o truncdfbf2_s.o truncsfbf2_s.o trunchfbf2_s.o fixtfbitint_s.o floatbitinttf_s.o fixhfti_s.o fixunshfti_s.o floattihf_s.o floatuntihf_s.o floattibf_s.o floatuntibf_s.o eqhf2_s.o fixxfbitint_s.o floatbitinthf_s.o floatbitintbf_s.o floatbitintxf_s.o enable-execute-stack_s.o hardcfr_s.o strub_s.o heap-trampoline_s.o emutls_s.o libgcc.a -lSystem -dylib -dylib_compatibility_version 1 -dylib_current_version 1.1 -dylib_install_name /workspace/destdir/x86_64-apple-darwin14/lib/libgcc_s.1.1.dylib -single_module
Assertion failed: targetAtom != NULL (/workspace/srcdir/cctools-port/cctools/ld64/src/ld/ld.hpp: Fixup: 902)
Aborted

GDB gives me a very unhelpful backtrace:

Thread 1 "x86_64-apple-da" received signal SIGABRT, Aborted.
0x00007ffff7fad455 in setjmp () from /lib/ld-musl-x86_64.so.1
(gdb) bt
#0  0x00007ffff7fad455 in setjmp () from /lib/ld-musl-x86_64.so.1
#1  0x00007ffff7fad5b0 in raise () from /lib/ld-musl-x86_64.so.1
#2  0x0000003000000010 in ?? ()
#3  0x00007fffffffd530 in ?? ()
#4  0x00007fffffffd470 in ?? ()
#5  0x0000000000000000 in ?? ()

@eschnett
Copy link
Contributor Author

eschnett commented Jan 3, 2025

Here is what my new best friend ChatGPT has to say on this issue:
"7. macOS Version
"The -mmacosx-version-min=10.5 flag you're using specifies the minimum macOS version for the build. If you're building on a newer macOS version, there might be issues related to backward compatibility.
Solution: Try adjusting the minimum macOS version to something more recent, such as 10.9 or 10.14, depending on the environment you're targeting."

@eschnett
Copy link
Contributor Author

eschnett commented Jan 4, 2025

Why do we care about 10.5? Julia requires 10.14, and we use the 10.12 SDK?

@giordano
Copy link
Member

giordano commented Jan 4, 2025

Why do we care about 10.5? Julia requires 10.14, and we use the 10.12 SDK?

We don't, it's GCC build script which is forcing it: gcc-mirror/gcc@20b8779#diff-5c91aee3ddbc0ea342f51c839978c4fb0bc1a1bb1bf2d160cbcb062431141c79R251, as I said above.

@giordano
Copy link
Member

giordano commented Jan 4, 2025

make -j${nproc} VERBOSE=1
make install
make -j${nproc} VERBOSE=1 libtapi
make -j${nproc} VERBOSE=1 install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure we need to install all of llvm here (which also takes a while to compile), my understanding is that we only need libtapi (for cctools), which can be installed with just install-libtapi, but we also need the header files for cctools below, and that's more complicated, we should eventually have

sandbox:${WORKSPACE}/srcdir/apple-libtapi/build # ls ${includedir}/tapi/
APIVersion.h           Defines.h              LinkerInterfaceFile.h  PackedVersion32.h      Symbol.h               Version.h              Version.inc            tapi.h

All the *.h files should be in src/tapi/include/tapi, but Version.inc is generated inside the build directory.

@giordano
Copy link
Member

giordano commented Jan 11, 2025

Uhm, now I'm having troubles compiling glibc for x86_64-linux at

make -j${nproc}

[18:06:22] In file included from readlib.c:37:
[18:06:22] ../sysdeps/unix/sysv/linux/x86_64/ldconfig.h:27:30: error: ‘FLAG_ELF_MUSL’ undeclared here (not in a function); did you mean ‘FLAG_ELF’?
[18:06:22]    27 |   { "libc.musl-x86_64.so.1", FLAG_ELF_MUSL }
[18:06:22]       |                              ^~~~~~~~~~~~~
[18:06:22] readlib.c:61:3: note: in expansion of macro ‘SYSDEP_KNOWN_LIBRARY_NAMES’
[18:06:22]    61 |   SYSDEP_KNOWN_LIBRARY_NAMES
[18:06:22]       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
[...]
[18:06:22] make[2]: *** [../o-iterator.mk:9: /workspace/srcdir/glibc_build/elf/readlib.o] Error 1
[18:06:22] make[2]: *** Waiting for unfinished jobs....

Failed command should be

sandbox:${WORKSPACE}/srcdir/glibc-2.17/elf # x86_64-linux-gnu-gcc readlib.c -c -std=gnu99 -fgnu89-inline  -D_GNU_SOURCE -O2 -Wall -Winline -Wno-array-parameter -Wno-builtin-declaration-mismatch -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes         -I../include -I/workspace/srcdir/glibc_build/elf -I/workspace/srcdir/glibc_build -I../sysdeps/unix/sysv/linux/x86_64/64/nptl -I../sysdeps/unix/sysv/linux/x86_64/64 -I../nptl/sysdeps/unix/sysv/linux/x86_64 -I../nptl/sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/wordsize-64 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../nptl/sysdeps/x86_64/64 -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/multiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu -I../sysdeps/x86_64/multiarch -I../nptl/sysdeps/x86_64 -I../sysdeps/x86_64 -I../sysdeps/x86 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64/wordsize-64 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdinc -isystem /workspace/x86_64-linux-gnu/destdir/bin/../lib/gcc/x86_64-linux-gnu/14.2.0/include -isystem /workspace/x86_64-linux-gnu/destdir/bin/../lib/gcc/x86_64-linux-gnu/14.2.0/include-fixed -isystem /workspace/destdir/x86_64-linux-gnu/sys-root/usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h       -o /workspace/srcdir/glibc_build/elf/readlib.o -MD -MP -MF /workspace/srcdir/glibc_build/elf/readlib.o.dt -MT /workspace/srcdir/glibc_build/elf/readlib.o
In file included from readlib.c:37:
../sysdeps/unix/sysv/linux/x86_64/ldconfig.h:27:30: error: ‘FLAG_ELF_MUSL’ undeclared here (not in a function); did you mean ‘FLAG_ELF’?
   27 |   { "libc.musl-x86_64.so.1", FLAG_ELF_MUSL }
      |                              ^~~~~~~~~~~~~
readlib.c:61:3: note: in expansion of macro ‘SYSDEP_KNOWN_LIBRARY_NAMES’
   61 |   SYSDEP_KNOWN_LIBRARY_NAMES
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~

Need to figure out where musl is coming from here.

Interestingly,

sandbox:${WORKSPACE}/srcdir/glibc-2.17/elf # tail $(realpath ../sysdeps/unix/sysv/linux/x86_64/ldconfig.h)
#include <sysdeps/generic/ldconfig.h>

#define SYSDEP_KNOWN_INTERPRETER_NAMES \
  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
#define SYSDEP_KNOWN_LIBRARY_NAMES \
  { "libc.so.6", FLAG_ELF_LIBC6 },      \
  { "libm.so.6", FLAG_ELF_LIBC6 },  \
  { "libc.musl-x86_64.so.1", FLAG_ELF_MUSL }

but https://github.com/bminor/glibc/blob/glibc-2.17/sysdeps/unix/sysv/linux/x86_64/ldconfig.h doesn't have the last line about musl (which is also a bit surprising when compiling glibc).

Edit: ah, that's coming from

diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h
index 59e20dc..13c4215 100644
--- a/sysdeps/generic/ldconfig.h
+++ b/sysdeps/generic/ldconfig.h
@@ -27,6 +27,7 @@
#define FLAG_ELF 0x0001
#define FLAG_ELF_LIBC5 0x0002
#define FLAG_ELF_LIBC6 0x0003
+#define FLAG_ELF_MUSL 0x0004
#define FLAG_REQUIRED_MASK 0xff00
#define FLAG_SPARC_LIB64 0x0100
#define FLAG_IA64_LIB64 0x0200
diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
index c7e9ad6..abd724e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
+++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
@@ -23,4 +23,5 @@
{ "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
#define SYSDEP_KNOWN_LIBRARY_NAMES \
{ "libc.so.6", FLAG_ELF_LIBC6 }, \
- { "libm.so.6", FLAG_ELF_LIBC6 },
+ { "libm.so.6", FLAG_ELF_LIBC6 }, \
+ { "libc.musl-x86_64.so.1", FLAG_ELF_MUSL }
but the patch to sysdeps/generic/ldconfig.h was rejected. Sigh.

How did this ever work?!? As far I could tell, the patch never applied to glibc 2.12 nor 2.17.

Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to build all GCC for all platforms locally. I'm now rebuilding and publishing them (could have started doing the publishing the first time round, oh well), tomorrow I'll open the PR to BinaryBuilderBase.

@giordano giordano merged commit 76b7ef0 into master Jan 12, 2025
3 checks passed
@giordano giordano deleted the eschnett/GCC-14 branch January 12, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants