You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cc-wrapper mktemp invokation incompatible with MacOS #258607
The issue can be resolved by applying the following change to cc-wrapper.sh:
@@ -246,7 +246,7 @@ if [[ -e @out@/nix-support/cc-wrapper-hook ]]; then
fi
if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
- responseFile=$(mktemp --tmpdir cc-params.XXXXXX)+ responseFile=$(mktemp "${TMPDIR:-/tmp}/cc-params.XXXXXX")
trap 'rm -f -- "$responseFile"' EXIT
printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
Expected behavior
The mktemp error should not have occurred. The code under test used to work, and failed after an update of the nixpkgs revision in use from ea4c80b to 6500b45.
Screenshots
n/a
Additional context
The commit range includes the following two commits that touch on mktemp:
520a544 adds mktemp --tmpdir to the strip setup-hook
6f2b3ba adds mktemp --tmpdir to the cc-wrapper for response file handling
The latter one seems to be the cause of the issue.
So the wrapper picks up the mktemp binary from the system instead of the one from the store because the environment is not pure? This makes the behavior of this and other wrappers unpredictable. Maybe it would be better to make sure that the tools used in the wrapper are actually from its real runtime dependencies in the store?
Maybe it would be better to make sure that the tools used in the wrapper are actually from its real runtime dependencies in the store?
Yes, that thought crossed my mind, too. However, I saw that there is an explicit import of coreutils, which is then explicitly reverted. And this import is conditional and seems to be disabled on MacOS. I don't know the context or reasoning for all this logic and didn't venture there. But, that may very well also be a good solution.
Ah cool! So it basically already works that way. Setting nativeTools = false actually enables the import.
Your explanation led me to find #11798 where this logic was first introduced. The discussion there is very interesting, afaiu we need to restore PATH to its original value so things like linker scripts will still find the intended executables.
I think that the commit that introduced the mktemp should have added it before the path gets restored.
Ah cool! So it basically already works that way. Setting nativeTools = false actually enables the import.
Oh, I see, thanks! I overlooked one negation.
I think that the commit that introduced the mktemp should have added it before the path gets restored.
That seems like it could solve the issue, too. Perhaps it's easier to just resolve mktemp before the PATH is reset and then still invoke it later, since there is some more code in-between.
I had opened #258608 that replaces the mktemp invocation by a portable one. That approach was easier to test in my use-case without rebuilding the world.
Activity
tobim commentedon Oct 2, 2023
So the wrapper picks up the
mktempbinary from the system instead of the one from the store because the environment is not pure? This makes the behavior of this and other wrappers unpredictable. Maybe it would be better to make sure that the tools used in the wrapper are actually from its real runtime dependencies in the store?aherrmann commentedon Oct 3, 2023
@tobim Yes, that matches my understanding.
Yes, that thought crossed my mind, too. However, I saw that there is an explicit import of coreutils, which is then explicitly reverted. And this import is conditional and seems to be disabled on MacOS. I don't know the context or reasoning for all this logic and didn't venture there. But, that may very well also be a good solution.
tobim commentedon Oct 3, 2023
Ah cool! So it basically already works that way. Setting
nativeTools = falseactually enables the import.Your explanation led me to find #11798 where this logic was first introduced. The discussion there is very interesting, afaiu we need to restore
PATHto its original value so things like linker scripts will still find the intended executables.I think that the commit that introduced the
mktempshould have added it before the path gets restored.aherrmann commentedon Oct 3, 2023
Oh, I see, thanks! I overlooked one negation.
That seems like it could solve the issue, too. Perhaps it's easier to just resolve
mktempbefore thePATHis reset and then still invoke it later, since there is some more code in-between.I had opened #258608 that replaces the
mktempinvocation by a portable one. That approach was easier to test in my use-case without rebuilding the world.