From 2dbb812126e8d4992567deb04b75a739c1937604 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 1 Sep 2023 23:04:11 -0700 Subject: [PATCH] Disable stack protector on x86 static executables Close #7274 --- native/src/base/Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/native/src/base/Android.mk b/native/src/base/Android.mk index ad3bd9b56..ab46e2092 100644 --- a/native/src/base/Android.mk +++ b/native/src/base/Android.mk @@ -34,4 +34,9 @@ LOCAL_SRC_FILES := compat/compat.cpp # Fix static variables' ctor/dtor when using LTO # See: https://github.com/android/ndk/issues/1461 LOCAL_EXPORT_LDFLAGS := -static -T src/lto_fix.lds +# For some reason, using the hacky libc.a with x86 will trigger stack protection violation +# when mixing Rust and C++ code. Disable stack protector to bypass this issue. +ifeq ($(TARGET_ARCH), x86) +LOCAL_EXPORT_CFLAGS := -fno-stack-protector +endif include $(BUILD_STATIC_LIBRARY)