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 support for FreeBSD cross-compilation #34000

Merged
merged 16 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion docs/workflow/building/libraries/freebsd-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tested on plain FreeBSD 11.3 Azure image
## Prerequisites
This needs to be done once on fresh system.

```sudo pkg install cmake git icu libunwind bash python2 krb5 lttng-ust llvm60 libgit2```
```sudo pkg install cmake git icu libunwind bash python2 krb5 lttng-ust llvm90 libgit2 libinotify openssl```

some scripts may still assume /bin/bash exists. To workaround it for now do of needed:
```
Expand Down
2 changes: 1 addition & 1 deletion eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if(CLR_CMAKE_HOST_LINUX)
endif(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_FREEBSD)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
add_link_options(-fuse-ld=lld LINKER:--build-id=sha1)
add_link_options(LINKER:--build-id=sha1)
endif(CLR_CMAKE_HOST_FREEBSD)

#------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ if(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
set(CLR_CMAKE_HOST_FREEBSD 1)

if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL Linux)
set(CLR_CMAKE_HOST_OS Linux)
set(CLR_CMAKE_TARGET_OS FreeBSD)
endif()
endif(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)

if(CLR_CMAKE_HOST_OS STREQUAL OpenBSD)
Expand Down Expand Up @@ -315,10 +320,10 @@ if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
endif()
endif()
else()
if(NOT (CLR_CMAKE_HOST_OS STREQUAL Windows_NT))
if(NOT (CLR_CMAKE_HOST_OS STREQUAL Windows_NT) AND NOT (CLR_CMAKE_HOST_OS STREQUAL Linux AND CLR_CMAKE_TARGET_OS STREQUAL FreeBSD))
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
endif()
if(NOT (CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_ALPINE_LINUX))
if(NOT (CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_ALPINE_LINUX OR CLR_CMAKE_TARGET_FREEBSD))
message(FATAL_ERROR "Invalid host and target os/arch combination. Target OS: ${CLR_CMAKE_TARGET_OS}")
endif()
if(NOT ((CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM)))
Expand Down
15 changes: 5 additions & 10 deletions eng/native/init-distro-rid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
# If -portablebuild=false is passed a non-portable rid will be created for any
# distro.
#
# Below is the list of current non-portable platforms.
#
# Builds from the following *must* be non-portable:
#
# | OS | Expected RID |
# -------------------------------------------------
# | freeBSD | freebsd.(version)-x64 |
#
# It is important to note that the function does not return anything, but it
# exports __DistroRid, if there is a non-portable distro rid to be used.
#
Expand Down Expand Up @@ -70,8 +62,11 @@ initNonPortableDistroRid()
fi

if [ "$targetOs" = "FreeBSD" ]; then
__freebsd_major_version=$(freebsd-version | { read v; echo "${v%%.*}"; })
nonPortableBuildID="freebsd.$__freebsd_major_version-${buildArch}"
if (( isPortable == 0 )); then
# $rootfsDir can be empty. freebsd-version is shell script and it should always work.
__freebsd_major_version=$($rootfsDir/bin/freebsd-version | { read v; echo "${v%%.*}"; })
nonPortableBuildID="freebsd.$__freebsd_major_version-${buildArch}"
fi
fi

if [ -n "${nonPortableBuildID}" ]; then
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ItemGroup>
<_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" />
<_CoreClrBuildArg Include="-$(Configuration.ToLower())" />
<_CoreClrBuildArg Condition="'$(TargetOS)' != '' and '$(TargetOS)' != '$(HostOS)'" Include="-os $(TargetOS) " />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/crossgen-corelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ __UnprocessedBuildArgs=

source "$__ProjectRoot"/_build-commons.sh

if [[ "${__BuildArch}" != "${__HostArch}" ]]; then
if [[ "${__BuildArch}" != "${__HostArch}" ]] || [[ "$__HostOS" != "$__TargetOS" ]]; then
__CrossBuild=1
fi

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<_CoreClrBuildArg Include="$(Compiler)" />
<_CoreClrBuildArg Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="-ci" />
<_CoreClrBuildArg Condition="'$(CrossBuild)' == 'true'" Include="-cross" />
<_CoreClrBuildArg Condition="'$(TargetOS)' != ''" Include="-os $(TargetOS) " />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'x64') and '$(Configuration)' == 'Release'" Include="-enforcepgo" />
<_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(Configuration)' == 'Release'" Include="-stripsymbols" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" />
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
add_subdirectory(debug/dbgutil)

if(CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID AND NOT CLR_CMAKE_TARGET_FREEBSD)
add_subdirectory(debug/createdump)
endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID)
endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID AND NOT CLR_CMAKE_TARGET_FREEBSD)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these


# Include the dummy c++ include files
include_directories("pal/inc/rt/cpp")
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ else(CLR_CMAKE_HOST_WIN32)
# Add dependency on export file
add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE})

if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD)
if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_TARGET_FREEBSD)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD)
endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_TARGET_FREEBSD)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these


if(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)

# Generate DAC export file with the DAC_ prefix
generate_exports_file_prefix(${DEF_SOURCES} ${EXPORTS_FILE} DAC_)
Expand Down Expand Up @@ -70,7 +70,7 @@ 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_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)
endif(CLR_CMAKE_HOST_WIN32)

if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD)
Expand Down Expand Up @@ -104,9 +104,9 @@ add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $<TARGET_OBJECTS:mscordac

set_target_properties(mscordacobj mscordaccore PROPERTIES DAC_COMPONENT TRUE)

if(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)
add_dependencies(mscordaccore lib_redefines_inc)
endif(CLR_CMAKE_HOST_LINUX)
endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)

if(CLR_CMAKE_HOST_UNIX)
add_dependencies(mscordaccore mscordaccore_exports)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/src/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ set(MSCORDBI_SOURCES
)

# Add the DAC PAL export mapping file
if(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)
list(APPEND MSCORDBI_SOURCES ${PAL_REDEFINES_FILE})
endif(CLR_CMAKE_HOST_LINUX)
endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)

if(CLR_CMAKE_TARGET_WIN32)
add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll)
Expand Down Expand Up @@ -111,9 +111,9 @@ elseif(CLR_CMAKE_HOST_UNIX)

add_dependencies(mscordbi mscordaccore)

if(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)
add_dependencies(mscordbi pal_redefines_file)
endif(CLR_CMAKE_HOST_LINUX)
endif(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_TARGET_FREEBSD)

endif(CLR_CMAKE_HOST_WIN32)

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/src/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD)

if(NOT DEFINED ENV{ROOTFS_DIR})
include_directories(SYSTEM /usr/local/include)
elseif (CLR_CMAKE_TARGET_FREEBSD)
include_directories(SYSTEM $ENV{ROOTFS_DIR}/usr/local/include)
endif()

if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(CheckTypeSize)
include(CheckLibraryExists)

if(CLR_CMAKE_TARGET_FREEBSD)
set(CMAKE_REQUIRED_INCLUDES /usr/local/include)
set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
elseif(CLR_CMAKE_TARGET_SUNOS)
set(CMAKE_REQUIRED_INCLUDES /opt/local/include)
endif()
Expand Down
25 changes: 13 additions & 12 deletions src/coreclr/src/pal/src/libunwind/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,8 @@ SET(libunwind_la_SOURCES_os_freebsd_local
# Nothing
)

if(CLR_CMAKE_HOST_LINUX)
SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_linux})
SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_linux_local})
SET(libunwind_la_SOURCES_x86_os x86/Gos-linux.c)
SET(libunwind_x86_la_SOURCES_os x86/getcontext-linux.S)
SET(libunwind_la_SOURCES_x86_os_local x86/Los-linux.c)
SET(libunwind_la_SOURCES_x86_64_os x86_64/Gos-linux.c)
SET(libunwind_la_SOURCES_x86_64_os_local x86_64/Los-linux.c)
SET(libunwind_la_SOURCES_arm_os arm/Gos-linux.c)
SET(libunwind_la_SOURCES_arm_os_local arm/Los-linux.c)
list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_linux.c)
elseif(CLR_CMAKE_HOST_FREEBSD)

if(CLR_CMAKE_HOST_FREEBSD OR ${CLR_CMAKE_TARGET_OS} STREQUAL "FreeBSD")
SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_freebsd})
SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_freebsd_local})
SET(libunwind_la_SOURCES_x86_os x86/Gos-freebsd.c)
Expand All @@ -137,6 +127,17 @@ elseif(CLR_CMAKE_HOST_FREEBSD)
SET(libunwind_la_SOURCES_arm_os arm/Gos-freebsd.c)
SET(libunwind_la_SOURCES_arm_os_local arm/Los-freebsd.c)
list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_freebsd.c)
elseif(CLR_CMAKE_HOST_LINUX)
SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_linux})
SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_linux_local})
SET(libunwind_la_SOURCES_x86_os x86/Gos-linux.c)
SET(libunwind_x86_la_SOURCES_os x86/getcontext-linux.S)
SET(libunwind_la_SOURCES_x86_os_local x86/Los-linux.c)
SET(libunwind_la_SOURCES_x86_64_os x86_64/Gos-linux.c)
SET(libunwind_la_SOURCES_x86_64_os_local x86_64/Los-linux.c)
SET(libunwind_la_SOURCES_arm_os arm/Gos-linux.c)
SET(libunwind_la_SOURCES_arm_os_local arm/Los-linux.c)
list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_linux.c)
endif()

# List of arch-independent files needed by both local-only and generic
Expand Down
20 changes: 19 additions & 1 deletion src/coreclr/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
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()
endif()

if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$")
if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD)
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)
Expand Down Expand Up @@ -57,6 +64,17 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$")
set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0)
endif()

#
if (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(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)
endif()
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!")
endif()
Expand Down
1 change: 1 addition & 0 deletions src/installer/corehost/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<BuildArgs Condition="'$(Compiler)' != ''">$(BuildArgs) $(Compiler)</BuildArgs>
<BuildArgs Condition="'$(CMakeArgs)' != ''">$(BuildArgs) $(CMakeArgs)</BuildArgs>
<BuildArgs Condition="'$(StripSymbols)' == 'true'">$(BuildArgs) -stripsymbols</BuildArgs>
<BuildArgs Condition="'$(TargetOS)' == 'FreeBSD'">$(BuildArgs) -os FreeBSD</BuildArgs>
</PropertyGroup>

<!--
Expand Down
1 change: 0 additions & 1 deletion src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ endif ()

if(CLR_CMAKE_TARGET_FREEBSD)
add_definitions(-D_BSD_SOURCE) # required for getline
add_link_options(-fuse-ld=lld)
endif(CLR_CMAKE_TARGET_FREEBSD)

# CLR_ADDITIONAL_LINKER_FLAGS - used for passing additional arguments to linker
Expand Down
7 changes: 4 additions & 3 deletions src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ elseif (CLR_CMAKE_TARGET_IOS)
set(PAL_UNIX_NAME \"IOS\")
elseif (CLR_CMAKE_TARGET_FREEBSD)
set(PAL_UNIX_NAME \"FREEBSD\")
include_directories(SYSTEM /usr/local/include)
set(CMAKE_REQUIRED_INCLUDES /usr/local/include)
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/local/include)
set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
elseif (CLR_CMAKE_TARGET_NETBSD)
set(PAL_UNIX_NAME \"NETBSD\")
elseif (CLR_CMAKE_TARGET_ARCH_WASM)
Expand Down Expand Up @@ -729,11 +729,12 @@ check_symbol_exists(
if(CLR_CMAKE_TARGET_IOS)
set(HAVE_IOS_NET_ROUTE_H 1)
set(NET_ROUTE_H_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/System.Native/ios/net/route.h")
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h ${NET_ROUTE_H_INCLUDE})
else()
set(NET_ROUTE_H_INCLUDE net/route.h)
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h net/if.h ${NET_ROUTE_H_INCLUDE})
endif()

set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h ${NET_ROUTE_H_INCLUDE})
check_type_size(
"struct rt_msghdr"
HAVE_RT_MSGHDR
Expand Down
16 changes: 15 additions & 1 deletion src/libraries/Native/Unix/tryrun.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
Copy link
Member

Choose a reason for hiding this comment

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

isn't this already set by eng/common/cross/toolchain.cmake ?

Copy link
Member Author

Choose a reason for hiding this comment

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

That does not seems to be set soon enough and build fails. src/coreclr/tryrun.cmake has same line.


macro(set_cache_value)
set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
Expand All @@ -9,11 +10,19 @@ if(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()
endif()

if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$")
if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD)
set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)

Expand All @@ -22,6 +31,11 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$")
else()
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0)
endif()
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)
endif()
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!")
endif()