-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
clang: skip the -nostdlibinc
patch on Darwin; ld64: search standard library locations
#349555
Conversation
9ee5389
to
feb9fd5
Compare
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.
Shouldn't this be targetPlatform? When cross compiling from Darwin to Linux, we'd want the same behaviour as building natively on Linux, right?
Yyyyes, maybe. Except the reasoning for why it’s safe and won’t cause things like #151879 is based on properties of Darwin as a host platform. So I don’t know, really. Part of me hopes that when cross to Darwin is a thing we’ll have figured out a way to get rid of this patch on Linux too, but I can change it to |
Oh, sorry, I misread you as talking about cross the other way around. I think it is safe for cross to Linux. This patch is only here to stop host platform stuff leaking in on non‐NixOS Linux. But it can’t really leak in on macOS because the stuff that would leak in isn’t there. And you’d have a cross sysroot for that case, anyway. But I guess the compiler would behave slightly differently (i.e., better, basically). |
'' + ( | ||
# See the comment on the `add-nostdlibinc-flag.patch` patch in | ||
# `../default.nix` for why we skip Darwin here. | ||
if lib.versionOlder release_version "13" && !stdenv.hostPlatform.isDarwin then '' | ||
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ | ||
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ | ||
lib/Driver/ToolChains/*.cpp | ||
'' else '' | ||
(cd tools && ln -s ../../clang-tools-extra extra) | ||
'' | ||
) + lib.optionalString stdenv.hostPlatform.isMusl '' |
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 is removed in #348568 i think.
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.
Yes, 8708697.
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’s replaced with a patch, but I think the logic of not using it on Darwin would remain in that case.
Oh nevermind adding a flag to the actual command line, not support for a flag |
So the situation is:
Ideally, the patch should be applied based on I would like to get this in for 24.11 because currently Rust bindgen stuff is broken on macOS and I don’t think it’s meaningfully backwards‐incompatible in a way that anyone will notice, but pinging @RossComputerGuy just in case. |
-nostdlibinc
patch on Darwin-nostdlibinc
patch on Darwin; ld64: search standard library locations
feb9fd5
to
49da105
Compare
Pushed to clean up now‐unnecessary hacks in the Darwin stdenv, and apply the same change to I also conditionalized the patch on both the host and target platform being Darwin for maximum safety for now. Hopefully in the future we can avoid the sysroot weirdness that makes this necessary on Linux hosts entirely. |
49da105
to
6784d7e
Compare
0f0c00b
to
8c87bfa
Compare
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.
LGTM before the 25th.
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.
zed-editor now builds fine on darwin without the NIX_CFLAGS_COMPILE = "-F${apple-sdk_15.sdkroot}/System/Library/Frameworks";
workaround for rust-bindgen 🥳
┏━ Dependency Graph:
┃ ┌─ ✔ blade-util-0.1.0 ⏱ 1s
┃ ├─ ✔ blade-macros-0.3.0 ⏱ 1s
┃ ├─ ✔ tree-sitter-gowork-0.0.1
┃ ├─ ✔ tree-sitter-heex-0.0.1
┃ ├─ ✔ xim-ctext-0.3.0
┃ ├─ ✔ tree-sitter-md-0.3.2
┃ ├─ ✔ xim-0.4.0
┃ ├─ ✔ xim-parser-0.2.1
┃ ├─ ✔ xkbcommon-0.7.0
┃ ├─ ✔ tree-sitter-yaml-0.6.1 ⏱ 8s
┃ ┌─ ✔ cargo-vendor-dir ⏱ 34s
┃ ├─ ✔ cargo-bundle-unstable-2023-08-18 ⏱ 2m46s
┃ ├─ ✔ cargo-about-0.6.4 ⏱ 3m47s
┃ ✔ zed-editor-0.157.5 ⏱ 41m5s
┣━━━ Builds
┗━ ∑ ⏵ 0 │ ✔ 1903 │ ⏸ 0 │ Finished at 08:30:05 after 11h24m32s
We have to leave the flags in the wrapper until the bootstrap tools are updated, but drop the redundant `-isysroot` to fix issues like <NixOS#349555>.
8c87bfa
to
37b4e76
Compare
Zed working confirms that this PR accomplishes its primary goal 🎉 Still waiting to hear about .NET. Swift is being a pain and we might have to back out those changes for now. Testing dropping the redundant |
Ack. |
37b4e76
to
3f0333e
Compare
6013ee9
to
670a9d2
Compare
This is basically harmless for the same reason as it is for Clang, and lets us avoid doing wrapper hacks to fix things like the .NET build. This reverts commit 4340a5a.
670a9d2
to
b75c702
Compare
-nostdlibinc
patch on Darwin; {ld64,swift}: search standard library locations-nostdlibinc
patch on Darwin; ld64: search standard library locations
Dropped the Swift changes; it’s too haunted to deal with right now and it works okay without the commit. Moved the flags for backwards‐compatibility with the current bootstrap tools into the |
Summary of the state of things: it bootstraps fine and fixes the regression, can build Swift, Zed, etc., but the .NET build fails due to Swift‐related |
It turns out that .NET’s build system just has |
The stdenv changes LGTM. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/the-darwin-sdks-have-been-updated/55295/26 |
It kind of feels like we should find a better way of doing this on Linux too, but I’m picking the conservative option for now. Not tested in any way yet.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.