Skip to content

global use of stdenv adapter withCFlags is broken #225740

@Shawn8901

Description

@Shawn8901

Describe the bug

As context: I am trying to build my machines with x86-64-v3 compiler flags. There is a open PR which introduces that feature. (but its not really related to the error).
Nevertheless in addition i try to compile all my packages with -mpclmul flag.

I was "activating" that feature via the stdenv adapter withCFlags that is present in

withCFlags = compilerFlags: stdenv:
and setting that via doing

  nixpkgs.overlays = [
    (self: super: {
      stdenv = super.withCFlags ["-mpclmul"] super.stdenv;
    })
  ];

or

  nixpkgs.config.replaceStdenv = {pkgs}: pkgs.withCFlags ["-mpclmul"] pkgs.stdenv;

The build fails with

error: attribute 'libc_bin' missing

       at /nix/store/fldvk3c519c6qq304ha4cwikmj8ravv0-source/pkgs/build-support/cc-wrapper/default.nix:129:20:

          128| # Ensure bintools matches
          129| assert libc_bin == bintools.libc_bin;
             |                    ^

In addition i have also checked impureUseNativeOptimizations, which fails with the same error.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Get any nixos configuration
  2. add nixpkgs.config.replaceStdenv = {pkgs}: pkgs.withCFlags ["-mpclmul"] pkgs.stdenv;

Expected behavior

nix is doing a full rebuild of the system with the desired CFLAGS

Additional context

Possibly it got broken by #217206 . I did find that by some uneducated bisect attempts.
In addition if i change back the line to the previous line (without env. at the beginning) it evaluates successfully.

Sadly i honestly don't get how that got exactly broken so i can not provide a PR by myself.

Notify maintainers

@Artturin (sorry to ping you, but you are the only person i can relate to here and you did the treewide change in the mentioned PR)

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.22-xanmod1, NixOS, 23.05 (Stoat), 23.05.20230405.b9737bc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(root): `""`
 - channels(shawn): `""`
 - nixpkgs: `/nix/store/izd1kzpf37zysl17nga1gcw9c7x1mzxq-source`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions