-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: expose cc-wrapper script #65813
cc-wrapper: expose cc-wrapper script #65813
Conversation
d3202d2
to
a5e11fa
Compare
Have you considered renaming the binary? |
In my opinion we should make |
I did, but other tooling (such as the CMake for using this compiler) expects it to have the original name, so when I tried to do this it complicated things pretty significantly. |
ping @Ericson2314 @orivej - sorry to be a bother, just in case you missed this. |
You could also use override like: gcc.overrideAttrs (old: {
installPhase = old.installPhase + ''
wrap ${old.targetPrefix}mycc $cc-wrapper $ccPath/${old.targetPrefix}mycc
'';
}) The only problem is how to reach cc-wrapper.sh. I think it needs to be added as an attribute. Something like diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index cf2d38cd997..60f18e7b4d1 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -132,6 +132,8 @@ stdenv.mkDerivation {
src=$PWD
'';
+ cc-wrapper = ./cc-wrapper.sh;
+
installPhase =
''
set -u
@@ -173,42 +175,42 @@ stdenv.mkDerivation {
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
if [ -e $ccPath/${targetPrefix}gcc ]; then
- wrap ${targetPrefix}gcc ${./cc-wrapper.sh} $ccPath/${targetPrefix}gcc
+ wrap ${targetPrefix}gcc $cc-wrapper $ccPath/${targetPrefix}gcc
ln -s ${targetPrefix}gcc $out/bin/${targetPrefix}cc
export named_cc=${targetPrefix}gcc
export named_cxx=${targetPrefix}g++
elif [ -e $ccPath/clang ]; then
- wrap ${targetPrefix}clang ${./cc-wrapper.sh} $ccPath/clang
+ wrap ${targetPrefix}clang $cc-wrapper $ccPath/clang
ln -s ${targetPrefix}clang $out/bin/${targetPrefix}cc
export named_cc=${targetPrefix}clang
export named_cxx=${targetPrefix}clang++
fi
if [ -e $ccPath/${targetPrefix}g++ ]; then
- wrap ${targetPrefix}g++ ${./cc-wrapper.sh} $ccPath/${targetPrefix}g++
+ wrap ${targetPrefix}g++ $cc-wrapper $ccPath/${targetPrefix}g++
ln -s ${targetPrefix}g++ $out/bin/${targetPrefix}c++
elif [ -e $ccPath/clang++ ]; then
- wrap ${targetPrefix}clang++ ${./cc-wrapper.sh} $ccPath/clang++
+ wrap ${targetPrefix}clang++ $cc-wrapper $ccPath/clang++
ln -s ${targetPrefix}clang++ $out/bin/${targetPrefix}c++
fi
if [ -e $ccPath/cpp ]; then
- wrap ${targetPrefix}cpp ${./cc-wrapper.sh} $ccPath/cpp
+ wrap ${targetPrefix}cpp $cc-wrapper $ccPath/cpp
fi
''
+ optionalString cc.langFortran or false ''
- wrap ${targetPrefix}gfortran ${./cc-wrapper.sh} $ccPath/${targetPrefix}gfortran
+ wrap ${targetPrefix}gfortran $cc-wrapper $ccPath/${targetPrefix}gfortran
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}g77
ln -sv ${targetPrefix}gfortran $out/bin/${targetPrefix}f77
''
+ optionalString cc.langJava or false ''
- wrap ${targetPrefix}gcj ${./cc-wrapper.sh} $ccPath/${targetPrefix}gcj
+ wrap ${targetPrefix}gcj $cc-wrapper $ccPath/${targetPrefix}gcj
''
+ optionalString cc.langGo or false ''
- wrap ${targetPrefix}gccgo ${./cc-wrapper.sh} $ccPath/${targetPrefix}gccgo
+ wrap ${targetPrefix}gccgo $cc-wrapper $ccPath/${targetPrefix}gccgo
'';
strictDeps = true; |
@veprbl Thanks for your comment. If I'm not mistaken, to apply your proposed solution to the package that I am writing, I would need to invoke I'm not sure if that would be a better solution to my problem than what I've submitted in this PR. If my description of the motivation was unclear, you can see the package I am writing here and here. |
@davidtwco In your case you might not need the value of This PR, as it is now, doesn't make |
I agree that your suggestion would make
The only part of your suggestion I'm still struggling to understand is how I would access |
@davidtwco {
extraBuildCommands = ''
wrap compute $cc-wrapper $ccPath/compute
wrap compute++ $cc-wrapper $ccPath/compute++
'';
} This change should also allow cc-wrapper script to be easily overridden. If you want you can propose it in a separate PR. I expect, it will be accepted. |
@veprbl thanks, I've tried to get that working, but unfortunately I hit an error that I'm not sure how to resolve. I'm not sure if it is a problem with the approach or my overlay:
|
@davidtwco Probably "cc-wrapper" is not a good name for an environment variable because of the dash, maybe should rename it to "wrapper" |
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 I don't like this. You are meant to call cc-wrapper and each compiler separately.
If I understand correctly, this is exactly what @davidtwco is looking to do. The name |
Oh my bad, this is other binaries to wrap? |
Yeah, this would enable wrapping binaries with names other than |
What is the main one of |
In my case, there are two binaries, In the approach this PR currently takes, the existing gcc and clang wrapping still takes place as normal, but extra Locally, I have the alternate approach, proposed by @veprbl, also working, which uses If either of these approaches are suitable, I can update this PR with them. If you'd prefer I attempt to modify cc-wrapper in some other way to achieve this, then I'm happy to do that also - I'm not quite sure I understand what you're suggesting in the quoted reply. |
@Ericson2314 What changes would you like me to make so that this can be merged? |
@davidtwco I think my proposed solution [1] would be less invasive and that change to nixpkgs should have greater a chance to be accepted. [1] #65813 (comment) |
a5e11fa
to
4996756
Compare
@veprbl I've updated the PR with your suggested approach. |
@davidtwco No problem. This can be avoided if you first reset your PR branch to a common state, then switch the github target branch and then push your PR branch by your change on top of the new target branch. It would be also fine to just open a new PR, especially because you have a new change now. @GrahamcOfBorg build stdenv.cc |
e2684b4
to
14cd28e
Compare
Rebased @GrahamcOfBorg build stdenv.cc |
@GrahamcOfBorg build hello |
OK, It's fine in its current state to me |
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.
Able to compile hello
on NixOS
Motivation for this change
This change exposes the cc-wrapper script as an attribute and environment variable so that compilers with names other than
clang
andgcc
can be wrapped using theextraBuildCommands
argument:Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @Ericson2314 @orivej