aports/community/quickjs/00-makefile.patch
2024-02-14 18:14:21 +00:00

55 lines
1.3 KiB
Diff

Source: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
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_WERROR=y
# force 32 bit build for some utilities
#CONFIG_M32=y
+#CONFIG_STATIC=y
# cosmopolitan build (see https://github.com/jart/cosmopolitan)
#CONFIG_COSMO=y
@@ -126,13 +127,14 @@
CFLAGS_NOLTO:=$(CFLAGS_OPT)
ifdef CONFIG_COSMO
LDFLAGS+=-s # better to strip by default
-else
-LDFLAGS+=-g
endif
+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
@@ -142,10 +144,10 @@
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
ifndef CONFIG_COSMO