From bdeee7fc0e1c9a59fec8b81e0615c642de611531 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 19 Mar 2023 20:25:50 +0000 Subject: [PATCH] Trying mostly ineffectively to make android executables smaller. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4237 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- Makefile | 55 ++++++++++++++++++++++++++++++++----------------- src/bcrypt.js.c | 4 ++-- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index a9ca8267..63aa5eca 100644 --- a/Makefile +++ b/Makefile @@ -47,13 +47,17 @@ RELEASE_TARGETS := \ out/winrelease/tildefriends \ out/androidrelease/tildefriends \ out/androidrelease-x86_64/tildefriends +ANDROID_RELEASE_TARGETS := $(filter-out $(DEBUG_TARGETS),$(ANDROID_TARGETS)) +NONANDROID_RELEASE_TARGETS := $(filter-out $(ANDROID_ARM64_TARGETS),$(RELEASE_TARGETS)) +NONANDROID_TARGETS := $(filter-out $(ANDROID_TARGETS),$(DEBUG_TARGETS) $(RELEASE_TARGETS)) debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic $(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC $(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og -$(RELEASE_TARGETS): CFLAGS += -DNDEBUG -O3 -out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: CFLAGS += -Os +$(RELEASE_TARGETS): CFLAGS += -DNDEBUG +$(NONANDROID_RELEASE_TARGETS): CFLAGS += -O3 +$(ANDROID_RELEASE_TARGETS): CFLAGS += -Os windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32 windebug winrelease: AS = $(CC) windebug winrelease: CFLAGS += \ @@ -250,24 +254,34 @@ SQLITE_SOURCES := deps/sqlite/sqlite3.c SQLITE_OBJS := $(call get_objs,SQLITE_SOURCES) $(SQLITE_OBJS): CFLAGS += \ -DSQLITE_DBCONFIG_DEFAULT_DEFENSIVE \ + -DSQLITE_DEFAULT_MEMSTATUS=0 \ + -DSQLITE_DQS=0 \ -DSQLITE_ENABLE_FTS5 \ -DSQLITE_ENABLE_JSON1 \ - -DSQLITE_THREADSAFE=1 \ - -DSQLITE_MAX_LENGTH=5242880 \ - -DSQLITE_MAX_SQL_LENGTH=100000 \ - -DSQLITE_MAX_COLUMN=100 \ - -DSQLITE_MAX_EXPR_DEPTH=40 \ - -DSQLITE_MAX_COMPOUND_SELECT=300 \ - -DSQLITE_MAX_VDBE_OP=25000 \ - -DSQLITE_MAX_FUNCTION_ARG=8 \ -DSQLITE_MAX_ATTACHED=0 \ + -DSQLITE_MAX_COLUMN=100 \ + -DSQLITE_MAX_COMPOUND_SELECT=300 \ + -DSQLITE_MAX_EXPR_DEPTH=40 \ + -DSQLITE_MAX_FUNCTION_ARG=8 \ + -DSQLITE_MAX_LENGTH=5242880 \ -DSQLITE_MAX_LIKE_PATTERN_LENGTH=50 \ - -DSQLITE_MAX_VARIABLE_NUMBER=100 \ + -DSQLITE_MAX_SQL_LENGTH=100000 \ -DSQLITE_MAX_TRIGGER_DEPTH=10 \ + -DSQLITE_MAX_VARIABLE_NUMBER=100 \ + -DSQLITE_MAX_VDBE_OP=25000 \ + -DSQLITE_OMIT_DEPRECATED \ + -DSQLITE_OMIT_DESERIALIZE \ + -DSQLITE_OMIT_LOAD_EXTENSION \ + -DSQLITE_OMIT_TCL_VARIABLE \ -DSQLITE_SECURE_DELETE \ + -DSQLITE_THREADSAFE=0 \ + -DSQLITE_UNTESTABLE \ + -DSQLITE_USE_ALLOCA \ + -DHAVE_ISNAN \ -Wno-implicit-fallthrough \ -Wno-unused-but-set-variable \ - -Wno-unused-function + -Wno-unused-function \ + -Wno-unused-variable XOPT_SOURCES := deps/xopt/xopt.c XOPT_OBJS := $(call get_objs,XOPT_SOURCES) @@ -277,6 +291,8 @@ $(filter $(BUILD_DIR)/win%,$(XOPT_OBJS)): CFLAGS += \ -DHAVE_VASNPRINTF \ -DHAVE_VASPRINTF \ -Dvsnprintf=rpl_vsnprintf +$(XOPT_OBJS): CFLAGS += \ + -Wno-implicit-const-int-float-conversion QUICKJS_SOURCES := \ deps/quickjs/cutils.c \ @@ -289,13 +305,14 @@ QUICKJS_OBJS := $(call get_objs,QUICKJS_SOURCES) $(QUICKJS_OBJS): CFLAGS += \ -DCONFIG_VERSION=\"$(shell cat deps/quickjs/VERSION)\" \ -DCONFIG_BIGNUM \ - -DDUMP_LEAKS \ -D_GNU_SOURCE \ - -Wno-sign-compare \ + -Wno-enum-conversion \ + -Wno-implicit-const-int-float-conversion \ -Wno-implicit-fallthrough \ - -Wno-unused-variable \ + -Wno-sign-compare \ -Wno-unused-but-set-variable \ - -Wno-enum-conversion + -Wno-unused-variable +$(NONANDROID_TARGETS): CFLAGS += -DDUMP_LEAKS LIBBACKTRACE_SOURCES := \ deps/libbacktrace/atomic.c \ @@ -392,7 +409,7 @@ $(1): $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe) $(BUILD_DIR)/$(1)/$(PROJECT)$(if $(filter win%,$(1)),.exe): $(filter $(BUILD_DIR)/$(1)/%,$(ALL_APP_OBJS)) @echo [link] $$@ - @$$(CC) -o $$@ $$^ $$(LDFLAGS) + @$$(CC) -o $$@ -Wl,-Map,$$@.map $$^ $$(LDFLAGS) $(BUILD_DIR)/$(1)/%.o: %.c @mkdir -p $$(dir $$@) @@ -449,8 +466,8 @@ out/%.unsigned.apk: @echo [aapt] $@ @cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/bin/aarch64/ @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk$(BUILD_TYPE)/bin/x86_64/ - @/usr/bin/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib/llvm-strip out/apk$(BUILD_TYPE)/bin/aarch64/tildefriends - @/usr/bin/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib/llvm-strip out/apk$(BUILD_TYPE)/bin/x86_64/tildefriends + @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/aarch64/tildefriends + @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/bin/x86_64/tildefriends @cp out/apk/res.apk $@ @cp out/apk/classes.dex out/apk$(BUILD_TYPE)/ @cd out/apk$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../ diff --git a/src/bcrypt.js.c b/src/bcrypt.js.c index f2a278b9..b7d80a37 100644 --- a/src/bcrypt.js.c +++ b/src/bcrypt.js.c @@ -19,7 +19,7 @@ void tf_bcrypt_register(JSContext* context) JSValue bcrypt = JS_NewObject(context); JS_SetPropertyStr(context, global, "bCrypt", bcrypt); JS_SetPropertyStr(context, bcrypt, "hashpw", JS_NewCFunction(context, _crypt_hashpw, "hashpw", 2)); - JS_SetPropertyStr(context, bcrypt, "gensalt", JS_NewCFunction(context, _crypt_gensalt, "gensalt", 0)); + JS_SetPropertyStr(context, bcrypt, "gensalt", JS_NewCFunction(context, _crypt_gensalt, "gensalt", 1)); JS_FreeValue(context, global); } @@ -37,7 +37,7 @@ JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSVal JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) { - int length; + int length = 0; JS_ToInt32(context, &length, argv[0]); char buffer[16]; #if defined(_WIN32)