Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Remove RPATH/RUNPATH from cdylib on alpine-musl
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavoire committed Feb 14, 2022
1 parent 07412df commit b386c52
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ffi-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mkdir -v -p "$destdir/include/ddprof" "$destdir/lib/pkgconfig" "$destdir/cmake"
version=$(awk -F\" '$1 ~ /^version/ { print $2 }' < ddprof-ffi/Cargo.toml)
target="$(rustc -vV | awk '/^host:/ { print $2 }')"
shared_library_suffix=".so"
remove_rpath=0

# Rust provides this note about the link libraries:
# note: Link against the following native artifacts when linking against this
Expand All @@ -27,6 +28,8 @@ case "$target" in
"x86_64-alpine-linux-musl"|"aarch64-alpine-linux-musl")
expected_native_static_libs=" -lssp_nonshared -lgcc_s -lc"
native_static_libs=" -lssp_nonshared -lc"
# on alpine musl, Rust adds some weird runpath to cdylibs
remove_rpath=1
;;
"x86_64-apple-darwin")
expected_native_static_libs=" -framework Security -liconv -lSystem -lresolv -lc -lm -liconv"
Expand Down Expand Up @@ -63,6 +66,10 @@ echo "Building the libddprof_ffi library (may take some time)..."
cargo build --release --target "${target}"
cp -v "target/${target}/release/libddprof_ffi.a" "target/${target}/release/libddprof_ffi${shared_library_suffix}" "$destdir/lib/"

if [[ "$remove_rpath" -eq 1 ]]; then
patchelf --remove-rpath "target/${target}/release/libddprof_ffi${shared_library_suffix}"
fi

# objcopy might not be available on OSX
if command -v objcopy > /dev/null; then
# Remove .llvmbc section which is not useful for clients
Expand Down

0 comments on commit b386c52

Please sign in to comment.