From 43ae9afecb6f8307afe91d73bff7435176beef56 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid Date: Fri, 19 Jun 2020 15:50:20 +0300 Subject: [PATCH] Add support for illumos cross-compilation (#37753) --- .gitignore | 10 +++-- eng/native/configurecompiler.cmake | 14 +++++++ eng/native/configureplatform.cmake | 8 ++-- eng/native/configuretools.cmake | 7 ++-- eng/native/functions.cmake | 14 +++++++ src/coreclr/src/dlls/dbgshim/CMakeLists.txt | 23 ++++------- src/coreclr/src/dlls/mscordac/CMakeLists.txt | 44 ++++++++------------ src/coreclr/src/dlls/mscordbi/CMakeLists.txt | 26 ++++-------- .../src/dlls/mscoree/coreclr/CMakeLists.txt | 10 +---- src/coreclr/src/ilasm/CMakeLists.txt | 8 +--- src/coreclr/src/ildasm/exe/CMakeLists.txt | 8 +--- src/coreclr/src/jit/CMakeLists.txt | 9 +---- src/coreclr/src/pal/tests/palsuite/CMakeLists.txt | 1 + .../pal_sxs/test1/CMakeLists.txt | 15 ++----- src/coreclr/tryrun.cmake | 47 +++++++++++++++------- src/installer/corehost/CMakeLists.txt | 2 +- src/installer/corehost/build.sh | 3 +- .../corehost/cli/fxr/standalone/CMakeLists.txt | 15 +------ .../cli/hostpolicy/standalone/CMakeLists.txt | 15 +------ src/installer/corehost/tryrun.cmake | 28 +++++++++++++ src/libraries/Native/Unix/tryrun.cmake | 29 +++++++------ .../System.Data.Odbc/src/System.Data.Odbc.csproj | 6 +-- 22 files changed, 165 insertions(+), 177 deletions(-) create mode 100644 src/installer/corehost/tryrun.cmake diff --git a/.gitignore b/.gitignore index 88165cf..bfe14ad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,12 @@ syntax: glob ### VisualStudio ### # Tool Runtime Dir -.dotnet/ -.dotnet-mono/ -.packages/ -.tools/ +# note: there is no trailing slash so if these are symlinks (which are seen as files, +# instead of directories), git will still ignore them. +.dotnet +.dotnet-mono +.packages +.tools # User-specific files *.suo diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index a6e6ba4..a6537bb 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -577,4 +577,18 @@ else (CLR_CMAKE_HOST_WIN32) if (AWK STREQUAL "AWK-NOTFOUND") message(FATAL_ERROR "AWK not found") endif() + + # detect linker + set(ldVersion ${CMAKE_C_COMPILER};-Wl,--version) + execute_process(COMMAND ${ldVersion} + ERROR_QUIET + OUTPUT_VARIABLE ldVersionOutput) + + if("${ldVersionOutput}" MATCHES "GNU ld" OR "${ldVersionOutput}" MATCHES "GNU gold") + set(LD_GNU 1) + elseif("${ldVersionOutput}" MATCHES "Solaris Link") + set(LD_SOLARIS 1) + else(CLR_CMAKE_HOST_OSX) + set(LD_OSX 1) + endif() endif(CLR_CMAKE_HOST_WIN32) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index bbc7877..8c4ddff 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -152,7 +152,7 @@ if(CLR_CMAKE_HOST_OS STREQUAL SunOS) COMMAND isainfo -n OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET) - if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64") + if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64" OR CMAKE_CROSSCOMPILING) set(CLR_CMAKE_HOST_UNIX_AMD64 1) set(CMAKE_SYSTEM_PROCESSOR "amd64") else() @@ -165,11 +165,11 @@ if(CLR_CMAKE_HOST_OS STREQUAL SunOS) ERROR_QUIET) set(CLR_CMAKE_HOST_SUNOS 1) - if(SUNOS_KERNEL_KIND STREQUAL illumos) + if(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING) set(CLR_CMAKE_HOST_OS_ILLUMOS 1) - else(SUNOS_KERNEL_KIND STREQUAL illumos) + else(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING) set(CLR_CMAKE_HOST_OS_SOLARIS 1) - endif(SUNOS_KERNEL_KIND STREQUAL illumos) + endif(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING) endif(CLR_CMAKE_HOST_OS STREQUAL SunOS) if(CLR_CMAKE_HOST_OS STREQUAL Windows) diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index 4fb9453..0edbe2e 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -34,17 +34,18 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) "${TOOLSET_PREFIX}${exec}") if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") - message(FATAL_ERROR "Unable to find toolchain executable for: ${exec}.") + message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.") endif() set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endfunction() locate_toolchain_exec(ar CMAKE_AR) - locate_toolchain_exec(link CMAKE_LINKER) locate_toolchain_exec(nm CMAKE_NM) - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + if(CMAKE_C_COMPILER_ID MATCHES "GNU") locate_toolchain_exec(ranlib CMAKE_RANLIB) + else() + locate_toolchain_exec(link CMAKE_LINKER) endif() if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS)) diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 49b0064..4479072 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -162,6 +162,20 @@ function(preprocess_compile_asm) set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE) endfunction() +function(set_exports_linker_option exports_filename) + if(LD_GNU OR LD_SOLARIS) + # Add linker exports file option + if(LD_SOLARIS) + set(EXPORTS_LINKER_OPTION -Wl,-M,${exports_filename} PARENT_SCOPE) + else() + set(EXPORTS_LINKER_OPTION -Wl,--version-script=${exports_filename} PARENT_SCOPE) + endif() + elseif(LD_OSX) + # Add linker exports file option + set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${exports_filename} PARENT_SCOPE) + endif() +endfunction() + function(generate_exports_file) set(INPUT_LIST ${ARGN}) list(GET INPUT_LIST -1 outputFilename) diff --git a/src/coreclr/src/dlls/dbgshim/CMakeLists.txt b/src/coreclr/src/dlls/dbgshim/CMakeLists.txt index ef2d0e3..54cedfe 100644 --- a/src/coreclr/src/dlls/dbgshim/CMakeLists.txt +++ b/src/coreclr/src/dlls/dbgshim/CMakeLists.txt @@ -24,25 +24,16 @@ else(CLR_CMAKE_TARGET_WIN32) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dbgshim_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) -endif(CLR_CMAKE_TARGET_WIN32) -if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - # This option is necessary to ensure that the overloaded delete operator defined inside - # of the utilcode will be used instead of the standard library delete operator. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + # This option is necessary to ensure that the overloaded delete operator defined inside + # of the utilcode will be used instead of the standard library delete operator. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - # Add linker exports file option - if(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - else(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_SUNOS) -endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + set_exports_linker_option(${EXPORTS_FILE}) -if(CLR_CMAKE_HOST_OSX) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) -endif(CLR_CMAKE_HOST_OSX) +endif(CLR_CMAKE_TARGET_WIN32) add_library_clr(dbgshim SHARED ${DBGSHIM_SOURCES}) diff --git a/src/coreclr/src/dlls/mscordac/CMakeLists.txt b/src/coreclr/src/dlls/mscordac/CMakeLists.txt index c32c8d1..94b61b5 100644 --- a/src/coreclr/src/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordac/CMakeLists.txt @@ -71,34 +71,24 @@ else(CLR_CMAKE_HOST_WIN32) # Add lib redefines file to DAC list(APPEND CLR_DAC_SOURCES libredefines.S) endif(CLR_CMAKE_HOST_LINUX) -endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - # This option is necessary to ensure that the overloaded delete operator defined inside - # of the utilcode will be used instead of the standard library delete operator. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") - - # The following linked options can be inserted into the linker libraries list to - # ensure proper resolving of circular references between a subset of the libraries. - set(START_LIBRARY_GROUP -Wl,--start-group) - set(END_LIBRARY_GROUP -Wl,--end-group) - - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -Wl,--whole-archive) - set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) - - # Add linker exports file option - if(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - else(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_SUNOS) -endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - -if(CLR_CMAKE_HOST_OSX) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) -endif(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + # This option is necessary to ensure that the overloaded delete operator defined inside + # of the utilcode will be used instead of the standard library delete operator. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + + # The following linked options can be inserted into the linker libraries list to + # ensure proper resolving of circular references between a subset of the libraries. + set(START_LIBRARY_GROUP -Wl,--start-group) + set(END_LIBRARY_GROUP -Wl,--end-group) + + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -Wl,--whole-archive) + set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + + set_exports_linker_option(${EXPORTS_FILE}) +endif(CLR_CMAKE_HOST_WIN32) # Create object library to enable creation of proper dependency of mscordaccore.exp on mscordac.obj and # mscordaccore on both the mscordaccore.exp and mscordac.obj. diff --git a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt index 39561e1..b87b3ea 100644 --- a/src/coreclr/src/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscordbi/CMakeLists.txt @@ -39,25 +39,15 @@ else(CLR_CMAKE_HOST_WIN32) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordbi_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) -endif(CLR_CMAKE_HOST_WIN32) -if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - # This option is necessary to ensure that the overloaded new/delete operators defined inside - # of the utilcode will be used instead of the standard library delete operator. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") - - # Add linker exports file option - if(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - else(CLR_CMAKE_HOST_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_SUNOS) -endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) - -if(CLR_CMAKE_HOST_OSX) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) -endif(CLR_CMAKE_HOST_OSX) + if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + # This option is necessary to ensure that the overloaded new/delete operators defined inside + # of the utilcode will be used instead of the standard library delete operator. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") + endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS) + + set_exports_linker_option(${EXPORTS_FILE}) +endif(CLR_CMAKE_HOST_WIN32) add_library_clr(mscordbi SHARED ${MSCORDBI_SOURCES}) target_precompile_header(TARGET mscordbi HEADER stdafx.h) diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index 32fb9e2..c676198 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -42,22 +42,16 @@ else(CLR_CMAKE_HOST_WIN32) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -Wl,--whole-archive) set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) - - if(CLR_CMAKE_TARGET_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - elseif(CLR_CMAKE_TARGET_SUNOS) - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_TARGET_SUNOS) endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) if(CLR_CMAKE_TARGET_OSX) # These options are used to force every object to be included even if it's unused. set(START_WHOLE_ARCHIVE -force_load) set(END_WHOLE_ARCHIVE ) - - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_OSX) + set_exports_linker_option(${EXPORTS_FILE}) + if(CLR_CMAKE_TARGET_ANDROID AND CLR_CMAKE_HOST_ARCH_ARM) set(EXPORTS_LINKER_OPTION "${EXPORTS_LINKER_OPTION} -Wl,--no-warn-shared-textrel") endif(CLR_CMAKE_TARGET_ANDROID AND CLR_CMAKE_HOST_ARCH_ARM) diff --git a/src/coreclr/src/ilasm/CMakeLists.txt b/src/coreclr/src/ilasm/CMakeLists.txt index 0036ed4..ae54195 100644 --- a/src/coreclr/src/ilasm/CMakeLists.txt +++ b/src/coreclr/src/ilasm/CMakeLists.txt @@ -113,14 +113,8 @@ if(CLR_CMAKE_HOST_UNIX) mscorrc coreclrpal palrt + ${CMAKE_DL_LIBS} ) - - # FreeBSD and NetBSD implement dlopen(3) in libc - if(NOT CLR_CMAKE_TARGET_FREEBSD AND NOT CLR_CMAKE_TARGET_NETBSD) - target_link_libraries(ilasm - dl - ) - endif(NOT CLR_CMAKE_TARGET_FREEBSD AND NOT CLR_CMAKE_TARGET_NETBSD) else() target_link_libraries(ilasm ${ILASM_LINK_LIBRARIES} diff --git a/src/coreclr/src/ildasm/exe/CMakeLists.txt b/src/coreclr/src/ildasm/exe/CMakeLists.txt index 47531eb..fe0892f 100644 --- a/src/coreclr/src/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/src/ildasm/exe/CMakeLists.txt @@ -104,14 +104,8 @@ if(CLR_CMAKE_HOST_UNIX) mscorrc coreclrpal palrt + ${CMAKE_DL_LIBS} ) - - # FreeBSD and NetBSD implement dlopen(3) in libc - if(NOT CLR_CMAKE_TARGET_FREEBSD AND NOT CLR_CMAKE_TARGET_NETBSD) - target_link_libraries(ildasm - dl - ) - endif(NOT CLR_CMAKE_TARGET_FREEBSD AND NOT CLR_CMAKE_TARGET_NETBSD) else() target_link_libraries(ildasm ${ILDASM_LINK_LIBRARIES} diff --git a/src/coreclr/src/jit/CMakeLists.txt b/src/coreclr/src/jit/CMakeLists.txt index a3f0b1a..85d3565 100644 --- a/src/coreclr/src/jit/CMakeLists.txt +++ b/src/coreclr/src/jit/CMakeLists.txt @@ -321,16 +321,9 @@ else() if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) # This is required to force using our own PAL, not one that we are loaded with. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") - - if(CLR_CMAKE_TARGET_SUNOS) - set(JIT_EXPORTS_LINKER_OPTION -Wl,-M,${JIT_EXPORTS_FILE}) - else(CLR_CMAKE_TARGET_SUNOS) - set(JIT_EXPORTS_LINKER_OPTION -Wl,--version-script=${JIT_EXPORTS_FILE}) - endif(CLR_CMAKE_TARGET_SUNOS) - elseif(CLR_CMAKE_TARGET_OSX) - set(JIT_EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${JIT_EXPORTS_FILE}) endif() + set_exports_linker_option(${JIT_EXPORTS_FILE}) set(SHARED_LIB_SOURCES ${SOURCES}) endif() diff --git a/src/coreclr/src/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/src/pal/tests/palsuite/CMakeLists.txt index 902f125..091da03 100644 --- a/src/coreclr/src/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/src/pal/tests/palsuite/CMakeLists.txt @@ -20,6 +20,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-narrowing) + add_compile_options(-fno-builtin) add_compile_options($<$:-fpermissive>) add_compile_options(-Wno-int-to-pointer-cast) endif() diff --git a/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt index 2d2d037..0db9b28 100644 --- a/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ b/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt @@ -18,18 +18,9 @@ convert_to_absolute_path(DEF_SOURCES1 ${DEF_SOURCES1}) set(EXPORTS_FILE1 ${CMAKE_CURRENT_BINARY_DIR}/dlltest1.exports) generate_exports_file(${DEF_SOURCES1} ${EXPORTS_FILE1}) -if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD) - set(EXPORTS_LINKER_OPTION1 -Wl,--version-script=${EXPORTS_FILE1}) -endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD) - -if(CLR_CMAKE_TARGET_OSX) - set(EXPORTS_LINKER_OPTION1 -Wl,-exported_symbols_list,${EXPORTS_FILE1}) -endif(CLR_CMAKE_TARGET_OSX) - -if(CLR_CMAKE_TARGET_SUNOS) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) -endif(CLR_CMAKE_TARGET_SUNOS) +if(CLR_CMAKE_HOST_UNIX) + set_exports_linker_option(${EXPORTS_FILE}) +endif(CLR_CMAKE_HOST_UNIX) set(DLL1SOURCES dlltest1.cpp) add_library(paltest_pal_sxs_test1_dll1 SHARED ${DLL1SOURCES}) diff --git a/src/coreclr/tryrun.cmake b/src/coreclr/tryrun.cmake index 5fdc28a..fdd9154 100644 --- a/src/coreclr/tryrun.cmake +++ b/src/coreclr/tryrun.cmake @@ -6,22 +6,21 @@ macro(set_cache_value) set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) endmacro() -if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR +if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR + EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) - - SET(ALPINE_LINUX 1) -else() - SET(ALPINE_LINUX 0) - if(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) - set(FREEBSD 1) - set(CMAKE_SYSTEM_NAME FreeBSD) - set(CLR_CMAKE_TARGET_OS FreeBSD) - else() - SET(FREEBSD 0) - endif() + + set(ALPINE_LINUX 1) +elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) + set(FREEBSD 1) + set(CMAKE_SYSTEM_NAME FreeBSD) + set(CLR_CMAKE_TARGET_OS FreeBSD) +elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) + set(ILLUMOS 1) + set(CLR_CMAKE_TARGET_OS SunOS) endif() -if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD) +if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1) set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0) set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0) @@ -68,11 +67,31 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD) set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1) set_cache_value(HAVE_PROCFS_MAPS 0) set_cache_value(HAVE_PROCFS_STAT 0) - set_cache_value(HAVE_PROCFS_STATUS 0) + set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 0) set_cache_value(GETPWUID_R_SETS_ERRNO 0) set_cache_value(UNGETC_NOT_RETURN_EOF 0) set_cache_value(HAVE_COMPATIBLE_ILOGBNAN 1) set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) + elseif(ILLUMOS) + set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0) + set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 1) + set_cache_value(HAVE_LARGE_SNPRINTF_SUPPORT_EXITCODE 1) + set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1) + set_cache_value(HAVE_PROCFS_STATUS_EXITCODE 1) + set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 1) + set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1) + set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1) + set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0) + set_cache_value(COMPILER_SUPPORTS_W_CLASS_MEMACCESS 1) + set_cache_value(HAVE_SET_MAX_VARIABLE 1) + set_cache_value(HAVE_FULLY_FEATURED_PTHREAD_MUTEXES 1) + set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) endif() else() message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!") diff --git a/src/installer/corehost/CMakeLists.txt b/src/installer/corehost/CMakeLists.txt index 2343e3a..651a63b 100644 --- a/src/installer/corehost/CMakeLists.txt +++ b/src/installer/corehost/CMakeLists.txt @@ -12,7 +12,7 @@ if(MSVC) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. - add_compile_options(-fno-use-cxa-atexit) + add_compile_options($<$:-fno-use-cxa-atexit>) endif() add_subdirectory(cli) diff --git a/src/installer/corehost/build.sh b/src/installer/corehost/build.sh index 7be41fa..2153c58 100755 --- a/src/installer/corehost/build.sh +++ b/src/installer/corehost/build.sh @@ -98,5 +98,4 @@ setup_dirs check_prereqs # Build the installer native components. -# note the third argument, tryrun_dir is empty for installers -build_native "$__BuildArch" "$__scriptpath" "" "$__IntermediatesDir" "installer component" +build_native "$__BuildArch" "$__scriptpath" "$__scriptpath" "$__IntermediatesDir" "installer component" diff --git a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt index 0a2ea92..1a2147c 100644 --- a/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt +++ b/src/installer/corehost/cli/fxr/standalone/CMakeLists.txt @@ -35,20 +35,7 @@ else(CLR_CMAKE_TARGET_WIN32) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostfxr.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) - if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) - - if(CLR_CMAKE_HOST_OSX) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_OSX) - - if(CLR_CMAKE_HOST_SUNOS) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_SUNOS) + set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) include(../../lib.cmake) diff --git a/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt b/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt index d663154..88fe378 100644 --- a/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt +++ b/src/installer/corehost/cli/hostpolicy/standalone/CMakeLists.txt @@ -29,20 +29,7 @@ else(CLR_CMAKE_TARGET_WIN32) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostpolicy.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) - if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD) - - if(CLR_CMAKE_HOST_OSX) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_OSX) - - if(CLR_CMAKE_HOST_SUNOS) - # Add linker exports file option - set(EXPORTS_LINKER_OPTION -Wl,-M,${EXPORTS_FILE}) - endif(CLR_CMAKE_HOST_SUNOS) + set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) include(../../lib.cmake) diff --git a/src/installer/corehost/tryrun.cmake b/src/installer/corehost/tryrun.cmake new file mode 100644 index 0000000..eba94ae --- /dev/null +++ b/src/installer/corehost/tryrun.cmake @@ -0,0 +1,28 @@ +set(CROSS_ROOTFS $ENV{ROOTFS_DIR}) +set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH}) + +macro(set_cache_value) + set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE) + set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) +endmacro() + +if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR + EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR + EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) + + set(ALPINE_LINUX 1) +elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) + set(FREEBSD 1) + set(CMAKE_SYSTEM_NAME FreeBSD) + set(CLR_CMAKE_TARGET_OS FreeBSD) +elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) + set(ILLUMOS 1) +endif() + +if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) + if(ILLUMOS) + set_cache_value(COMPILER_SUPPORTS_W_CLASS_MEMACCESS 0) + endif() +else() + message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!") +endif() diff --git a/src/libraries/Native/Unix/tryrun.cmake b/src/libraries/Native/Unix/tryrun.cmake index a1d7384..84b727f 100644 --- a/src/libraries/Native/Unix/tryrun.cmake +++ b/src/libraries/Native/Unix/tryrun.cmake @@ -6,23 +6,21 @@ macro(set_cache_value) set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) endmacro() -if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR +if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR + EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) - - SET(ALPINE_LINUX 1) - SET(FREEBSD 0) -else() - SET(ALPINE_LINUX 0) - if(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) - set(FREEBSD 1) - set(CMAKE_SYSTEM_NAME FreeBSD) - set(CLR_CMAKE_TARGET_OS FreeBSD) - else() - SET(FREEBSD 0) - endif() + + set(ALPINE_LINUX 1) +elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) + set(FREEBSD 1) + set(CMAKE_SYSTEM_NAME FreeBSD) + set(CLR_CMAKE_TARGET_OS FreeBSD) +elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) + set(ILLUMOS 1) + set(CLR_CMAKE_TARGET_OS SunOS) endif() -if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD) +if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) @@ -31,7 +29,8 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD) else() set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0) endif() - if (FREEBSD) + + if(FREEBSD) set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1) set_cache_value(HAVE_CLOCK_MONOTONIC 1) set_cache_value(HAVE_CLOCK_REALTIME 1) diff --git a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj index b05b0d2..c3eed38 100644 --- a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj +++ b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj @@ -2,7 +2,7 @@ $(NoWarn);CA2249 true - $(NetCoreAppCurrent)-Windows_NT;netcoreapp2.0-FreeBSD;netcoreapp2.0-Linux;netcoreapp2.0-OSX;netcoreapp2.0-Windows_NT;net461-Windows_NT;netstandard2.0;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetFrameworkCurrent)-Windows_NT + $(NetCoreAppCurrent)-Windows_NT;netcoreapp2.0-FreeBSD;netcoreapp2.0-Linux;netcoreapp2.0-OSX;netcoreapp2.0-Windows_NT;net461-Windows_NT;netstandard2.0;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetFrameworkCurrent)-Windows_NT true true @@ -109,7 +109,7 @@ - + @@ -169,4 +169,4 @@ - \ No newline at end of file + -- 2.7.4