Skip to content

Commit

Permalink
{bintools-wrapper,cc-wrapper}: allow paths relative to the Darwin SDK
Browse files Browse the repository at this point in the history
`-L` and `-I` are interpreted relative to the `$SDKROOT` by the
Darwin toolchain, so we have to avoid filtering out such paths in the
purity filter hacks in order to not break e.g. the .NET Core build
system. It’s also just the correct thing to do for the platform.
  • Loading branch information
emilazy committed Oct 26, 2024
1 parent 9142a07 commit a468519
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkgs/build-support/bintools-wrapper/ld-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "${NIX_STORE:-}"
while (( "$n" < "$nParams" )); do
p=${params[n]}
p2=${params[n+1]:-} # handle `p` being last one
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then
if [ "${p:0:3}" = -L/ ] && badPathWithDarwinSdk "${p:2}"; then
skip "${p:2}"
elif [ "$p" = -L ] && badPath "$p2"; then
elif [ "$p" = -L ] && badPathWithDarwinSdk "$p2"; then
n+=1; skip "$p2"
elif [ "$p" = -rpath ] && badPath "$p2"; then
n+=1; skip "$p2"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/cc-wrapper/cc-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then
-[IL] | -isystem) path=$p2 skipNext=true ;;
esac

if [[ -n $path ]] && badPath "$path"; then
if [[ -n $path ]] && badPathWithDarwinSdk "$path"; then
skip "$path"
$skipNext && n+=1
continue
Expand Down
13 changes: 13 additions & 0 deletions pkgs/build-support/wrapper-common/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ badPath() {
"${p#"${TEMPDIR:-/tmp}"}" = "$p"
}

# Like `badPath`, but handles paths that may be interpreted relative to
# `$SDKROOT` on Darwin. For example, `-L/usr/lib/swift` is interpreted
# as `-L$SDKROOT/usr/lib/swift` when `$SDKROOT` is set and
# `$SDKROOT/usr/lib/swift` exists.
badPathWithDarwinSdk() {
sdkPath=$SDKROOT/$1
if [[ "@darwinMinVersion@" && -e $sdkPath ]]; then
badPath "$sdkPath"
else
badPath "$1"
fi
}

expandResponseParams() {
declare -ga params=("$@")
local arg
Expand Down

0 comments on commit a468519

Please sign in to comment.