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

Add linux-musl entry for FALLBACK_HOST_RID #65339

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,16 @@ if(CLR_CMAKE_TARGET_UNIX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ANDROID>)
elseif(CLR_CMAKE_TARGET_LINUX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX>)
if(CLR_CMAKE_TARGET_LINUX_MUSL)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_LINUX_MUSL>)
endif()
elseif(CLR_CMAKE_TARGET_NETBSD)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_NETBSD>)
elseif(CLR_CMAKE_TARGET_SUNOS)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_SUNOS>)
if(CLR_CMAKE_TARGET_OS_ILLUMOS)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ILLUMOS>)
endif()
endif()
else(CLR_CMAKE_TARGET_UNIX)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WINDOWS>)
Expand Down
13 changes: 13 additions & 0 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @janvorli, @vitek-karas, I have used same detection mechanism as we have used in:

if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl ||
strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then
which was also ported to https://github.com/dotnet/install-scripts/blob/11b4eebe23d871c074364940d301c3eb53e7c7ec/src/dotnet-install.sh#L188

as fragile as it seems, it just works.

OUTPUT_VARIABLE CLR_CMAKE_LINUX_MUSL
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

if(DEFINED CLR_CMAKE_LINUX_ID)
Expand All @@ -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)

Expand Down Expand Up @@ -312,6 +321,10 @@ endif()
if(CLR_CMAKE_TARGET_OS STREQUAL Linux)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)

if(CLR_CMAKE_HOST_LINUX_MUSL)
set(CLR_CMAKE_TARGET_LINUX_MUSL 1)
endif(CLR_CMAKE_HOST_LINUX_MUSL)
endif(CLR_CMAKE_TARGET_OS STREQUAL Linux)

if(CLR_CMAKE_TARGET_OS STREQUAL tizen)
Expand Down
4 changes: 0 additions & 4 deletions src/native/corehost/hostmisc/hostmisc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/native/corehost/hostmisc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
am11 marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -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
Expand Down