Skip to content

Commit

Permalink
xcode-cross: Use the xcode clang toolchain directory as root director…
Browse files Browse the repository at this point in the history
…y for the execution

The -no-canonical-prefixes makes clang not resolve the destination
of the symlink, when resolving the clang executable location, instead
just looking at the symlink that was invoked.

This makes clang use this directory as root for compiler-rt files
as well, which now matches the directory used for libc++ as well.

This makes the setup much more similar to what it is in the original
scenarios.
  • Loading branch information
mstorsjo committed Apr 2, 2024
1 parent 55b67db commit 6d1ec12
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions setup-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export PATH=$CCTOOLS/bin:\$PATH
if [ "\$TOOL" = "clang++" ] || [ "\$TOOL" = "c++" ] || [ "\$TOOL" = "g++" ]; then
ARGS+=(--driver-mode=g++)
fi
ARGS+=(-no-canonical-prefixes)
EXE=\$(dirname \$(readlink -f \$0))/clang-exe
\$EXE "\${ARGS[@]}"
EOF
Expand All @@ -100,9 +101,15 @@ ln -s $CLANG/bin/dsymutil .
ln -s $CLANG/bin/llvm-nm nm
ln -s $CLANG/bin/clang clang-exe

cd ../lib
mkdir -p $CLANG/lib/arc
ln -s $(pwd)/clang/*.*.*/lib/darwin $CLANG/lib/clang/*.*.*/lib
for i in $(pwd)/arc/libarclite*.a; do
ln -s $i $CLANG/lib/arc
done
cd ../lib/clang
# Rename the original bundled clang resource directory to "orig", to avoid
# potential version number clashes.
mv * orig
# Fetch the version number of the resource directory of the clang we're
# using.
VER=$(cd $CLANG/lib/clang && ls)
# Link in the clang resource directory from the external installation into
# this directory.
ln -s $CLANG/lib/clang/$VER .
# Provide the original libraries in the external clang's resource directory.
ln -s $(pwd)/orig/lib/darwin $VER/lib

0 comments on commit 6d1ec12

Please sign in to comment.