gcc: only disable aligned_alloc for darwin build/host/target platforms#226290
gcc: only disable aligned_alloc for darwin build/host/target platforms#226290veprbl merged 1 commit intoNixOS:stagingfrom
Conversation
There was a problem hiding this comment.
I think it's a bit more tricky: aligned_alloc is gcc's builtin. As a result I expect it to be used both in gcc's binary and target libraries built by gcc. That means you likely want ac_cv_func_aligned_alloc=no for --host=darwin (and any --target=) to keep the properties of gcc binary. And for --target=darwin to keep the properties of target libraries like libgomp.
In theory it would be nice if gcc's build system provided hooks to affect only host or only target with ac_cv_func_aligned_alloc=no. But it's a bit tricky to get right. I think the canonical way to do it is to pass it via STAGE{2,3}_CONFIGURE_FLAGS to gcc.
Getting back to your issue you might get a reasonable outcome with lib.optionalString (hostPlatform.isDarwin || targetPlatform.isDarwin).
There was a problem hiding this comment.
Getting back to your issue you might get a reasonable outcome with lib.optionalString (hostPlatform.isDarwin || targetPlatform.isDarwin).
So
lib.optionalString (hostPlatform.isDarwin || targetPlatform.isDarwin) ''
export ac_cv_func_aligned_alloc=no
''
?
Isn't your new condition a super-set of the old, because of the ||? My issue is that without this PR (or similar) cross-compiled binaries for Raspberry Pi don't reference aligned_alloc whereas cross-compiled binaries built on Linux do. It seems to me your suggestion strictly expands the number of configurations where aligned_alloc will be left out.
Did you perhaps mean lib.optionalString (hostPlatform.isDarwin && targetPlatform.isDarwin), with && instead of ||?
There was a problem hiding this comment.
My suggestion was based on the following goals:
- when building on darwin build (either for linux or for darwin target) there should be no references to `aligned_allos)
- when building for target darwin (either on linux or darwin build) there should be no references to `aligned_allos)
Hence the ||.
There was a problem hiding this comment.
But I want to have darwin building for linux result in the same binaries as when linux builds for linux. That is, I want the aligned_alloc reference in the binaries because that's what linux building for linux have.
Do you know of a way to achieve that, without breaking darwin?
There was a problem hiding this comment.
Reading through gcc/doc/install.texi I found this bit (TIL!):
@subsubheading Overriding @command{configure} test results
Sometimes, it might be necessary to override the result of some
@command{configure} test, for example in order to ease porting to a new
system or work around a bug in a test. The toplevel @command{configure}
script provides three variables for this:
@table @code
@cindex @code{build_configargs}
@item build_configargs
The contents of this variable is passed to all build @command{configure}
scripts.
@cindex @code{host_configargs}
@item host_configargs
The contents of this variable is passed to all host @command{configure}
scripts.
@cindex @code{target_configargs}
@item target_configargs
The contents of this variable is passed to all target @command{configure}
scripts.
@end table
Thus most robust way to get that behavior might be the (untested):
lib.optionalString (buildPlatform.isDarwin) ''
export build_configargs=ac_cv_func_aligned_alloc=no
'' ++ lib.optionalString (hostPlatform.isDarwin) ''
export host_configargs=ac_cv_func_aligned_alloc=no
'' ++ lib.optionalString (targetPlatform.isDarwin) ''
export target_configargs=ac_cv_func_aligned_alloc=no
''There was a problem hiding this comment.
Thank you very much! Separate configure flags seem to be the correct fix, and achieves my goal of build platform independent binaries. PTAL.
Before this change a Darwin gcc would output binaries that avoid aligned_alloc, regardless of target platform. That's fine for Darwin targets, but not for non-darwin targets such as pkgsCross.raspberryPi. This change replaces the single configure flag with a flag for each of build, host, target. Idea by @trofi.
74a0638 to
b9aabd8
Compare
|
Excuse my ignorance, but what is the next step in getting this merged? More approvals? |
|
Getting review from @NixOS/darwin-maintainers would be nice. Otherwise I support merging it to |
|
Time for |
|
I guess this can only take place after 2023-05-15? |
Does the ban apply to darwin-only changes as well? |
|
Well, perhaps we could say that |
|
@eliasnaur Since this only affects cross, do you think you could massage this into a zero rebuild change? |
|
If it only affects cross, it should be enough to just do the inverse of this: nixpkgs/pkgs/development/compilers/gcc/12/default.nix Lines 72 to 74 in 120dd6a |
|
If I make the PR zero-rebuild as you describe, won't it break cross-building a darwin |
So I would say it is fine |
It may not work today, but won't we like to be able to cross-compile to darwin in the future? If I seem overly concerned about adding these special cases, it's because I've spent quite some time finding and fixing reproducibility ruining special cases already[0]. I'd rather not leave more for future contributors to untangle. [0] Apart from this PR, there are #226048, #223861, #225328, of which two trigger mass rebuilding. EDIT: almost forgot #229377. |
|
I think it's worth keeping it as is and wait to merge. |
|
The |
According to #232237, you are correct. |
Before this change a Darwin gcc would output binaries that avoid
aligned_alloc, regardless of target platform. That's fine for Darwin
targets, but not for non-darwin targets such as pkgsCross.raspberryPi.
This change replaces the single configure flag with a flag for
each of build, host, target.
Idea by @trofi.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)