Skip to content

Commit

Permalink
Only use --strip-uneeded on .so files
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff committed Nov 14, 2023
1 parent c4eeb43 commit 0679cdb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,22 @@ RUN find "${OUT}/bin" -name '*.lib' -exec install -Dt ../lib/ -m a-rwx,u+rw,g+r,
RUN find "$OUT/lib" -name '*.lib' -exec `
sh -euxc 'for _file in "$@"; do cp "$_file" "$(dirname "$_file")/lib$(basename "$_file" .lib).dll.a"; done' sh {} +

# Strip debug symbols and ensure any .so, .dll, .dylib has the execution flag set
# Strip must run before patchelf
# https://github.com/NixOS/patchelf/issues/507
RUN --mount=type=cache,target=/root/.cache `
echo 'strip --strip-unneeded "$@" && chmod +x "$@"' >/srv/stage.sh `
&& find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' -o -name '*.dll' -o -name '*.dylib' \) -exec /srv/build.sh {} +
# Ensure .so, .dll and .dylib have the execution bit set
RUN find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' -o -name '*.dll' -o -name '*.dylib' \) -exec chmod +x {} +

# Strip uneeded symbols from .so (Linux target only)
# Strip must run before patchelf: https://github.com/NixOS/patchelf/issues/507
RUN . /etc/environment `
&& find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' \) -exec strip --strip-unneeded {} +

# Ensure all .so files have the correct rpaths (Linux target only)
RUN find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' \) -exec patchelf --set-rpath '$ORIGIN' {} \;

# Remove non executable files from bin folder
# Strip debug symbols from .dll and .dylib (macOS and Windows targets)
RUN . /etc/environment `
&& find "$OUT" -type f \( -name '*.dll' -o -name '*.dylib' \) -exec strip -S {} +

# Remove non executable files from the bin folder
RUN find "${OUT}/bin" -type f -not -executable -delete

# Remove empty directories
Expand Down

0 comments on commit 0679cdb

Please sign in to comment.