Skip to content

Commit

Permalink
Fix Alpine Linux mono build and coreclr pgo support (#90251)
Browse files Browse the repository at this point in the history
#86804 renamed `CLR_CMAKE_HOST_ALPINE_LINUX` to `CLR_CMAKE_TARGET_LINUX_MUSL`. This PR applies the name change to missing files, fixing build of mono-based runtime and coreclr pgosupport on Alpine Linux.

Co-authored-by: Alexander Köplinger <[email protected]>
  • Loading branch information
ayakael and akoeplinger authored Nov 20, 2023
1 parent 5fa2080 commit 740ecd0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ function(add_pgo TargetName)
target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-generate)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fprofile-instr-generate")
if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CLR_CMAKE_HOST_ALPINE_LINUX)
if (CLR_CMAKE_TARGET_LINUX_MUSL)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -resource-dir ${CMAKE_SYSROOT}/usr/lib/clang/${CMAKE_C_COMPILER_VERSION}")
else(CLR_CMAKE_HOST_ALPINE_LINUX)
else(CLR_CMAKE_TARGET_LINUX_MUSL)
string(REPLACE "." ";" CLANG_VERSION "${CMAKE_C_COMPILER_VERSION}")
list(POP_FRONT CLANG_VERSION CLANG_VERSION_MAJOR)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -resource-dir ${CMAKE_SYSROOT}/usr/lib/llvm-${CLANG_VERSION_MAJOR}/lib/clang/${CMAKE_C_COMPILER_VERSION}")
endif(CLR_CMAKE_HOST_ALPINE_LINUX)
endif(CLR_CMAKE_TARGET_LINUX_MUSL)
endif(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang")
if(NOT LD_LLVM)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -fuse-ld=gold")
Expand Down
6 changes: 3 additions & 3 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,10 @@ set(FULL_VERSION ${product_version_string})
# OS SPECIFIC CHECKS
######################################

if(CLR_CMAKE_HOST_ALPINE_LINUX)
# Setting RLIMIT_NOFILE breaks debugging of coreclr on Alpine Linux for some reason
if(CLR_CMAKE_TARGET_LINUX_MUSL)
# Setting RLIMIT_NOFILE breaks debugging of coreclr on musl-libc for some reason
add_definitions(-DDONT_SET_RLIMIT_NOFILE)
# On Alpine Linux, we need to ensure that the reported stack range for the primary thread is
# On musl-libc, we need to ensure that the reported stack range for the primary thread is
# larger than the initial committed stack size.
add_definitions(-DENSURE_PRIMARY_STACK_SIZE)
endif()
Expand Down
12 changes: 6 additions & 6 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ if(NOT DISABLE_SHARED_LIBS)
add_library(monosgen-shared SHARED $<TARGET_OBJECTS:monosgen-objects>)
endif()
target_compile_definitions(monosgen-shared PRIVATE -DMONO_DLL_EXPORT)
# Alpine Linux implements ucontext in a different library
if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
# musl-libc implements ucontext in a different library on s390x
if(CLR_CMAKE_TARGET_LINUX_MUSL AND TARGET_S390X)
target_link_libraries(monosgen-shared PRIVATE ucontext)
endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
endif(CLR_CMAKE_TARGET_LINUX_MUSL AND TARGET_S390X)
set_target_properties(monosgen-shared PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME})
if(MONO_SET_RPATH_ORIGIN)
set_target_properties(monosgen-shared PROPERTIES INSTALL_RPATH "$ORIGIN")
Expand Down Expand Up @@ -610,10 +610,10 @@ if(NOT DISABLE_EXECUTABLES)
target_link_libraries(mono-sgen PRIVATE icu_shim_objects)
endif()
target_link_libraries(mono-sgen PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})
# Alpine Linux implements ucontext in a different library
if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
# musl-libc implements ucontext in a different library on s390x
if(CLR_CMAKE_TARGET_LINUX_MUSL AND TARGET_S390X)
target_link_libraries(mono-sgen PRIVATE ucontext)
endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
endif(CLR_CMAKE_TARGET_LINUX_MUSL AND TARGET_S390X)
if(NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS AND NOT DISABLE_LINK_STATIC_COMPONENTS)
# if components are built statically, link them into runtime.
target_sources(mono-sgen PRIVATE "${mono-components-objects}")
Expand Down

0 comments on commit 740ecd0

Please sign in to comment.