-
Notifications
You must be signed in to change notification settings - Fork 80
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
Detect whether compiler is Clang at nix eval time #216
Conversation
We can use cc.isClang to detect if compiler is Clang that would simplify runtime code.
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.
Nice, thanks!
In rules_nixpkgs, this attribute is now used to determine whether the compiler is clang, see [#216]. [#216]: tweag/rules_nixpkgs#216
In rules_nixpkgs, this attribute is now used to determine whether the compiler is clang, see [#216]. [#216]: tweag/rules_nixpkgs#216 CHANGELOG_BEGIN CHANGELOG_END
In rules_nixpkgs, this attribute is now used to determine whether the compiler is clang, see [#216]. [#216]: tweag/rules_nixpkgs#216 CHANGELOG_BEGIN CHANGELOG_END
…3798) * Update `rules_nixpgks` to HEAD Since [rules_nixpkgs#191] has been merged, we can drop the `rules-nixpkgs-arm.patch` from rules_nixpkgs. Also, rules_nixpkgs has been split into several components which need to be added explicitly in `deps.bzl`, see [#182]. [#191]: tweag/rules_nixpkgs#191 [#182]: tweag/rules_nixpkgs#182 * Adapt `compatibility/deps.bzl` * Update platforms repository to version 0.0.4 It has been updated in rules_nixpkgs, so this just follows suite. * Pass through `isClang` attribute for the cc-toolchain In rules_nixpkgs, this attribute is now used to determine whether the compiler is clang, see [#216]. [#216]: tweag/rules_nixpkgs#216 CHANGELOG_BEGIN CHANGELOG_END
This breaks for me with a custom toolchain? I think we should have a fallback mechanism, or a required module for custom toolchains (to allow for attribute defaults)
Maybe |
@dmadisetti Thanks for raising this.
Would it be feasible to extend the custom toolchain such that Otherwise, yes, a fallback branch seems like a reasonable option. |
@aherrmann it is possible to define I think the nicest option would be to create toolchain modules (I think one can call Failing that, the branch should be fine! I've been running a patch of Let me know if we should move this concern to its own issue |
Perhaps improving the error message is the right path then. I think this could also be achieved with a branch like you suggest: If the field is missing, the error could instruct the user to provide it. Thinking a bit more about it, I wonder if this issue is related to what @avdv encountered in tweag/rules_haskell#1750 (comment). |
I would recommend to not fall back to assuming that it's not Clang. When I ran into this issue, it was not trivial to debug the error. I think recommending people to add |
AFAIU, the idea was not to use a default value, but to fall back to the old behavior of calling We could even print a deprecation warning in this case. Also, I like the idea about the module! Currently you need to be aware of the current expectations and that is not very user friendly. |
Yes, that was also my understanding. This sounds far less dangerous than a hard-coded fall-back. @YorikSar were there any issues with that approach that #216 fixed?
To be sure I'm on the same page. This is talking about NixOS modules, correct? I'm not quite sure I understand how they fit here. Could you perhaps sketch out what this would look like? |
As far as I remember, |
Oh, I see. I think in this case this should be fixed by the switch to using |
While working on #215 I noticed that we can use cc.isClang to detect if compiler is Clang. It requires us to pull this flag through cc package wrappers. I split this from #215 because this affects our API: compiler packages in Nix would now be required to provide
isClang
flag that might not be the case for compilers provided by custom Nix expressions.