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
Member

@Mic92 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 July 1, 2020 20:57
@Mic92 Mic92 requested a review from matthewbauer July 1, 2020 20:59
@Mic92
Copy link
Member 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
Member 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

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

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

@aaronjanse
Copy link
Member

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.
Staging automation moved this from Needs review to Ready Jul 28, 2020
@Ericson2314
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Staging
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants