Skip to content

cc-wrapper, gcc, gnat, gnat-bootstrap: fix GCC 13 and GNAT 13/14/15 builds on darwin - #522847

Merged
reckenrode merged 1 commit into
NixOS:stagingfrom
zinzilulo:fix-gnat-aarch64-darwin
May 28, 2026
Merged

reckenrode merged 1 commit into
NixOS:stagingfrom
zinzilulo:fix-gnat-aarch64-darwin

Conversation

@zinzilulo

@zinzilulo zinzilulo commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Enables GNAT 14 and 15 to build on aarch64-darwin (tested on master cc53fdd).

Resolves: #385174 #385189.

Notes

  • GCC 14 and 15 build correctly on aarch64-darwin; this commit preserves that
  • apple-sdk_15 or newer is required; apple-sdk_14 fails due to __FLT_EVAL_METHOD__ issues in Ada builds, and fixing this via patches introduces additional header compatibility issues
  • Bootstrap uses Alire-distributed GNAT binary
  • cc-wrapper change avoids duplicate rpath/flag injection during bootstrap

Things done

nixpkgs-branch-check[bot]

This comment was marked as outdated.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.first-time contribution This PR is the author's first one; please be gentle! 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. labels May 22, 2026
@zinzilulo
zinzilulo force-pushed the fix-gnat-aarch64-darwin branch from 38f7c23 to a53de2a Compare May 22, 2026 00:36
nixpkgs-branch-check[bot]

This comment was marked as outdated.

@zinzilulo
zinzilulo changed the base branch from master to staging May 22, 2026 00:38
@nixpkgs-ci nixpkgs-ci Bot closed this May 22, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this May 22, 2026
@nixpkgs-branch-check
nixpkgs-branch-check Bot dismissed stale reviews from themself May 22, 2026 00:44

Review dismissed automatically

@zinzilulo
zinzilulo force-pushed the fix-gnat-aarch64-darwin branch from a53de2a to 26dc433 Compare May 22, 2026 00:53
@ofborg ofborg Bot added the 6.topic: darwin Running or building packages on Darwin label May 22, 2026
@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label May 23, 2026
@zinzilulo
zinzilulo force-pushed the fix-gnat-aarch64-darwin branch from 26dc433 to ae74f90 Compare May 23, 2026 22:48

@sempiternal-aurora sempiternal-aurora left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you so much for this, this does seem to fix the local build, and should fix the hydra build as it no longer requires the xcode cli tools installed. Just a few questions I had regarding the implementation. Sadly, I can't seem to run a nixpkgs-review session. Gonna have a further look at this tonight to see if there's something I'm missing.

Comment thread pkgs/top-level/all-packages.nix Resolved
@zinzilulo
zinzilulo force-pushed the fix-gnat-aarch64-darwin branch 2 times, most recently from 56257df to abdd2a0 Compare May 26, 2026 14:05
Comment thread pkgs/top-level/all-packages.nix Resolved
@sempiternal-aurora

Copy link
Copy Markdown
Contributor

Hey, would you be able to rebase onto staging? Just means that #523510 will be in the tree and thus builds will be fixed on staging.

@zinzilulo
zinzilulo force-pushed the fix-gnat-aarch64-darwin branch from abdd2a0 to ad7c8b0 Compare May 26, 2026 22:34
@zinzilulo

zinzilulo commented May 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey, would you be able to rebase onto staging? Just means that #523510 will be in the tree and thus builds will be fixed on staging.

Hi, the cleanup is complete and the branch has been rebased onto staging as requested. The updated commit also addresses the GCC 13 build issues on Darwin. I’ve successfully built it on aarch64-darwin, and I expect it will also resolve the issue on x86_64-darwin. I’ve added logic to exclude gettext from nativeBuildInputs when building GCC/GNAT 13 to avoid header conflicts on Darwin. Let me know if this causes any issues on linux.

At the moment, the GNAT 13 darwin build is failing at stage2, and I’m not yet sure whether I’ll be able to resolve it. GNAT 14/15 should continue to build as expected across all platforms based on the fixes in the previous commit, but to be extra certain I will rebuild GNAT/GCC 14/15 on aarch64-darwin and aarch64-linux. That will take some time, and I’ll update once it’s complete.

I’ve split the changes into two commits to keep them more manageable, let me know if you’d prefer them squashed.

@zinzilulo

Copy link
Copy Markdown
Contributor Author

Hey, would you be able to rebase onto staging? Just means that #523510 will be in the tree and thus builds will be fixed on staging.

Hi, the cleanup is complete and the branch has been rebased onto staging as requested. The updated commit also addresses the GCC 13 build issues on Darwin. I’ve successfully built it on aarch64-darwin, and I expect it will also resolve the issue on x86_64-darwin. I’ve added logic to exclude gettext from nativeBuildInputs when building GCC/GNAT 13 to avoid header conflicts on Darwin. Let me know if this causes any issues on linux.

At the moment, the GNAT 13 darwin build is failing at stage2, and I’m not yet sure whether I’ll be able to resolve it. GNAT 14/15 should continue to build as expected across all platforms based on the fixes in the previous commit, but to be extra certain I will rebuild GNAT/GCC 14/15 on aarch64-darwin and aarch64-linux. That will take some time, and I’ll update once it’s complete.

I’ve split the changes into two commits to keep them more manageable, let me know if you’d prefer them squashed.

GCC 13/14/15 and GNAT 14/15 have been successfully built on both aarch64-darwin and aarch64-linux.

@zinzilulo

zinzilulo commented May 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Update: I have successfully built GNAT 13 on aarch64-darwin; the fix should also apply to x86_64-darwin. There is an ABI mismatch between the bootstrap GCC (AlireGNAT 13.2.0-2) and our source tree (Iains 13.4.0-darwin-r0), requiring patches to allow compilation. As a result, the build output may diverge from what upstream produces.

Thank you so much for looking into this. Only one last thing I have is asking if you can add a blurb to the gnat 13 nested ptr patch explaining why it is needed, and where the differences come from. Everything else looks amazing and with that I should be able to approve it.
For adding the blurb, one good way would be committing it and git format-patch the commit into a file. Gives you all the changes and everything like one would expect in the lkml or similar.

Hi, I have updated the patch.

Edit: My bad, will fix shortly.

I have done some testing on 481208b with both native GNAT/GCC and cross GCC builds on aarch64-darwin and aarch64-linux. Everything looks good, and we should be ready to merge.

@sempiternal-aurora sempiternal-aurora left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing work, I'm happy with it all now. Now we just wait for a committer.

@sempiternal-aurora sempiternal-aurora mentioned this pull request May 28, 2026
1 of 13 tasks
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label May 28, 2026
@sempiternal-aurora

Copy link
Copy Markdown
Contributor

@reckenrode I'm quite happy with this, if you're happy do you reckon we can merge this?

Comment on lines +3941 to +3949
gnat-bootstrap13 = wrapCCWith {
cc = callPackage ../development/compilers/gnat-bootstrap { majorVersion = "13"; };
isAlireGNAT = true;
};

