From ac9b57c07e37320086801904577156ad2d765233 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 21 May 2020 19:18:50 -0400 Subject: [PATCH] Properly bundle in libstdc++ --- ci/build/build-static-release.sh | 14 ++++++++++++-- ci/build/code-server.sh | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ci/build/build-static-release.sh b/ci/build/build-static-release.sh index d59c6a4c9..1283c116b 100755 --- a/ci/build/build-static-release.sh +++ b/ci/build/build-static-release.sh @@ -16,8 +16,11 @@ main() { mkdir -p "$RELEASE_PATH/bin" rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server" - - g++ -Wl,--allow-multiple-definition "$node_path" -static-libstdc++ -static-libgcc -o "$RELEASE_PATH/lib/node" + rsync "$node_path" "$RELEASE_PATH/lib/node" + if [[ $OS == "linux" ]]; then + bundle_dynamic_lib libstdc++ + bundle_dynamic_lib libgcc_s + fi ln -s "./bin/code-server" "$RELEASE_PATH/code-server" ln -s "./lib/node" "$RELEASE_PATH/node" @@ -26,4 +29,11 @@ main() { yarn --production --frozen-lockfile } +bundle_dynamic_lib() { + lib_name="$1" + lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')" + + cp "$lib_path" "$RELEASE_PATH/lib/" +} + main "$@" diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index 8811558d5..d998f32e1 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -17,4 +17,5 @@ bin_dir() { } BIN_DIR=$(bin_dir) +export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}" exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"