aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-20 19:47:33 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-20 19:47:33 -0800
commit03dc674c2de0be2ee76b5ada3e5ff439a2d1b59b (patch)
treed982151bb86f0fd40a96574fa12b8d7397ac8e80
parentd0bcd3c6fbeecb4753f4ff74a95f28e44cb5a36e (diff)
downloadbun-03dc674c2de0be2ee76b5ada3e5ff439a2d1b59b.tar.gz
bun-03dc674c2de0be2ee76b5ada3e5ff439a2d1b59b.tar.zst
bun-03dc674c2de0be2ee76b5ada3e5ff439a2d1b59b.zip
Prevent linking to glibc 2.3x in release builds
-rw-r--r--Makefile168
1 files changed, 59 insertions, 109 deletions
diff --git a/Makefile b/Makefile
index 2a403d960..6f2865723 100644
--- a/Makefile
+++ b/Makefile
@@ -69,9 +69,7 @@ ifeq ($(OS_NAME),darwin)
endif
ifeq ($(OS_NAME),linux)
-LIBICONV_PATH = $(DEPS_DIR)/libiconv.a
-
-
+LIBICONV_PATH =
endif
build-iconv-linux:
@@ -215,7 +213,7 @@ ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) src/deps/libcrypto.boring.a
PLATFORM_LINKER_FLAGS =
ifeq ($(OS_NAME), linux)
-PLATFORM_LINKER_FLAGS = -lstdc++ \
+PLATFORM_LINKER_FLAGS = \
-lc \
-Wl,-z,now \
-Wl,--as-needed \
@@ -224,7 +222,11 @@ PLATFORM_LINKER_FLAGS = -lstdc++ \
-ffunction-sections \
-fdata-sections \
-Wl,--gc-sections \
- -fuse-ld=lld
+ -fuse-ld=lld \
+ -stdlib=libstdc++ \
+ -static-libstdc++ \
+ -static-libgcc \
+ -fPIC
endif
@@ -392,6 +394,42 @@ httpbench-release:
bun-codesign-debug:
bun-codesign-release-local:
+remove-glibc-version-dependency:
+ patchelf --clear-symbol-version __libc_start_main $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_key_create $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_once $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_setspecific $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_getspecific $(RELEASE_BUN);
+ patchelf --clear-symbol-version dlclose $(RELEASE_BUN);
+ patchelf --clear-symbol-version dlopen $(RELEASE_BUN);
+ patchelf --clear-symbol-version dlsym $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_attr_getstack $(RELEASE_BUN);
+ patchelf --clear-symbol-version dladdr $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_attr_setstacksize $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_create $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_detach $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_join $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_kill $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_mutex_trylock $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_setname_np $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_attr_setguardsize $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_rwlock_destroy $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_rwlock_rdlock $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_rwlock_init $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_rwlock_unlock $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_rwlock_wrlock $(RELEASE_BUN);
+ patchelf --clear-symbol-version __pthread_key_create $(RELEASE_BUN);
+ patchelf --clear-symbol-version fstat $(RELEASE_BUN);
+ patchelf --clear-symbol-version fstat64 $(RELEASE_BUN);
+ patchelf --clear-symbol-version lstat $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_getattr_np $(RELEASE_BUN);
+ patchelf --clear-symbol-version stat $(RELEASE_BUN);
+ patchelf --clear-symbol-version lstat64 $(RELEASE_BUN);
+ patchelf --clear-symbol-version pthread_sigmask $(RELEASE_BUN);
+ patchelf --clear-symbol-version __libc_single_threaded $(RELEASE_BUN);
+
+check-glibc-version-dependency:
+ @objdump -T $(RELEASE_BUN) | ((grep -qe "GLIBC_2.3[0-9]") && { echo "Glibc 2.3X detected, this will break the binary"; exit 1; }) || true
ifeq ($(OS_NAME),darwin)
@@ -498,12 +536,26 @@ release-bin-generate-copy:
release-bin-generate: release-bin-generate-copy release-bin-generate-zip
-release-bin-check:
+release-bin-check-version:
test $(shell eval $(BUN_RELEASE_BIN) --version) = $(PACKAGE_JSON_VERSION)
-release-bin-without-push: test-all release-bin-check release-bin-generate release-bin-codesign
+release-bin-check: release-bin-check-version
+release-bin-patch:
+
+ifeq ($(OS_NAME),linux)
+release-bin-patch: remove-glibc-version-dependency
+
+release-bin-check: release-bin-check-version
+# force it to run
+ @make -B check-glibc-version-dependency
+endif
+
+release-bin-without-push: release-bin-patch test-all release-bin-check release-bin-generate release-bin-codesign
release-bin: release-bin-without-push release-bin-push
+
+
+
release-bin-push:
gh release upload $(BUN_BUILD_TAG) --clobber $(BUN_DEPLOY_ZIP)
gh release upload $(BUN_BUILD_TAG) --clobber $(BUN_DEPLOY_ZIP) --repo $(BUN_AUTO_UPDATER_REPO)
@@ -666,7 +718,6 @@ bun-link-lld-release:
-O3
cp $(BUN_RELEASE_BIN) $(BUN_RELEASE_BIN)-profile
-$(STRIP) $(BUN_RELEASE_BIN)
-
mv $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
# We do this outside of build.zig for performance reasons
@@ -703,107 +754,6 @@ fmt-all:
unit-tests: generate-unit-tests run-unit-tests
-
-ifeq (test, $(firstword $(MAKECMDGOALS)))
-testpath := $(firstword $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS)))
-testfilter := $(wordlist 3, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
-testbinpath := zig-out/bin/test
-testbinpath := $(lastword $(testfilter))
-
-ifeq ($(if $(patsubst /%,,$(testbinpath)),,yes),yes)
-testfilterflag := --test-filter "$(filter-out $(testbinpath), $(testfilter))"
-
-endif
-
-ifneq ($(if $(patsubst /%,,$(testbinpath)),,yes),yes)
-testbinpath := zig-out/bin/test
-ifneq ($(strip $(testfilter)),)
-testfilterflag := --test-filter "$(testfilter)"
-endif
-endif
-
- testname := $(shell basename $(testpath))
-
-
- $(eval $(testname):;@true)
-
- ifeq ($(words $(testfilter)), 0)
-testfilterflag := --test-name-prefix "$(testname): "
-endif
-
-ifeq ($(testfilterflag), undefined)
-testfilterflag := --test-name-prefix "$(testname): "
-endif
-
-
-endif
-
-ifeq (build-unit, $(firstword $(MAKECMDGOALS)))
-testpath := $(firstword $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS)))
-testfilter := $(wordlist 3, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
-testbinpath := zig-out/bin/test
-testbinpath := $(lastword $(testfilter))
-
-ifeq ($(if $(patsubst /%,,$(testbinpath)),,yes),yes)
-testfilterflag := --test-filter "$(filter-out $(testbinpath), $(testfilter))"
-
-endif
-
-ifneq ($(if $(patsubst /%,,$(testbinpath)),,yes),yes)
-testbinpath := zig-out/bin/test
-ifneq ($(strip $(testfilter)),)
-testfilterflag := --test-filter "$(testfilter)"
-endif
-endif
-
- testname := $(shell basename $(testpath))
-
-
-$(eval $(testname):;@true)
-$(eval $(testfilter):;@true)
-$(eval $(testpath):;@true)
-
- ifeq ($(words $(testfilter)), 0)
-testfilterflag := --test-name-prefix "$(testname): "
-endif
-
-ifeq ($(testfilterflag), undefined)
-testfilterflag := --test-name-prefix "$(testname): "
-endif
-
-
-
-endif
-
-IO_FILE =
-
-ifeq ($(OS_NAME),linux)
-IO_FILE = "src/io/io_linux.zig"
-endif
-
-ifeq ($(OS_NAME),darwin)
-IO_FILE = "src/io/io_darwin.zig"
-endif
-
-build-unit:
- @rm -rf zig-out/bin/$(testname)
- @mkdir -p zig-out/bin
- zig test $(realpath $(testpath)) \
- $(testfilterflag) \
- --pkg-begin picohttp $(DEPS_DIR)/picohttp.zig --pkg-end \
- --pkg-begin io $(IO_FILE) --pkg-end \
- --pkg-begin clap $(DEPS_DIR)/zig-clap/clap.zig --pkg-end \
- --main-pkg-path $(shell pwd) \
- --test-no-exec \
- -fPIC \
- -femit-bin=zig-out/bin/$(testname) \
- -fcompiler-rt \
- -lc -lc++ \
- --cache-dir /tmp/zig-cache-bun-$(testname)-$(basename $(lastword $(testfilter))) \
- -fallow-shlib-undefined \
- $(ARCHIVE_FILES) $(ICU_FLAGS) && \
- cp zig-out/bin/$(testname) $(testbinpath)
-
run-unit:
@zig-out/bin/$(testname) -- fake