Skip to content
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

Enable aarch64 builds #82

Merged
merged 1 commit into from
Oct 12, 2024
Merged

Enable aarch64 builds #82

merged 1 commit into from
Oct 12, 2024

Conversation

mosteo
Copy link
Member

@mosteo mosteo commented Oct 9, 2024

No description provided.

@mosteo
Copy link
Member Author

mosteo commented Oct 9, 2024

@reznikmm or @simonjwright, any ideas or suggestions about the error starting here? It looks like some kind of dynamic library loading failure. This is for an alr built on macos-12 with gnat 14.2 on x64 (from the Alire index itself).

dyld[11348]: Library not loaded: '@rpath/libgcc_s.1.1.dylib'
  Referenced from: '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/alr'
  Reason: tried: '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/aaa/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ansi/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/lml/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ada-toml/lib/static/dev/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/gnatcoll-slim/lib/gnatcoll/static/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/umwi/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ajunitgen/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/xmlezout/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/cstrings/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/clic/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/simple_logging/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/den/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/dirty_booleans/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/diskflags/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/minirest/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/optional/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/semantic_versioning/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/si_units/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/spdx/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/stopwatch/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/toml_slicer/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/uri-ada/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/../..//setup_alire_prefix/lib/gcc/x86_64-apple-darwin21.6.0/14.2.0/adalib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/gcc/x86_64-apple-darwin21.6.0/14.2.0/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/gcc/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/aaa/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ansi/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/lml/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ada-toml/lib/static/dev/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/gnatcoll-slim/lib/gnatcoll/static/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/umwi/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/ajunitgen/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/xmlezout/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/cstrings/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/clic/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/simple_logging/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/den/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/dirty_booleans/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/diskflags/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/minirest/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/optional/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/semantic_versioning/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/si_units/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/spdx/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/stopwatch/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/toml_slicer/lib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/..//deps/uri-ada/obj/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/../..//setup_alire_prefix/lib/gcc/x86_64-apple-darwin21.6.0/14.2.0/adalib/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/alire_install/bin/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/gcc/x86_64-apple-darwin21.6.0/14.2.0/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/gcc/libgcc_s.1.1.dylib' (no such file), '/Users/runner/work/setup-alire/setup-alire/setup_alire_prefix/lib/libgcc_s.1.1.dylib' (no such file), '/usr/local/lib/libgcc_s.1.1.dylib' (no such file), '/usr/lib/libgcc_s.1.1.dylib' (no such file)
/Users/runner/work/_temp/0667c1ed-0351-47fa-9d08-c70bbc0dd47e.sh: line 2: 11348 Abort trap: 6           alr --version

@reznikmm
Copy link

I haven't seen this error before 😞

Shall we add -static-libgcc (gcc doc) to the linker options?

@mosteo mosteo force-pushed the feat/aarch64 branch 2 times, most recently from eea9346 to 9ddce90 Compare October 10, 2024 09:48
@mosteo
Copy link
Member Author

mosteo commented Oct 10, 2024

It's strange because it isn't happening in the alr nightly builds on either macos version. There must be some difference I'm not realizing.

@mosteo
Copy link
Member Author

mosteo commented Oct 10, 2024

There must be some difference I'm not realizing.

Perhaps that the original gnat used to build the failing alr is not available in this instance. But this is a stab in the dark.

@simonjwright
Copy link

Perhaps that the original gnat used to build the failing alr is not available in this instance.

That’s almost certainly the reason.

If I build with gnat-{aarch64,x86_64}-darwin-14.2.0-1 (the Alire compilers) then I get

$ otool -L hello
hello:
	@rpath/libgcc_s.1.1.dylib (compatibility version 1.0.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)

The paths used to interpret @rpath (a lot of them!) are baked in to the executable when it’s built, and libgcc_s.1.1.dylib comes with the compiler, so if the compiler isn’t where it was when the executable was built you get this issue.

There are several puzzling things.

The outputs of otool -L are:

alr-2.0.2-aarch64:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)

alr-2.0.2-x86_64:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

alr-nightly-aarch64:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.120.2)

alr-nightly-x86_64:
	@rpath/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.33.0)
	@rpath/libgcc_s.1.1.dylib (compatibility version 1.0.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

so what is it we’re doing differently in the x86_64 nightly from the other 3? And, why do the Alire compilers both include @rpaths in a little local build, but only the x86_64 compiler does for alr?

Using -largs -Wl,-v, the Alire aarch64 compiler outputs

/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/bin/../libexec/gcc/aarch64-apple-darwin23.6.0/14.2.0/ld \
-demangle \
-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ \
-dynamic \
-arch arm64 \
-platform_version macos 15.0.0 0.0 \
-o hello \
-L./ \
-L/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/lib/gcc/aarch64-apple-darwin23.6.0/14.2.0/adalib/ \
-L/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/bin/../lib/gcc/aarch64-apple-darwin23.6.0/14.2.0 \
-L/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/bin/../lib/gcc \
-L/opt/homebrew/lib \
-L/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/bin/../lib/gcc/aarch64-apple-darwin23.6.0/14.2.0/../../.. \
-lemutls_w \
-lheapt_w \
b~hello.o \
./hello.o \
-v \
/Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/lib/gcc/aarch64-apple-darwin23.6.0/14.2.0/adalib/libgnat.a \
-lgcc_s.1.1 \
-lgcc \
-lSystem \
-no_compact_unwind \
-rpath @loader_path \
-rpath /Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/lib/gcc/aarch64-apple-darwin23.6.0/14.2.0\
 -rpath /Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/lib/gcc -\
rpath /opt/homebrew/lib \
-rpath /Users/simon/Developer/bugs/alire/gnat-aarch64-darwin-14.2.0-1/lib

whereas mine outputs

/usr/bin/ld \
-demangle \
-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ \
-dynamic \
-arch arm64 \
-platform_version macos 15.0.0 0.0 \
-o hello \
-L./ \
-L/opt/gcc-14.2.0-1-aarch64/lib/gcc/aarch64-apple-darwin21/14.2.0/adalib/ \
-L/opt/gcc-14.2.0-1-aarch64/bin/../lib/gcc/aarch64-apple-darwin21/14.2.0 \
-L/opt/gcc-14.2.0-1-aarch64/bin/../lib/gcc \
-L/opt/homebrew/lib \
-L/opt/gcc-14.2.0-1-aarch64/bin/../lib/gcc/aarch64-apple-darwin21/14.2.0/../../.. \
-lemutls_w \
-lheapt_w \
b~hello.o \
./hello.o
-v \
/opt/gcc-14.2.0-1-aarch64/lib/gcc/aarch64-apple-darwin21/14.2.0/adalib/libgnat.a \
-lgcc \
-lSystem \
-no_compact_unwind

It’s not that the Alire compiler includes the xcode_15_fix. Also, my GCC 12 & 13 builds produce the short version!

I think that libgcc_s1 may be on its way out with Xcode 16 (clash of exception handling?)

@mosteo
Copy link
Member Author

mosteo commented Oct 10, 2024

Shall we add -static-libgcc (gcc doc) to the linker options?

I've verified the problem is happening at the nightly workflow, and adding that option indeed works. Thanks!

@mosteo
Copy link
Member Author

mosteo commented Oct 10, 2024

Thanks for the analysis, Simon, I missed your reply while I was trying things in the nightly build.

so what is it we’re doing differently in the x86_64 nightly from the other 3?

At this time what I can say is that we build from different workflows, and in particular for macOS there were some custom actions introduced by Maxim to support aarch64. I'm on the process of removing those, since we have now aarch64 toolchains in the index, and maybe that will homogenize things. In any case, explicitly requesting static linking to libgcc seems to have worked. I'm unsure about secondary effects, as the description of that switch contains worrying comments about exception handling. But all of our tests pass, so...

Thanks for your help with this as the moment we enter linker territory I become stupefied.

@mosteo mosteo changed the base branch from v3 to v4 October 12, 2024 07:47
@mosteo mosteo force-pushed the feat/aarch64 branch 5 times, most recently from b214af1 to 77947b9 Compare October 12, 2024 08:35
@mosteo mosteo marked this pull request as ready for review October 12, 2024 08:42
@mosteo
Copy link
Member Author

mosteo commented Oct 12, 2024

Thanks for your help, Maxim, Simon; with this one we have the aarch64 builds in the v4 branch.

@mosteo mosteo merged commit 50c811b into v4 Oct 12, 2024
35 checks passed
@mosteo mosteo deleted the feat/aarch64 branch October 12, 2024 08:43
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