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

cc-wrapper: fix wrapper tests and building for darwin on staging-next #107336

Closed
wants to merge 3 commits into from

Conversation

Emantor
Copy link
Member

@Emantor Emantor commented Dec 21, 2020

Motivation for this change

Fix darwin builds and the cc-wrapper-libcxx tests for staging-next. Opening as draft since I am not sure the first commit is the correct fix for this.

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.

Disable the dynamic linker if the platform is darwin. On darwin the
dynamic linker cannot be passed using the -dynamic-linker argument, but
needs to be explicitly set via environment variables. Passing the linker
via -dynamic-linker results in an error:

  ld: unknown option: -dynamic-linker=/usr/lib/dyld

Pass a isdarwin variable to the build script and disable the linker on
darwin systems.
Since commit 11302dc ("clang, cc-wrapper: Move `--gcc-toolchain`
logic into CC wrapper") --gcc-toolchain was only passed i useGccForLibs
is true. However useGccForLibs is disabled if libcxx is null, which
results in the libcxxStdenv failing, since the linker can't find libgcc
while linking. Remove the condition check for libcxx == null, to let the
wrapper tests pass again.
@vcunat
Copy link
Member

vcunat commented Dec 21, 2020

/cc @NixOS/darwin-maintainers I guess?

@ofborg ofborg bot requested a review from peti December 21, 2020 18:46
Copy link
Member

@LnL7 LnL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polluting the wrappers with this type of logic doesn't seem ideal. Allowing this to be set in the environment and inheriting that from the stdenv seems like a nicer approach. Some similar things are done like that here.

export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1}
export NIX_IGNORE_LD_THROUGH_GCC=1

@Emantor
Copy link
Member Author

Emantor commented Dec 21, 2020

Polluting the wrappers with this type of logic doesn't seem ideal. Allowing this to be set in the environment and inheriting that from the stdenv seems like a nicer approach. Some similar things are done like that here.

export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1}
export NIX_IGNORE_LD_THROUGH_GCC=1

I strongly agree, that is why I opened it as a draft. What do you think is the correct approach here, setting NIX_DYNAMIC_LINKER to darwin and checking for that? Or do we need another variable for clarity?

Edit: pushed a fixup commit which implements the special handling for darwin in NIX_DYNAMIC_LINKER.

@Ericson2314
Copy link
Member

CC @Mic92. I'm curious what exactly want wrong with #91293/#92089/#94582 and #106908.

#106925 in particular was supposed to help with this exact issue?

@LnL7
Copy link
Member

LnL7 commented Dec 21, 2020

I would change setDynamicLinker=1 to NIX_SET_DYNAMIC_LINKER=${NIX_SET_DYNAMIC_LINKER:-1}.

@Ericson2314 That's just the test, the stdenv is still broken.

@ofborg ofborg bot added the 6.topic: stdenv Standard environment label Dec 21, 2020
@Emantor
Copy link
Member Author

Emantor commented Dec 21, 2020

I would change setDynamicLinker=1 to NIX_SET_DYNAMIC_LINKER=${NIX_SET_DYNAMIC_LINKER:-1}.

Okay, I just realized that my first fixup was also broken… it's late here so I'll be going to bed, if this hasn't been resolved by tomorrow I'll work on this some more.

@Emantor
Copy link
Member Author

Emantor commented Dec 22, 2020

Closing this, since the two changes have been reverted in staging-next.

@Emantor Emantor closed this Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants