Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix System.Globalization.Native build on Big Sur (#28181)
Browse files Browse the repository at this point in the history
* Fix System.Globalization.Native build on Big Sur

* Fix build

* Add flags for Linux
  • Loading branch information
safern authored Jun 15, 2021
1 parent 3d4e15b commit 53cff17
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
7 changes: 3 additions & 4 deletions configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ elseif (CLR_CMAKE_PLATFORM_UNIX)
# This linker option causes executables we build to be marked as containing
# position independent code.
# It is necessary to make ASLR work for executables.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -Wl,-z,relro,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")

endif(WIN32)

Expand All @@ -359,8 +358,8 @@ endif(CLR_CMAKE_PLATFORM_UNIX)

if(CLR_CMAKE_PLATFORM_LINUX)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1 -Wl,-z,relro,-z,now")
endif(CLR_CMAKE_PLATFORM_LINUX)
if(CLR_CMAKE_PLATFORM_FREEBSD)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
Expand Down
8 changes: 1 addition & 7 deletions src/corefx/System.Globalization.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ if (NOT CLR_CMAKE_PLATFORM_DARWIN)
return()
endif()
else()
find_library(ICUCORE icucore)
if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
return()
endif()

add_definitions(-DOSX_ICU_LIBRARY_PATH=\"/usr/lib/libicucore.dylib\")
add_definitions(-DOSX_ICU_LIBRARY_PATH="/usr/lib/libicucore.dylib")
endif()

include(configure.cmake)
Expand Down
35 changes: 18 additions & 17 deletions src/corefx/System.Globalization.Native/configure.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
include(CheckCSourceCompiles)
include(CheckSymbolExists)
if (CLR_CMAKE_PLATFORM_DARWIN)
set(HAVE_SET_MAX_VARIABLE 1)
set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1)
else()
include(CheckCSourceCompiles)
include(CheckSymbolExists)

set(CMAKE_REQUIRED_INCLUDES ${UTYPES_H} ${ICU_HOMEBREW_INC_PATH})
set(CMAKE_REQUIRED_INCLUDES ${UTYPES_H} ${ICU_HOMEBREW_INC_PATH})

CHECK_C_SOURCE_COMPILES("
#include <unicode/udat.h>
int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
CHECK_C_SOURCE_COMPILES("
#include <unicode/udat.h>
int main(void) { enum UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)

if(NOT CLR_CMAKE_PLATFORM_DARWIN)
set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N})
else()
set(CMAKE_REQUIRED_LIBRARIES ${ICUCORE})
endif()

check_symbol_exists(
ucol_setMaxVariable
"unicode/ucol.h"
HAVE_SET_MAX_VARIABLE)
check_symbol_exists(
ucol_setMaxVariable
"unicode/ucol.h"
HAVE_SET_MAX_VARIABLE)

unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
Expand Down

0 comments on commit 53cff17

Please sign in to comment.