Build debug with thin lto

This commit is contained in:
topjohnwu
2024-07-31 16:57:30 -07:00
parent 46a34e19bc
commit 606d076251
5 changed files with 68 additions and 41 deletions

View File

@@ -1,7 +1,6 @@
APP_BUILD_SCRIPT := src/Android.mk
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 riscv64
APP_CFLAGS := -Wall -Oz -fomit-frame-pointer -flto
APP_LDFLAGS := -flto -Wl,--icf=all
APP_CFLAGS := -Wall -Oz -fomit-frame-pointer
APP_CPPFLAGS := -std=c++23
APP_STL := none
APP_PLATFORM := android-23
@@ -9,11 +8,25 @@ APP_THIN_ARCHIVE := true
APP_STRIP_MODE := none
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
ifdef MAGISK_DEBUG
NDK_APP_OUT := ./obj/debug
APP_CFLAGS += -flto=thin -gdwarf-4
APP_LDFLAGS += -flto=thin
else
NDK_APP_OUT := ./obj/release
APP_CFLAGS += -flto
APP_LDFLAGS += -flto -Wl,--icf=all
endif
ifdef B_CRT0
# Disable all security and debugging features
APP_CFLAGS += -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-stack-protector -U_FORTIFY_SOURCE
# Override output folder to make sure all dependencies are rebuilt with new CFLAGS
NDK_APP_OUT := ./obj/nolibc
NDK_APP_OUT := $(NDK_APP_OUT)-nolibc
endif

View File

@@ -58,7 +58,7 @@ rev = "809df65b20d61e88afb7f514b5cfdd3d1958a40f"
[profile.dev]
opt-level = "z"
lto = true
lto = "thin"
panic = "abort"
[profile.release]

View File

@@ -7,8 +7,16 @@
using namespace std;
#ifdef USE_CRT0
__asm__(".global vfprintf \n vfprintf = musl_vfprintf");
__asm__(".global vsscanf \n vsscanf = tfp_vsscanf");
__BEGIN_DECLS
int tfp_vsscanf(const char *s, const char *fmt, va_list args);
int vsscanf(const char *s, const char *fmt, va_list args) {
return tfp_vsscanf(s, fmt, args);
}
int musl_vfprintf(FILE *stream, const char *format, va_list arg);
int vfprintf(FILE *stream, const char *format, va_list arg) {
return musl_vfprintf(stream, format, arg);
}
__END_DECLS
#endif
static void print_formats() {

View File

@@ -12,7 +12,12 @@
using namespace std;
#ifdef USE_CRT0
__asm__(".global vfprintf \n vfprintf = tfp_vfprintf");
__BEGIN_DECLS
int tfp_vfprintf(FILE *stream, const char *format, va_list arg);
int vfprintf(FILE *stream, const char *format, va_list arg) {
return tfp_vfprintf(stream, format, arg);
}
__END_DECLS
#endif
bool unxz(out_stream &strm, rust::Slice<const uint8_t> bytes) {