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

gcc: tighten platform flags special-case for aarch64-darwin #225328

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

eliasnaur
Copy link
Contributor

@eliasnaur eliasnaur commented Apr 8, 2023

The 4aa95e3 commit added support for
aarch64-darwin but also ignored platform flags if the build platform
is aarch64-darwin. This leads to confusing errors such as
pkgsCross.raspberryPi packages compiled with soft-float even though
the platform supports hard-float (and is built as such on other
platforms).

The correct way to ignore platform flags is to check targetPlatform,
not the build platform. This change fixes that.

While we're here, tigthen the special-case to cover only the problematic
flags: -with-cpu and -with-arch.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@eliasnaur eliasnaur requested a review from matthewbauer as a code owner April 8, 2023 19:12
@eliasnaur eliasnaur marked this pull request as draft April 8, 2023 19:31
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Apr 8, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Apr 8, 2023
@eliasnaur eliasnaur changed the title gcc: don't leave out platform flags on aarch64-darwin gcc: tighten platform flags special-case for aarch64-darwin Apr 8, 2023
@eliasnaur eliasnaur marked this pull request as ready for review April 8, 2023 23:37
@eliasnaur eliasnaur changed the base branch from staging to master April 11, 2023 22:58
@eliasnaur
Copy link
Contributor Author

Gentle ping.

@eliasnaur
Copy link
Contributor Author

@trofi may I ask for a review? I know this is darwin, but you've had good insights into gcc guts on my other PRs.

FWIW, this PR is the only missing piece for getting rid of darwin-builder in my project.

Copy link
Contributor

@trofi trofi left a comment

Choose a reason for hiding this comment

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

LGTM!

@trofi
Copy link
Contributor

trofi commented Apr 27, 2023

Conflicting files pkgs/development/compilers/gcc/common/platform-flags.nix

If you can resolve the conflict we can push it to master very quickly.

@eliasnaur
Copy link
Contributor Author

Done, thank you.

@@ -3,10 +3,13 @@
let
gcc = targetPlatform.gcc or {};
p = gcc
isAarch64Darwin = targetPlatform.isDarwin && targetPlatform.isAarch64;
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably need to move it out of the middle of p expression (1 line above or below) as eval fails as:

       error: syntax error, unexpected '=', expecting ';'

       at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/ofborg-evaluator-4/pkgs/development/compilers/gcc/common/platform-flags.nix:6:19:

            5|   p =  gcc
            6|   isAarch64Darwin = targetPlatform.isDarwin && targetPlatform.isAarch64;
             |                   ^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, thank you.

The 4aa95e3 commit added support for
aarch64-darwin but also ignored platform flags if the build platform
is aarch64-darwin. This leads to confusing errors such as
`pkgsCross.raspberryPi` packages compiled with soft-float even though
the platform supports hard-float (and is built as such on other
platforms).

The correct way to ignore platform flags is to check `targetPlatform`,
not the build platform. This change fixes that.

While we're here, tigthen the special-case to cover only the problematic
flags: `-with-cpu` and `-with-arch`.
@eliasnaur
Copy link
Contributor Author

Done. This time I tested with

$ nix build .#gcc

not

$ nix run .#hello

🤦

@trofi trofi merged commit e303eb2 into NixOS:master Apr 27, 2023
@trofi
Copy link
Contributor

trofi commented Apr 27, 2023

Pulled as is. Thank you!

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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants