-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
pkgsStatic: use clang for C compiler on Darwin #86223
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
Conversation
7a03502
to
0de6275
Compare
macOS doesn't actually officially support static linking, right? I remember it being brittle and them going to some lengths to break building static executables over time. Not that I object to supporting it, just wondering if it should maybe have some kind of warning on it. Edit: Ah, I see; these still link to |
makeStaticDarwin = stdenv: stdenv // { | ||
makeStaticDarwin = stdenv_: let stdenv = stdenv_.override { | ||
# extraBuildInputs are dropped in cross.nix, but darwin still needs them | ||
extraBuildInputs = [ self.buildPackages.darwin.CF ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably just works in native compilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. pkgsStatic.htop
fails without it. (Although that does bring up the question of why extraBuildInputs exists at all.)
@@ -63,6 +63,8 @@ in lib.init bootStages ++ [ | |||
# `tryEval` wouldn't catch, wrecking accessing previous stages | |||
# when there is a C compiler and everything should be fine. | |||
then throw "no C compiler provided for this platform" | |||
else if crossSystem.isDarwin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need this to be an option. I think we want there to be a way to also use gcc for cross on Darwin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's possible but it would require nixpkgs to support Darwin as a cross target with a non-Darwin build platform, and I don't know if that's the case? I wasn't able to build a cc toolchain for it when I tried, anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - that's not supported. But we do want to support building statically on native Darwin gcc. That might not be as useful as I was originally thinking though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for now! The gcc option can be easily added later.
Motivation for this change
As title. Looks like people haven't really been using pkgsStatic on Darwin for a long time.
In addition to the testing steps listed below, I also ran some manual tests since pkgsStatic has very little test coverage in nixpkgs overall.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)