gnat-bootstrap14 = wrapCCWith {
cc = callPackage ../development/compilers/gnat-bootstrap { majorVersion = "14"; };
isAlireGNAT = true;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love dropping the dropping of bintoolsDualAs here. It should make updating cctools easier (since Apple dropped gas from the version after what we have in Nixpkgs).

@reckenrode

Copy link
Copy Markdown
Contributor

@reckenrode I'm quite happy with this, if you're happy do you reckon we can merge this?

I left one question and a comment. Otherwise, looks good.

@reckenrode reckenrode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@reckenrode
reckenrode added this pull request to the merge queue May 28, 2026
Merged via the queue into NixOS:staging with commit 8ffb17f May 28, 2026
22 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Backport failed for staging-26.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin staging-26.05
git worktree add -d .worktree/backport-522847-to-staging-26.05 origin/staging-26.05
cd .worktree/backport-522847-to-staging-26.05
git switch --create backport-522847-to-staging-26.05
git cherry-pick -x 481208bdff2dc2f61d4f4fde51e6bd2a939f7d68

@sempiternal-aurora

Copy link
Copy Markdown
Contributor

@zinzilulo would you like to make a backport, or would you like me too? Just so we can get these changes in the new 26.05 release.

@zinzilulo

zinzilulo commented May 28, 2026 •

Copy link
Copy Markdown
Contributor Author

@zinzilulo would you like to make a backport, or would you like me too? Just so we can get these changes in the new 26.05 release.

Hi, I’ve already created the backport branch, but I’m not very familiar with the backport process yet. I don’t have write access to the repository, so I’m unable to push the branch upstream. It would be great if you could help with the final steps to get the changes into the 26.05 staging branch. If still possible, I’d also like these changes to be backported to 25.11.

@sempiternal-aurora

Copy link
Copy Markdown
Contributor

@zinzilulo would you like to make a backport, or would you like me too? Just so we can get these changes in the new 26.05 release.

Hi, I’ve already created the backport branch, but I’m not very familiar with the backport process yet. I don’t have write access to the repository, so I’m unable to push the branch upstream. It would be great if you could help with the final steps to get the changes into the 26.05 staging branch. If still possible, I’d also like these changes to be backported to 25.11.

Sure thing! Creating a backport is just another pull request. You branch off from the staging-26.05 (or staging-25.11), and then cherry pick the commits as the nixpkgs-ci bot said above, and then just push to your copy of the repo and open a pull request against that same branch. Here's one I did a bit back for an example #505938. Then it's just approved in much the same name as a normal PR. That make sense?

@zinzilulo

Copy link
Copy Markdown
Contributor Author

@zinzilulo would you like to make a backport, or would you like me too? Just so we can get these changes in the new 26.05 release.

Hi, I’ve already created the backport branch, but I’m not very familiar with the backport process yet. I don’t have write access to the repository, so I’m unable to push the branch upstream. It would be great if you could help with the final steps to get the changes into the 26.05 staging branch. If still possible, I’d also like these changes to be backported to 25.11.

Sure thing! Creating a backport is just another pull request. You branch off from the staging-26.05 (or staging-25.11), and then cherry pick the commits as the nixpkgs-ci bot said above, and then just push to your copy of the repo and open a pull request against that same branch. Here's one I did a bit back for an example #505938. Then it's just approved in much the same name as a normal PR. That make sense?

Hi, that’s very helpful. I’ve now created the backport PRs: #525192 and #525200. Thanks everyone for the input and assistance!

@sempiternal-aurora

Copy link
Copy Markdown
Contributor

And thank you for your first contribution! It's honestly an amazing piece of work, and it's been lovely to help you get it all merged! Also helped me a lot, saves me having to go and fix all this myself.

@sempiternal-aurora sempiternal-aurora mentioned this pull request May 28, 2026
2 of 14 tasks
@sempiternal-aurora

Copy link
Copy Markdown
Contributor

@zinzilulo If you have free time, would you be able to help me with something? I'm trying to get gprbuild running on darwin with the newly fixed gnat compiler. Specifically, the gnatPackages.gprbuild-boot package doesn't seem to run correctly. Sometimes it infinitely hangs, other times it crashes with errors like this:

GPRBUILD Pro 18.0w (19940713) (arm64-apple-darwin)
Copyright (C) 2004-2016, AdaCore
 6 lines: No errors
TMPDIR = "/private/tmp/nix-shell.TFymLc/GPR.52924"
/nix/store/76pn62nrgg9v4kgj5hi8v9kv73w13v85-gprbuild-boot-25.0.0/bin/gprconfig --batch -o /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP --target=arm-darwin --fallback-targets --config=ada,,,,

raised STORAGE_ERROR : stack overflow
Checking configuration /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP

==============Messages for file: /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP
     1.
        |
        >>> "project" expected

 6 lines: 1 error
gprbuild: processing of configuration project "/private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP" failed

This error came from me patching out the 2> /dev/null in the gnatbuild calls in the configure script of gnat15Packages.xmlada, and then running it. It seems that something is wrong with the compiler, but it correctly builds and runs ghdl-llvm on the same platform, albeit with some linker warnings at runtime:

<snip>
ld: warning: object file (/nix/store/ig6x6w9nxldaj3rzd56mm6mfx2qw0590-ghdl-llvm-6.0.0/lib/ghdl/ieee/v93/numeric_std.o) was built for newer macOS version (15.0) than being linked (14.0)
<snip>
ld: warning: could not create compact unwind for _grt__avhpi__indexed_names_by_index: does not use standard frame
<snip>

Do you have any thoughts, do you think this might be related to the requirement that we build gnat with apple-sdk_15, or is it maybe something else?

@zinzilulo

zinzilulo commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@zinzilulo If you have free time, would you be able to help me with something? I'm trying to get gprbuild running on darwin with the newly fixed gnat compiler. Specifically, the gnatPackages.gprbuild-boot package doesn't seem to run correctly. Sometimes it infinitely hangs, other times it crashes with errors like this:

GPRBUILD Pro 18.0w (19940713) (arm64-apple-darwin)
Copyright (C) 2004-2016, AdaCore
 6 lines: No errors
TMPDIR = "/private/tmp/nix-shell.TFymLc/GPR.52924"
/nix/store/76pn62nrgg9v4kgj5hi8v9kv73w13v85-gprbuild-boot-25.0.0/bin/gprconfig --batch -o /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP --target=arm-darwin --fallback-targets --config=ada,,,,

raised STORAGE_ERROR : stack overflow
Checking configuration /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP

==============Messages for file: /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP
     1.
        |
        >>> "project" expected

 6 lines: 1 error
gprbuild: processing of configuration project "/private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP" failed

This error came from me patching out the 2> /dev/null in the gnatbuild calls in the configure script of gnat15Packages.xmlada, and then running it. It seems that something is wrong with the compiler, but it correctly builds and runs ghdl-llvm on the same platform, albeit with some linker warnings at runtime:

<snip>
ld: warning: object file (/nix/store/ig6x6w9nxldaj3rzd56mm6mfx2qw0590-ghdl-llvm-6.0.0/lib/ghdl/ieee/v93/numeric_std.o) was built for newer macOS version (15.0) than being linked (14.0)
<snip>
ld: warning: could not create compact unwind for _grt__avhpi__indexed_names_by_index: does not use standard frame
<snip>

Do you have any thoughts, do you think this might be related to the requirement that we build gnat with apple-sdk_15, or is it maybe something else?

Hi, I was looking into this earlier, unfortunely I don’t currently have the time to debug it properly. But here is my speculation:

  • Both the hanging issue and the STORAGE_ERROR : stack overflow appear to originate from gprconfig, which is provided by the gprbuild-boot package.
  • From the crash trace, it looks like it fails in the compiler enumeration logic:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16fdfdae0)
  * frame #0: ...
    frame #1: gprconfig`gpr__knowledge__foreach_language_runtime
    frame #2: gprconfig`gpr__knowledge__foreach_compiler_in_dir
    frame #3: gprconfig`gpr__knowledge__foreach_compiler_in_path
    frame #4: gprconfig`_ada_gprconfig__main
    frame #5: gprconfig`main
    frame #6: dyld`start

