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

stdenv: make -nostdinc work as intended #91974

Merged
merged 1 commit into from Jul 28, 2020
Merged

Conversation

@Mic92
Copy link
Contributor

Mic92 commented Jul 1, 2020

Right now we add glibc to search path also -nostdinc was provided,
which breaks projects providing their own gcc.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@Mic92 Mic92 requested a review from Ericson2314 as a code owner Jul 1, 2020
@Mic92 Mic92 requested a review from matthewbauer Jul 1, 2020
pkgs/test/cc-wrapper/default.nix Outdated Show resolved Hide resolved
@teto teto mentioned this pull request Jul 1, 2020
0 of 9 tasks complete
@Mic92 Mic92 marked this pull request as draft Jul 1, 2020
@Mic92 Mic92 force-pushed the Mic92:nostdinc branch 3 times, most recently from b78a55d to d4f4506 Jul 2, 2020
@Mic92 Mic92 marked this pull request as ready for review Jul 2, 2020
@Mic92
Copy link
Contributor Author

Mic92 commented Jul 2, 2020

Until this hits master, the following solution also works:

with import <nixpkgs> {};
let
  libcPattern =
    builtins.replaceStrings ["/"] ["\\/"] "${gcc.libc_dev}/include";
  gcc' = wrapCCWith {
    cc = gcc.cc;
    bintools = binutils;
    extraBuildCommands = ''
      cat >> $out/nix-support/add-flags.sh <<'EOF'
      if [[ "$@" = *-nostdinc* ]]; then
          NIX_CFLAGS_COMPILE_${gcc.suffixSalt}=''${NIX_CFLAGS_COMPILE_${gcc.suffixSalt}//-idirafter ${libcPattern}/}
      fi
      EOF
    '';
  };
in (overrideCC stdenv gcc').mkDerivation {
  name = "env";
  buildInputs = [
    bashInteractive
  ];
}
@Mic92
Copy link
Contributor Author

Mic92 commented Jul 2, 2020

@GrahamcOfBorg build stdenv

@FRidh FRidh added this to WIP in Staging via automation Jul 2, 2020
@FRidh FRidh moved this from WIP to Needs review in Staging Jul 2, 2020
@Ericson2314
Copy link
Member

Ericson2314 commented Jul 22, 2020

Oh this looks great to me; I had tried something similar at one point when adding those new files.

Do note when you fix conflicts that we now touch all the flags files so downstream can unconditionally cat them.

@Ericson2314
Copy link
Member

Ericson2314 commented Jul 22, 2020

CC @aaronjanse just in case anything special needs to be done for relibc's crt0.

@Mic92 Mic92 force-pushed the Mic92:nostdinc branch from d4f4506 to d4ca08d Jul 22, 2020
@aaronjanse
Copy link
Member

aaronjanse commented Jul 23, 2020

CC @aaronjanse just in case anything special needs to be done for relibc's crt0.

I don't know enough to understand this PR well, but I've locally verified that these changes don't break relibc 👍

Right now we add glibc to search path also -nostdinc was provided,
which breaks projects providing their own gcc.
@Mic92 Mic92 force-pushed the Mic92:nostdinc branch from d4ca08d to 96092dc Jul 23, 2020
Staging automation moved this from Needs review to Ready Jul 28, 2020
@Ericson2314
Copy link
Member

Ericson2314 commented Jul 28, 2020

Oh i missed the conflicts were fixed. Let's ship!

@Ericson2314 Ericson2314 merged commit cd719c1 into NixOS:staging Jul 28, 2020
17 of 18 checks passed
17 of 18 checks passed
stdenv, stdenv.passthru.tests on x86_64-darwin
Details
stdenv.passthru.tests on x86_64-darwin No attempt
Details
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="96092dc"; rev="96092dc93640b8ad6520a8bae6f78d62eaba0ec2"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
stdenv, stdenv.passthru.tests on aarch64-linux Success
Details
stdenv, stdenv.passthru.tests on x86_64-linux Success
Details
Staging automation moved this from Ready to Done Jul 28, 2020
@Mic92 Mic92 deleted the Mic92:nostdinc branch Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Staging
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.