-
-
Notifications
You must be signed in to change notification settings - Fork 255
[wrapper] Make cc_wrapper.sh
POSIX-compliant and use #!/bin/sh
#548
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
base: master
Are you sure you want to change the base?
Conversation
#!/bin/sh
#!/bin/sh
cc_wrapper.sh
POSIX-compliant and use #!/bin/sh
a420fd6
to
91d7af8
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.
Pull Request Overview
This PR makes the cc_wrapper.sh
shell script POSIX-compliant to support Linux distributions like NixOS that don't provide /bin/bash
. The change replaces bash-specific features with POSIX shell equivalents while maintaining the same functionality.
Key changes:
- Replace
#!/bin/bash
shebang with#!/bin/sh
- Convert bash arrays and associative constructs to POSIX-compatible alternatives
- Replace bash-specific syntax with POSIX shell equivalents
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This is a case in which Copilot comments are highly relevant and much more thorough than what I could provide. Please take a look. |
91d7af8
to
943f059
Compare
Copilot was quick to remind me that POSIX shells don't support the same nice syntax for regular expressions as bash. After fixing the issues it pointed out, I was able to get several of the test scripts to pass in an Ubuntu container, so hopefully CI will pass this time :) |
Some Linux distributions, such as NixOS, do not provide /bin/bash. This commit aims to make the LLVM toolchain compatible with these platforms by only using POSIX-compatible features in the shell script and replacing the shebang with #!/bin/sh . This commit does not update the corresponding MacOS script, as all MacOS builds should have /bin/bash. Supercedes bazel-contrib#543.
943f059
to
0732989
Compare
Trying to rewrite As an alternative, I moved the current |
Can a maintainer please re-run CI on this PR? |
I checked the errors and it appears that the new inner script is still not present. So somewhere it is not being copied as it needs to. |
Some Linux distributions, such as NixOS, do not provide
/bin/bash
. This PR aims to make the LLVM toolchain compatible with these platforms by only using POSIX-compatible features in the shell script and replacing the shebang with#!/bin/sh
.Prior to this change, attempting to use the LLVM toolchain to build a C/C++ target on NixOS causes an error like:
src/main/tools/linux-sandbox-pid1.cc:548: "execvp(external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh, 0x1ce8a310)": No such file or directory
where the
No such file or directory
error is referring to/bin/bash
, not thecc_wrapper.sh
script itself. In fact, trying to runbazel-REPONAME/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh
manually afterwards gives aRequired file not found
error.This PR emerged out of a discussion on #543, where it was noticed that replacing the
#!/bin/bash
shebang with#!/usr/bin/env bash
causes issues when the calling rule does not include/usr/bin
inPATH
(rules_rust
hits this case).This PR does not update the corresponding MacOS script, as all MacOS platforms should have
/bin/bash
.Supercedes #543.