Skip to content

Commit

Permalink
[native] Ensure separate debug and release .a files (#9150)
Browse files Browse the repository at this point in the history
Context: a7b5768
Context: 2ec6f54

Commit a7b5768, among other things, reorganized the way we build
our native runtime.  One of the changes was subdivision of source
code into separate subdirectories, each of them a separate static
library.  One of reasons behind it was preparation for the future
work where we will be linking the application native runtime
dynamically at application build time, mixing and matching various
libraries as necessary.

For the last reason, some of the `.a` archives are output to the
location where we store files to be packaged and distributed to end
users.  However, what a7b5768 missed was the fact that this mode
operation causes later builds to overwrite the earlier ones, since
archive names are the same.  This can cause, for instance, the
library debug build to be silently replaced with the release one.
While this won't be a problem on CI (and thus in our distribution
packages), it may have weird effects on one's local workflow (e.g.
parts of the runtime may be built for release and parts for debug,
depending on the build order).

Commit 2ec6f54 added a partial solution to this issue, but one
that covered only the UBSAN and ASAN scenarios and ignored the debug
vs release ones.

Complete the fix started by 2ec6f54 by by making all output
libraries use the `-debug` or `-release` prefix.

Also, libxamarin-native-tracing is not a static library, don't
mistakenly treat it as one.
  • Loading branch information
grendello authored Jul 29, 2024
1 parent 16cdbb0 commit c157aed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ elseif(ENABLE_CLANG_UBSAN)
set(STATIC_LIB_NAME_SUFFIX "-ubsan")
endif()

if(DEBUG_BUILD)
set(STATIC_LIB_NAME_SUFFIX "${STATIC_LIB_NAME_SUFFIX}-debug")
else()
set(STATIC_LIB_NAME_SUFFIX "${STATIC_LIB_NAME_SUFFIX}-release")
endif()

if(USE_CCACHE)
if(CMAKE_CXX_COMPILER MATCHES "/ccache/")
message(STATUS "ccache: compiler already uses ccache")
Expand Down
2 changes: 0 additions & 2 deletions src/native/tracing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ add_library(

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

set_static_library_suffix(${LIB_NAME})

target_include_directories(
${LIB_NAME}
PUBLIC
Expand Down

0 comments on commit c157aed

Please sign in to comment.