From feb7c6bfe3e3b9e039bec03bab231d5459343813 Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Wed, 28 Sep 2016 14:58:52 -0600 Subject: [PATCH] build: hide layer symbols in android build Hide symbols from layers that don't need to be exported. This makes libraries smaller. It reduces symbol lookup time and call overhead. It prevents possible symbol collisions. --- build-android/jni/Android.mk | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk index 363b80e..ef793fd 100644 --- a/build-android/jni/Android.mk +++ b/build-android/jni/Android.mk @@ -25,7 +25,7 @@ LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_utils.cpp LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(SRC_DIR)/layers \ $(SRC_DIR)/loader -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -41,9 +41,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(SRC_DIR)/external/glslang \ $(SRC_DIR)/external/spirv-tools/include LOCAL_STATIC_LIBRARIES += layer_utils SPIRV-Tools-prebuilt -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -55,9 +56,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(LAYER_DIR)/include \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -69,9 +71,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(SRC_DIR)/layers \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -83,9 +86,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(LAYER_DIR)/include \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -97,9 +101,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(LAYER_DIR)/include \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -112,9 +117,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(LAYER_DIR)/include \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -126,9 +132,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ $(LAYER_DIR)/include \ $(SRC_DIR)/loader LOCAL_STATIC_LIBRARIES += layer_utils -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_SHARED_LIBRARY) # Pull in prebuilt shaderc @@ -188,9 +195,10 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ LOCAL_STATIC_LIBRARIES := googletest_main layer_utils LOCAL_SHARED_LIBRARIES += shaderc-prebuilt glslang-prebuilt OGLCompiler-prebuilt OSDependent-prebuilt HLSL-prebuilt shaderc_util-prebuilt SPIRV-prebuilt SPIRV-Tools-prebuilt -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR --include=$(SRC_DIR)/common/vulkan_wrapper.h +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden --include=$(SRC_DIR)/common/vulkan_wrapper.h LOCAL_LDLIBS := -llog LOCAL_LDFLAGS += -Wl,-Bsymbolic +LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL include $(BUILD_EXECUTABLE) # Note: The following module is similar in name to the executable, but differs so that loader won't enumerate the resulting .so @@ -210,7 +218,7 @@ LOCAL_C_INCLUDES += $(SRC_DIR)/include \ LOCAL_STATIC_LIBRARIES := googletest_main layer_utils LOCAL_SHARED_LIBRARIES += shaderc-prebuilt glslang-prebuilt OGLCompiler-prebuilt OSDependent-prebuilt HLSL-prebuilt shaderc_util-prebuilt SPIRV-prebuilt SPIRV-Tools-prebuilt -LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -DVALIDATION_APK --include=$(SRC_DIR)/common/vulkan_wrapper.h +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden -DVALIDATION_APK --include=$(SRC_DIR)/common/vulkan_wrapper.h LOCAL_WHOLE_STATIC_LIBRARIES += android_native_app_glue LOCAL_LDLIBS := -llog -landroid include $(BUILD_SHARED_LIBRARY) -- 2.7.4