This suggests the issue is in gprconfig compiler detection, not in the build or linking phase. It may be iterating over invalid or unexpected compiler entries and corrupting internal state, likely due to mismatched knowledge base / metadata.

There’s also a patch (nixpkgs-gnat.xml) that looks a bit fragile to me:

<variable name="gnat_unwrapped">
  <external>readlink -n ${PATH}/../nix-support/gprconfig-gnat-unwrapped</external>
</variable>

If that path resolution is off, it could break compiler discovery and lead to this kind of failure, which could be a contributing issue.

The linker warnings are generally harmless (to my experience). It could be due to the usage of a newer SDK, but doesn’t seem to be the offending factor.

I think this is less likely a regression from this PR. I’m happy to help dig deeper later if needed, but this probably belongs to #521558.

@sempiternal-aurora

Copy link
Copy Markdown
Contributor

@zinzilulo If you have free time, would you be able to help me with something? I'm trying to get gprbuild running on darwin with the newly fixed gnat compiler. Specifically, the gnatPackages.gprbuild-boot package doesn't seem to run correctly. Sometimes it infinitely hangs, other times it crashes with errors like this:

GPRBUILD Pro 18.0w (19940713) (arm64-apple-darwin)
Copyright (C) 2004-2016, AdaCore
 6 lines: No errors
