cc-wrapper: Pass shellcheck and other cleanups#27879
cc-wrapper: Pass shellcheck and other cleanups#27879Ericson2314 merged 1 commit intoNixOS:stagingfrom
Conversation
|
@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @vcunat and @abbradar to be potential reviewers. |
Ericson2314
left a comment
There was a problem hiding this comment.
Here's some things I'd like feedback on (along with me discovering my own mistake :)).
There was a problem hiding this comment.
I think not including extraBefore here was an oversight of whoever added it originally. Note that the debugging code below originally also skipped it.
There was a problem hiding this comment.
This was the same one as above---eager copy paste---and unneeded.
There was a problem hiding this comment.
Somebody should weigh in on this.
There was a problem hiding this comment.
thsi is probably not intentional
There was a problem hiding this comment.
I weigh in on "thsi" most likely being a typo. Does that count?
There was a problem hiding this comment.
Wait, we already check for file existence, so this is definitely isn't needed.
There was a problem hiding this comment.
Semantics change, but all the flags are sans-whitespace so it seems fine.
There was a problem hiding this comment.
I think this is clearer than the regex stuff that was there before---and shellcheck said the regex stuff was done wrong anyways such that only string literals would match.
There was a problem hiding this comment.
N.B. bugs like this weren't being caught because extra word splitting on arrays.
There was a problem hiding this comment.
Semantics change, but the old version was a mistake. I fixed a hardening flag bug uncovered by this; hope there aren't others.
@orivej did something the same fix for ld-wrapper, and I guess it was fine there?
There was a problem hiding this comment.
So the "skip" thing does say "bad path", but not knowing what flag it came from is strictly less useful. I'm conflicted.
There was a problem hiding this comment.
This is a dead variable, but used in commented code, so I guess I'll leave it for now.
7f7ed3c to
de957cc
Compare
|
In #27672 I made cc-wrapper robust with undefined variables with |
There was a problem hiding this comment.
thsi is probably not intentional
de957cc to
6463fd3
Compare
|
OK I think I dealt with all comments. |
| NIX_CFLAGS_LINK+=" $NIX_CXXSTDLIB_LINK" | ||
| fi | ||
|
|
||
| LD=@ldPath@/ld |
There was a problem hiding this comment.
This would be the unwrapped ld, which seems wrong.
| params=("${rest[@]}") | ||
| fi | ||
|
|
||
| LD=@prog@ |
There was a problem hiding this comment.
This however would be the wrapped ld. Since cc will fork ld-wrapper, the old LD=..., assuming LD was already an export so it affected forked processes' environments (!), would be clobbered anyways.
| export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" | ||
|
|
||
| # Export and assign separately in order that a failing $(..) will fail | ||
| # the script. |
There was a problem hiding this comment.
Added back better comment without typo.
Motivation for this change
In many cases, this involved taking @orivej's and @edolstra's recent ld-wrapper improvements, and applying then elsewhere.
The only semantics changes I know of are
Fix bad word-splitting---already done with ld-wrapper with no issues
Remove unused and probably wrong
LD=---didn't take into account cross and in cc-wrapper pointed to unwrapped ld while in ld-wrapper pointed to wrapped ld.Things done
Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers.
(nix.useSandbox on NixOS,
or option
build-use-sandboxinnix.confon non-NixOS)
nix-shell -p nox --run "nox-review wip"./result/bin/)CC @orivej