diff --git a/README.md b/README.md index 5500e1e..e6860e2 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,14 @@ it comes to support. `make USE_SYSTEM_NIM=1 test` +### PARTIAL_STATIC_LINKING + +Statically link some libraries (currently libgcc\_s and libpcre). Defaults to 0. + +This is useful when you can't statically link Glibc because you use NSS functions. + +`make PARTIAL_STATIC_LINKING=1 beacon_node` + ### LINK_PCRE Link PCRE, defaults to 1. diff --git a/makefiles/variables.mk b/makefiles/variables.mk index a01eb10..40a7c63 100644 --- a/makefiles/variables.mk +++ b/makefiles/variables.mk @@ -30,13 +30,23 @@ ifdef LOG_LEVEL NIM_PARAMS := $(NIM_PARAMS) -d:chronicles_log_level="$(LOG_LEVEL)" endif +# statically link everything but libc +PARTIAL_STATIC_LINKING := 0 +ifeq ($(PARTIAL_STATIC_LINKING), 1) + NIM_PARAMS := $(NIM_PARAMS) --passL:-static-libgcc +endif + # avoid a "libpcre.so.3: cannot open shared object file: No such file or directory" message, where possible LINK_PCRE := 1 ifeq ($(LINK_PCRE), 1) ifneq ($(OS), Windows_NT) - ifneq ($(strip $(shell uname)), Darwin) - NIM_PARAMS := $(NIM_PARAMS) -d:usePcreHeader --passL:\"-lpcre\" - endif + ifneq ($(strip $(shell uname)), Darwin) + ifeq ($(PARTIAL_STATIC_LINKING), 1) + NIM_PARAMS := $(NIM_PARAMS) -d:usePcreHeader --passL:-l:libpcre.a + else + NIM_PARAMS := $(NIM_PARAMS) -d:usePcreHeader --passL:-lpcre +endif + endif endif endif