cc-wrapper: warn if clang's --target option is used on a wrapped compiler#323869
cc-wrapper: warn if clang's --target option is used on a wrapped compiler#323869emilazy merged 1 commit intoNixOS:stagingfrom
--target option is used on a wrapped compiler#323869Conversation
|
I disagree with this change. Upstreams rightly expect to be able to use Clang with custom targets (at least with some, like bpf). They probably do not expect Clang to have a full cross sysroot set up, but they do expect it to work for targets that don't need that, and it's valid of them to expect that. How about this? If a custom target is used, we exec the unwrapped compiler, to make it as likely as possible that simple uses with no libraries will work. Additionally, if it's not on a list of targets we consider safe (which should definitely include bpf and probably also wasm but not wasi), we warn before execing? |
|
I don't think passing to an unwrapped compiler is going to work very well, because it won't be able to find requisite headers. I think in the long run there's a need for a different type of wrapping - one for non-"system" targets, like wasm and gpu kernels, that have a fraction of the concerns that cc-wrapper deals with (though at the same time I probably wouldn't want to start writing a new cc-wrapper-alike without any shared code). See how awkward I found it to cook up a custom platform object for Perhaps cc-wrapper could take a Still, I do think we should be warning people that "this may not work right" until such time as we have a better solution. |
alyssais
left a comment
There was a problem hiding this comment.
I don't think passing to an unwrapped compiler is going to work very well, because it won't be able to find requisite headers.
Fair enough. I guess even with BPF, you could have header-only libraries you'd want to use, and it's only a warning.
Maybe as we get more experience with this it'll become clearer what a good solution will be…
5ec73f3 to
7db7bf0
Compare
7db7bf0 to
fc590fd
Compare
emilazy
left a comment
There was a problem hiding this comment.
This caused a bunch of Rust‐related headaches recently and I believe it’s still broken there, so yeah I approve of this as a general warning. Even if we want this to work properly, it currently doesn’t.
|
FWIW my main concern is that this might be spammy with other build tools that pass the |
|
This broke ROCm (because of course it did 😂). See: #375745 and #375850 I was wondering if you had some specific mechanism in mind that would work well for the workaround. 🤔 I'm guessing reverting this or adding an environment variable to turn this off in some places would not be a practical fix because it would cause a mass rebuild and therefore have a really long turnaround time? |
|
Fun. As discussed in #370180, ROCm’s use of a wrapped compiler seems a bit weird/dodgy in general. But in this case I guess it’s passing the correct target anyway? We could refine this check so that it accepts
|
|
We've hit an issue related to this change in the limine package, from what I understand we should be passing the unwrapped clang to use for the UEFI target right? there's #377696 that does this but I haven't reviewed it yet. it would be awesome if we had a UEFI toolchain in nixpkgs to not have to do that workaround
This seems to be a perfect solution for packages that target UEFI and only depend on vendored-in dependencies |
|
We've encountered issue with this solution as well. Code responsible for that is in the rust ecosystem crate: However something was in on the stderr: I think this warning gives an unintended side effect which doesn't make sense in this case. @emilazy what do you think? |
|
My (brief) reading of the code is it only uses |
|
The
It's set both on Linux and MacOS by default. I get that the Maybe we should add this warning only if |
|
Yup, we see this warning all the time with GHC too. |
Description of changes
A reaction to #318674. People shouldn't expect using the
--targetargument of a wrapped compiler to work properly. I'd personally be in favour of a hard fail in this case because it's only an accident if it appears to work ok.Note this is the first occurrence of
cc-wrapperemitting stderr output in nonNIX_DEBUGmode, but warnings tend not to have the desired effect if you need to ask for them first..Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-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.