Skip to content

make-binary-wrapper: add cc to propagatedBuildInputs#311794

Merged
Ericson2314 merged 1 commit intoNixOS:stagingfrom
rhelmot:freebsd-minimal3/make-binary-wrapper
May 26, 2024
Merged

make-binary-wrapper: add cc to propagatedBuildInputs#311794
Ericson2314 merged 1 commit intoNixOS:stagingfrom
rhelmot:freebsd-minimal3/make-binary-wrapper

Conversation

@rhelmot
Copy link
Contributor

@rhelmot rhelmot commented May 14, 2024

This is required for stdenv on native FreeBSD.

Description of changes

part of #296581

This is an @artemist change. While I don't understand it myself, I recall her telling me that this was something that should have been included for linux as well but was just working anyway by chance. It is required for the native FreeBSD stdenv.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
    • x86_64-freebsd
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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.

Add a 👍 reaction to pull requests you find important.

@rhelmot rhelmot requested a review from Ericson2314 as a code owner May 14, 2024 23:56
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 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. labels May 15, 2024
@artemist
Copy link
Member

Adding cc to propagatedBuildInputs makes derivations with makeBinaryWrapper in nativeBuildInputs run the cc-wrapper setup hook.
This isn't an issue for derivations using stdenv, as the cc setup hook is already run by default. However, derivations that are made with stdenvNoCC, e.g. because they're made with runCommand, will not run the cc-wrapper setup hook without this change.

For some reason, I don't recall why, the FreeBSD native compiler will not work correctly without the setup hook.

@rhelmot rhelmot added the 6.topic: bsd Running or building packages on BSD label May 15, 2024
@alyssais alyssais self-requested a review May 15, 2024 08:09
@alyssais
Copy link
Member

Sounds sensible to me. Can the commit message be updated with @artemist's explanation?

Adding cc to propagatedBuildInputs makes derivations with
makeBinaryWrapper in nativeBuildInputs run the cc-wrapper
setup hook. This isn't an issue for derivations using
stdenv, as the cc setup hook is already run by default.
However, derivations that are made with stdenvNoCC, e.g.
because they're made with runCommand, will not run the
cc-wrapper setup hook without this change.

For some reason the FreeBSD native compiler will not work
correctly without the setup hook.
@rhelmot rhelmot force-pushed the freebsd-minimal3/make-binary-wrapper branch from 645a6db to 0c34636 Compare May 17, 2024 19:53
@Ericson2314 Ericson2314 merged commit e897cae into NixOS:staging May 26, 2024
@alyssais
Copy link
Member

This seems to be causing some weird side effects. pkgsMusl.systemd no longer builds:

Command line: `clang /run/user/1008/tmp.WuVNjgdfHT/source/build/meson-private/tmpdd3qc57v/testfile.c -o /run/user/1008/tmp.WuVNjgdfHT/source/build/meson-private/tmpdd3qc57v/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=gnu11` -> 1
stderr:
clang: error: argument unused during compilation: '-pie' [-Werror,-Wunused-command-line-argument]

Given that this is a stdenv rebuild, and it seems unlikely to me that it's something specific about pkgsMusl.systemd that's broken, I think we need to revert this before it makes its way into the next staging cycle and is no longer changeable until the next one.

@rhelmot
Copy link
Contributor Author

rhelmot commented Jun 7, 2024

I finally ran into the error which necessitated this change: while cross-building a perl-env for FreeBSD:

clang: error: unable to execute command: Executable "ld" doesn't exist!
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This seems to be because perl's buildEnv explicitly includes makeBinaryWrapper but buildEnv uses runCommand (not runCommandCC). What should be the correct fix in this case?

rhelmot added a commit to rhelmot/nixpkgs that referenced this pull request Jun 17, 2024
The "correct" solution to this problem (makeBinaryWrapper fails to be
able to compile the binary wrapper when building a freebsd cross env) is
that makeBinaryWrapper should propagate or embed a reference to the
compiler. However, this causes build failures on musl, so this will have
to do for now.
@Ericson2314 Ericson2314 deleted the freebsd-minimal3/make-binary-wrapper branch July 24, 2024 18:34
@Ericson2314
Copy link
Member

I think the issue with this is that the hardening disable flags are not done per platform like the other cc-/bintools-wrapper env vars. (I ran into this with OpenBSD.)

rhelmot added a commit to rhelmot/nixpkgs that referenced this pull request Jul 24, 2024
The "correct" solution to this problem (makeBinaryWrapper fails to be
able to compile the binary wrapper when building a freebsd cross env) is
that makeBinaryWrapper should propagate or embed a reference to the
compiler. However, this causes build failures on musl, so this will have
to do for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: bsd Running or building packages on BSD 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-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants