Skip to content

Commit

Permalink
Added Wrapper for Linker Arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Redfire75369 committed Oct 14, 2024
1 parent 809a1e6 commit 77f97ec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/scripts/macos-linker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# Wrapper to adapt ld64 to gnu style arguments
# Taken from https://github.com/rust-lang/rust/issues/60059#issuecomment-1972748340

declare -a args=()
for arg in "$@"
do
# Options for Linker
if [[ $arg == "-Wl,"* ]]; then
IFS=',' read -r -a options <<< "${arg#-Wl,}"
for option in "${options[@]}"
do
if [[ $option == "-plugin="* ]] || [[ $option == "-plugin-opt=mcpu="* ]]; then
# Ignore -lto_library and -plugin-opt=mcpu
:
elif [[ $option == "-plugin-opt=O"* ]]; then
# Convert -plugin-opt=O* to --lto-CGO*
args[${#args[@]}]="-Wl,--lto-CGO${option#-plugin-opt=O}"
else
# Pass through other arguments
args[${#args[@]}]="-Wl,$option"
fi
done

else
# Pass through other arguments
args[${#args[@]}]="$arg"
fi
done

# Use clang to call ld64.lld
exec ${CC} -v "${args[@]}"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
CFLAGS: -flto
CPPFLAGS: -flto
CXXFLAGS: -flto
RUSTFLAGS: -Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld -Clink-arg=-flto
RUSTFLAGS: -Clinker-plugin-lto -Clinker=${{ github.workspace}}/.github/scripts/macos-linker.sh -Clink-arg=-fuse-ld=lld
run: |
just build-release -vv --locked --target $TARGET
mv ./target/$TARGET/release/cli ./target/$TARGET/release/spiderfire
Expand Down

0 comments on commit 77f97ec

Please sign in to comment.