diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index fc11001aa76c82..d8f61472abb77b 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -44,7 +44,7 @@ elseif(TARGET_ARCH_NAME STREQUAL "x86") set(TOOLCHAIN "i686-linux-gnu") elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") set(CMAKE_SYSTEM_PROCESSOR "x86_64") - set(triple "x86_64-unknown-freebsd11") + set(triple "x86_64-unknown-freebsd12") elseif (ILLUMOS) set(CMAKE_SYSTEM_PROCESSOR "x86_64") set(TOOLCHAIN "x86_64-illumos") @@ -90,6 +90,9 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") set(CMAKE_C_COMPILER_TARGET ${triple}) set(CMAKE_CXX_COMPILER_TARGET ${triple}) set(CMAKE_ASM_COMPILER_TARGET ${triple}) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld") set(CMAKE_SYSROOT "${CROSS_ROOTFS}") elseif(ILLUMOS) set(CMAKE_SYSROOT "${CROSS_ROOTFS}") diff --git a/eng/common/native/find-native-compiler.sh b/eng/common/native/find-native-compiler.sh index aed19d07d506ff..861d1931e55e31 100644 --- a/eng/common/native/find-native-compiler.sh +++ b/eng/common/native/find-native-compiler.sh @@ -55,7 +55,7 @@ if [ -z "$CLR_CC" ]; then # Set default versions if [ -z "$majorVersion" ]; then # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. - if [ "$compiler" = "clang" ]; then versions=( 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) + if [ "$compiler" = "clang" ]; then versions=( 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) elif [ "$compiler" = "gcc" ]; then versions=( 9 8 7 6 5 4.9 ); fi for version in "${versions[@]}"; do diff --git a/eng/native/init-compiler.sh b/eng/native/init-compiler.sh index 567d18da4747a1..c6a94f6f939e2a 100755 --- a/eng/native/init-compiler.sh +++ b/eng/native/init-compiler.sh @@ -46,7 +46,7 @@ if [[ -z "$CLR_CC" ]]; then # Set default versions if [[ -z "$majorVersion" ]]; then # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. - if [[ "$compiler" == "clang" ]]; then versions=( 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) + if [[ "$compiler" == "clang" ]]; then versions=( 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) elif [[ "$compiler" == "gcc" ]]; then versions=( 11 10 9 8 7 6 5 4.9 ); fi for version in "${versions[@]}"; do diff --git a/eng/pipelines/common/platform-matrix.yml b/eng/pipelines/common/platform-matrix.yml index 15fe948e92967e..bc8803b8487085 100644 --- a/eng/pipelines/common/platform-matrix.yml +++ b/eng/pipelines/common/platform-matrix.yml @@ -262,7 +262,7 @@ jobs: targetRid: freebsd-x64 platform: FreeBSD_x64 container: - image: ubuntu-18.04-cross-freebsd-11-20200407092345-a84b0d2 + image: ubuntu-18.04-cross-freebsd-12-20210813173449-f13d79e registry: mcr jobParameters: runtimeFlavor: ${{ parameters.runtimeFlavor }} diff --git a/src/libraries/Native/Unix/System.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Native/extra_libs.cmake index 74efbf803ae0f2..2edc74bde7aaff 100644 --- a/src/libraries/Native/Unix/System.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Native/extra_libs.cmake @@ -4,7 +4,7 @@ macro(append_extra_system_libs NativeLibsExtra) list(APPEND ${NativeLibsExtra} rt) elseif (CLR_CMAKE_TARGET_FREEBSD) list(APPEND ${NativeLibsExtra} pthread) - find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) + find_library(INOTIFY_LIBRARY inotify HINTS ${CROSS_ROOTFS}/usr/local/lib) list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY}) elseif (CLR_CMAKE_TARGET_SUNOS) list(APPEND ${NativeLibsExtra} socket) diff --git a/src/libraries/Native/Unix/configure.cmake b/src/libraries/Native/Unix/configure.cmake index 18afacc2dbc59c..e35f5ddbb3db99 100644 --- a/src/libraries/Native/Unix/configure.cmake +++ b/src/libraries/Native/Unix/configure.cmake @@ -982,7 +982,7 @@ set (CMAKE_REQUIRED_FLAGS ${PREVIOUS_CMAKE_REQUIRED_FLAGS}) set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) if (HAVE_SYS_INOTIFY_H AND CLR_CMAKE_TARGET_FREEBSD) - set (CMAKE_REQUIRED_LIBRARIES "-linotify -L/usr/local/lib") + set (CMAKE_REQUIRED_LIBRARIES "-linotify -L${CROSS_ROOTFS}/usr/local/lib") endif() check_symbol_exists( diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 16c5ca6dfc89ce..a7038121e37daa 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -252,6 +252,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS") set(HOST_SOLARIS 1) add_definitions(-DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DHOST_SOLARIS -D__EXTENSIONS__ -D_XPG4_2) +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(HOST_FREEBSD 1) else() message(FATAL_ERROR "Host '${CMAKE_SYSTEM_NAME}' not supported.") endif() @@ -292,6 +294,8 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "Windows") set(TARGET_WIN32 1) elseif(TARGET_SYSTEM_NAME STREQUAL "SunOS") set(TARGET_SOLARIS 1) +elseif(TARGET_SYSTEM_NAME STREQUAL "FreeBSD") + set(TARGET_FREEBSD 1) else() message(FATAL_ERROR "Target '${TARGET_SYSTEM_NAME}' not supported.") endif() @@ -320,7 +324,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" OR CMAKE_SYSTEM_PROCESSOR STREQUAL set(CMAKE_SYSTEM_PROCESSOR "x86") elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") set(CMAKE_SYSTEM_PROCESSOR "arm64") -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x64") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x64") set(CMAKE_SYSTEM_PROCESSOR "x86_64") endif() @@ -594,6 +598,12 @@ elseif(HOST_WIN32) elseif(HOST_SOLARIS) set(ICU_FLAGS "-DPALEXPORT=\"\" -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) +elseif(TARGET_FREEBSD) + set(ICU_FLAGS "-DTARGET_UNIX -Wno-deprecated-declarations") + set(HAVE_SYS_ICU 1) + set(ICU_LIBS icuuc icui18n) + set(ICU_INCLUDEDIR "${CROSS_ROOTFS}/usr/local/include") + set(ICU_LIBDIR "${CROSS_ROOTFS}/usr/local/lib") else() message(FATAL_ERROR "Unknown host") endif() diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index b3d3f47c894e0b..438e71783cc817 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -175,3 +175,9 @@ if(HOST_SOLARIS) set(HAVE_NETINET_TCP_H 1) set(HAVE_GETADDRINFO 1) endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + # FreeBSD fails earlier ac_check_headers for these because is needed. + set(HAVE_SYS_SYSCTL_H 1) + set(HAVE_SYS_USER_H 1) +endif() diff --git a/src/mono/cmake/eglib-config.h.cmake.in b/src/mono/cmake/eglib-config.h.cmake.in index 9f1394e134b53e..ac061852d61dd5 100644 --- a/src/mono/cmake/eglib-config.h.cmake.in +++ b/src/mono/cmake/eglib-config.h.cmake.in @@ -33,7 +33,7 @@ #else -#if @HAVE_ALLOCA_H@ == 1 +#ifdef HAVE_ALLOCA_H #define G_HAVE_ALLOCA_H #endif diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e66bee5a2c6ec2..bbcb229db1b990 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -243,6 +243,12 @@ <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/usr/lib/s390x-linux-gnu/pkgconfig" /> + + + <_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$([MSBuild]::NormalizePath('$(RepositoryEngineeringDir)', 'common', 'cross', 'toolchain.cmake'))" /> + <_MonoBuildEnv Include="TARGET_BUILD_ARCH=x64" /> + + <_MonoCPPFLAGS Include="-DWIN32" /> diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 3e9ca497336abf..bec48adfacc0e5 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -35,6 +35,8 @@ elseif(HOST_WIN32) set(OS_LIBS bcrypt.lib Mswsock.lib ws2_32.lib psapi.lib version.lib advapi32.lib winmm.lib kernel32.lib) elseif(HOST_SOLARIS) set(OS_LIBS socket pthread m ${CMAKE_DL_LIBS}) +elseif(HOST_FREEBSD) + set(OS_LIBS pthread m) endif() # @@ -254,7 +256,7 @@ set(posix_sources if(HOST_DARWIN) set(os_sources "${darwin_sources};${posix_sources}") -elseif(HOST_LINUX OR HOST_SOLARIS) +elseif(HOST_LINUX OR HOST_SOLARIS OR HOST_FREEBSD) set(os_sources "${posix_sources}") elseif(HOST_WIN32) set(os_sources "${windows_sources}")