Source: Chloe Kudryavtsev Remove When: The default Makefile doesn't enforce 32 bit binaries and allows for static linking. 1. Make M32 mode conditional and not dependent on cross-compilation (off by default). 2. Fix up LIBS. 3. Allow for static linking. 4. append to ldflags instead of overwrite 5. flto=auto instead of flto diff --git a/Makefile b/Makefile index 49b1f6f..086371c 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ CONFIG_LTO=y #CONFIG_WERROR=y # force 32 bit build for some utilities #CONFIG_M32=y +#CONFIG_STATIC=y ifdef CONFIG_DARWIN # use clang instead of gcc @@ -112,11 +113,13 @@ CFLAGS_DEBUG=$(CFLAGS) -O0 CFLAGS_SMALL=$(CFLAGS) -Os CFLAGS_OPT=$(CFLAGS) -O2 CFLAGS_NOLTO:=$(CFLAGS_OPT) -LDFLAGS=-g +ifdef CONFIG_STATIC +LDFLAGS+=-static +endif ifdef CONFIG_LTO -CFLAGS_SMALL+=-flto -CFLAGS_OPT+=-flto -LDFLAGS+=-flto +CFLAGS_SMALL+=-flto=auto +CFLAGS_OPT+=-flto=auto +LDFLAGS+=-flto=auto endif ifdef CONFIG_PROFILE CFLAGS+=-p @@ -126,11 +129,11 @@ ifdef CONFIG_ASAN CFLAGS+=-fsanitize=address -fno-omit-frame-pointer LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer endif -ifdef CONFIG_WIN32 -LDEXPORT= -else +ifndef CONFIG_WIN32 +ifndef CONFIG_STATIC LDEXPORT=-rdynamic endif +endif PROGS=qjs$(EXE) qjsc$(EXE) run-test262 ifneq ($(CROSS_PREFIX),)