From 7a33725c3edfc75a0de0f7a0b58c5467617198bd Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Tue, 15 Feb 2022 01:36:16 +0200 Subject: [PATCH] Add linux-musl entry for FALLBACK_HOST_RID --- eng/native/configurecompiler.cmake | 6 ++++++ eng/native/configureplatform.cmake | 9 +++++++++ src/native/corehost/hostmisc/hostmisc.cmake | 4 ---- src/native/corehost/hostmisc/pal.h | 6 ++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 4324e23ed1fa2..d09f9f1353f4d 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -493,10 +493,16 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_ANDROID>) elseif(CLR_CMAKE_TARGET_LINUX) add_compile_definitions($<$>>:TARGET_LINUX>) + if(CLR_CMAKE_HOST_LINUX_MUSL) + add_compile_definitions($<$>>:TARGET_LINUX_MUSL>) + endif() elseif(CLR_CMAKE_TARGET_NETBSD) add_compile_definitions($<$>>:TARGET_NETBSD>) elseif(CLR_CMAKE_TARGET_SUNOS) add_compile_definitions($<$>>:TARGET_SUNOS>) + if(CLR_CMAKE_TARGET_OS_ILLUMOS) + add_compile_definitions($<$>>:TARGET_ILLUMOS>) + endif() endif() else(CLR_CMAKE_TARGET_UNIX) add_compile_definitions($<$>>:TARGET_WINDOWS>) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index ecf10a8d4c39e..3c23cd0e5e13b 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -70,6 +70,11 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID" OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND bash -c "if strings \"${CMAKE_SYSROOT}/usr/bin/ldd\" 2>&1 | grep -q musl; then echo musl; fi" + OUTPUT_VARIABLE CLR_CMAKE_LINUX_MUSL + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(DEFINED CLR_CMAKE_LINUX_ID) @@ -80,6 +85,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) set(CLR_CMAKE_HOST_ALPINE_LINUX 1) set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID}) endif() + + if(CLR_CMAKE_LINUX_MUSL STREQUAL musl) + set(CLR_CMAKE_HOST_LINUX_MUSL 1) + endif() endif(DEFINED CLR_CMAKE_LINUX_ID) endif(CLR_CMAKE_HOST_OS STREQUAL Linux) diff --git a/src/native/corehost/hostmisc/hostmisc.cmake b/src/native/corehost/hostmisc/hostmisc.cmake index a6237b0526c74..83233a9572ff4 100644 --- a/src/native/corehost/hostmisc/hostmisc.cmake +++ b/src/native/corehost/hostmisc/hostmisc.cmake @@ -5,10 +5,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/configure.cmake) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories("${CLR_SRC_NATIVE_DIR}") -if(CLR_CMAKE_TARGET_OS_ILLUMOS) - add_definitions(-DTARGET_ILLUMOS) -endif() - # CMake does not recommend using globbing since it messes with the freshness checks list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/trace.cpp diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index 69cf835380083..225eab59566a4 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -64,7 +64,7 @@ // degree of compat across their respective releases is usually high. // // We cannot maintain the same (compat) invariant for linux and thus, we will fallback to using lowest RID-Plaform. -#if defined(_WIN32) +#if defined(TARGET_WINDOWS) #define LIB_PREFIX #define MAKE_LIBNAME(NAME) (_X(NAME) _X(".dll")) #define FALLBACK_HOST_RID _X("win10") @@ -79,8 +79,10 @@ #define FALLBACK_HOST_RID _X("freebsd") #elif defined(TARGET_ILLUMOS) #define FALLBACK_HOST_RID _X("illumos") -#elif defined(__sun) +#elif defined(TARGET_SUNOS) #define FALLBACK_HOST_RID _X("solaris") +#elif defined(TARGET_LINUX_MUSL) +#define FALLBACK_HOST_RID _X("linux-musl") #else #define FALLBACK_HOST_RID _X("linux") #endif