Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native] Change name of static libraries in some cases #9135

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ endif()
option(ENABLE_CLANG_ASAN "Enable the clang AddressSanitizer support" OFF)
option(ENABLE_CLANG_UBSAN "Enable the clang UndefinedBehaviorSanitizer support" OFF)

if(ENABLE_CLANG_ASAN AND ENABLE_CLANG_UBSAN)
message(FATAL_ERROR "Both ASAN and UBSAN builds cannot be enabled at the same time")
endif()

if(ENABLE_CLANG_ASAN OR ENABLE_CLANG_UBSAN)
set(STRIP_DEBUG_DEFAULT OFF)
set(ANALYZERS_ENABLED ON)
Expand All @@ -80,6 +84,12 @@ option(DISABLE_DEBUG "Disable the built-in debugging code" OFF)
option(USE_CCACHE "Use ccache, if found, to speed up recompilation" ON)
option(DONT_INLINE "Do not inline any functions which are usually inlined, to get better stack traces" ${DONT_INLINE_DEFAULT})

if(ENABLE_CLANG_ASAN)
set(STATIC_LIB_NAME_SUFFIX "-asan")
elseif(ENABLE_CLANG_UBSAN)
set(STATIC_LIB_NAME_SUFFIX "-ubsan")
endif()

if(USE_CCACHE)
if(CMAKE_CXX_COMPILER MATCHES "/ccache/")
message(STATUS "ccache: compiler already uses ccache")
Expand Down Expand Up @@ -441,6 +451,19 @@ add_compile_options("$<$<COMPILE_LANGUAGE:C>:${COMMON_C_ARGS}>")
add_link_options("$<$<COMPILE_LANGUAGE:CXX>:${COMMON_CXX_LINKER_ARGS}>")
add_link_options("$<$<COMPILE_LANGUAGE:C>:${COMMON_C_LINKER_ARGS}>")

#
# Helper macros
#
macro(set_static_library_suffix TARGET_NAME)
if(STATIC_LIB_NAME_SUFFIX)
set_target_properties(
${TARGET_NAME}
PROPERTIES
SUFFIX "${STATIC_LIB_NAME_SUFFIX}.a"
)
endif()
endmacro()

add_subdirectory(libunwind)
add_subdirectory(lz4)
add_subdirectory(libstub)
Expand Down
2 changes: 2 additions & 0 deletions src/native/java-interop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ add_library(

add_library(${LIB_ALIAS} ALIAS ${LIB_NAME})

set_static_library_suffix(${LIB_NAME})

target_include_directories(
${LIB_NAME}
PUBLIC
Expand Down
3 changes: 2 additions & 1 deletion src/native/monodroid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(DEBUG_BUILD)
set(CMAKE_C_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG})
elseif(NOT ANALYZERS_ENABLED)
set(BUILD_STATIC_LIBRARY ON)
set(BUILD_STATIC_LIBRARY OFF) # Turn off for now, until we implement dynamic runtime linking at app build time
endif()

# Library directories
Expand Down Expand Up @@ -101,6 +101,7 @@ if(BUILD_STATIC_LIBRARY)
STATIC
${XAMARIN_MONODROID_SOURCES}
)
set_static_library_suffix(${XAMARIN_MONO_ANDROID_STATIC_LIB})
endif()

macro(lib_target_options TARGET_NAME)
Expand Down
2 changes: 2 additions & 0 deletions src/native/pinvoke-override/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ macro(create_library _libname _alias _sources)

add_library(${_alias} ALIAS ${_libname})

set_static_library_suffix(${_libname})

target_compile_definitions(
${_libname}
PRIVATE
Expand Down
2 changes: 2 additions & 0 deletions src/native/runtime-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ add_library(

add_library(${LIB_ALIAS} ALIAS ${LIB_NAME})

set_static_library_suffix(${LIB_NAME})

target_compile_options(
${LIB_NAME}
PRIVATE
Expand Down
4 changes: 4 additions & 0 deletions src/native/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ add_library(
)
add_library(${LIB_ALIAS} ALIAS ${LIB_NAME})

set_static_library_suffix(${LIB_NAME})

add_library(
${LIB_NAME_NO_ABI}
STATIC
${XA_SHARED_SOURCES}
)
add_library(${LIB_ALIAS_NO_ABI} ALIAS ${LIB_NAME_NO_ABI})

set_static_library_suffix(${LIB_NAME_NO_ABI})

macro(lib_target_options TARGET_NAME)
target_include_directories(
${TARGET_NAME}
Expand Down
2 changes: 2 additions & 0 deletions src/native/tracing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ add_library(

add_library(${LIB_ALIAS} ALIAS ${LIB_NAME})

set_static_library_suffix(${LIB_NAME})

target_include_directories(
${LIB_NAME}
PUBLIC
Expand Down
Loading