TMPDIR = "/private/tmp/nix-shell.TFymLc/GPR.52924"
/nix/store/76pn62nrgg9v4kgj5hi8v9kv73w13v85-gprbuild-boot-25.0.0/bin/gprconfig --batch -o /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP --target=arm-darwin --fallback-targets --config=ada,,,,

raised STORAGE_ERROR : stack overflow
Checking configuration /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP

==============Messages for file: /private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP
     1.
        |
        >>> "project" expected

 6 lines: 1 error
gprbuild: processing of configuration project "/private/tmp/nix-shell.TFymLc/GPR.52924/GNAT-TEMP-000001.TMP" failed

This error came from me patching out the 2> /dev/null in the gnatbuild calls in the configure script of gnat15Packages.xmlada, and then running it. It seems that something is wrong with the compiler, but it correctly builds and runs ghdl-llvm on the same platform, albeit with some linker warnings at runtime:

<snip>
ld: warning: object file (/nix/store/ig6x6w9nxldaj3rzd56mm6mfx2qw0590-ghdl-llvm-6.0.0/lib/ghdl/ieee/v93/numeric_std.o) was built for newer macOS version (15.0) than being linked (14.0)
<snip>
ld: warning: could not create compact unwind for _grt__avhpi__indexed_names_by_index: does not use standard frame
<snip>

Do you have any thoughts, do you think this might be related to the requirement that we build gnat with apple-sdk_15, or is it maybe something else?

Hi, I was looking into this earlier, unfortunely I don’t currently have the time to debug it properly. But here is my speculation:

  • Both the hanging issue and the STORAGE_ERROR : stack overflow appear to originate from gprconfig, which is provided by the gprbuild-boot package.
  • From the crash trace, it looks like it fails in the compiler enumeration logic:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16fdfdae0)
  * frame #0: ...
    frame #1: gprconfig`gpr__knowledge__foreach_language_runtime
    frame #2: gprconfig`gpr__knowledge__foreach_compiler_in_dir
    frame #3: gprconfig`gpr__knowledge__foreach_compiler_in_path
    frame #4: gprconfig`_ada_gprconfig__main
    frame #5: gprconfig`main
    frame #6: dyld`start

This suggests the issue is in gprconfig compiler detection, not in the build or linking phase. It may be iterating over invalid or unexpected compiler entries and corrupting internal state, likely due to mismatched knowledge base / metadata.

There’s also a Nix patch in this PR that looks a bit fragile to me:

<variable name="gnat_unwrapped">
  <external>readlink -n ${PATH}/../nix-support/gprconfig-gnat-unwrapped</external>
</variable>

If that path resolution is off, it could break compiler discovery and lead to this kind of failure, which could be a contributing factor.

The linker warnings are generally harmless (to my experience). It could be due to the usage of a newer SDK, but doesn’t seem to be the offending factor.

I think this is less likely a regression from this PR. I’m happy to help dig deeper later if needed, but this probably belongs to #521558.

Ah, thank you so much! This really helps me. I should be able to use this to see if it fixes things. I have ideas about how I can fix it. Thank you so much!

@zinzilulo
zinzilulo deleted the fix-gnat-aarch64-darwin branch July 30, 2026 13:03
@vcunat vcunat mentioned this pull request Sep 28, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 8.has: failed backport 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.first-time contribution This PR is the author's first one; please be gentle! backport staging-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants