Skip to content

Commit

Permalink
Move System.Globalization.Native under libraries (#875)
Browse files Browse the repository at this point in the history
- Delete Microsoft.NETCore.Native package
- Unify CMake files with the rest of libraries/native
- Fix pedantic warnings
- Comment out assert (#946)
- Delete dlclose during shutdown. It is not safe to unload any libraries that the runtime depends on.
- Install ICU for libraries build in the CI

Fixes https://github.com/dotnet/coreclr/issues/22391
  • Loading branch information
jkotas authored Dec 17, 2019
1 parent 6c91387 commit 5cc6019
Show file tree
Hide file tree
Showing 49 changed files with 141 additions and 345 deletions.
3 changes: 2 additions & 1 deletion eng/pipelines/libraries/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ jobs:

- ${{ if eq(parameters.osGroup, 'OSX') }}:
- script: |
brew install pkgconfig openssl
brew install pkgconfig icu4c openssl
brew link --force icu4c
ln -s /usr/local/opt/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/
ln -s /usr/local/opt/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/
ln -s /usr/local/opt/openssl/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ include(pgosupport.cmake)
# - project which require platform header not clr's
# - do not depend on clr's compile definitions
#-----------------------------------------
if(CLR_CMAKE_PLATFORM_UNIX AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
add_subdirectory(src/corefx)
endif()

if(CLR_CMAKE_PLATFORM_UNIX)
add_subdirectory(src/pal)
add_subdirectory(src/coreclr/hosts)
Expand Down
30 changes: 0 additions & 30 deletions src/coreclr/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -380,36 +380,6 @@ function(_install)
endif()
endfunction()

function(verify_dependencies targetName errorMessage)
set(SANITIZER_BUILD OFF)

if (CLR_CMAKE_PLATFORM_UNIX)
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL CHECKED)
string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS)
string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS)
if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1))
set(SANITIZER_BUILD ON)
endif()
endif()
endif()

# We don't need to verify dependencies on OSX, since missing dependencies
# result in link error over there.
# Also don't verify dependencies for Asan build because in this case shared
# libraries can contain undefined symbols
if (NOT CLR_CMAKE_PLATFORM_DARWIN AND NOT CLR_CMAKE_PLATFORM_ANDROID AND NOT SANITIZER_BUILD)
add_custom_command(
TARGET ${targetName}
POST_BUILD
VERBATIM
COMMAND ${CMAKE_SOURCE_DIR}/verify-so.sh
$<TARGET_FILE:${targetName}>
${errorMessage}
COMMENT "Verifying ${targetName} dependencies"
)
endif()
endfunction()

function(add_library_clr)
_add_library(${ARGV})
endfunction()
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<NativeBinary Include="$(BinDir)libdbgshim.so" />
<NativeBinary Include="$(BinDir)libmscordaccore.so" />
<NativeBinary Include="$(BinDir)libmscordbi.so" />
<NativeBinary Include="$(BinDir)System.Globalization.Native.so" />
<File Include="$(BinDir)SOS_README.md">
<TargetPath>runtimes\$(PackageTargetRuntime)\native</TargetPath>
</File>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<NativeBinary Include="$(BinDir)libdbgshim.so" />
<NativeBinary Include="$(BinDir)libmscordaccore.so" />
<NativeBinary Include="$(BinDir)libmscordbi.so" />
<NativeBinary Include="$(BinDir)System.Globalization.Native.so" />
<File Include="$(BinDir)SOS_README.md">
<TargetPath>runtimes\$(PackageTargetRuntime)\native</TargetPath>
</File>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<File Include="$(BinDir)SOS_README.md">
<TargetPath>runtimes\$(PackageTargetRuntime)\native</TargetPath>
</File>
<NativeBinary Include="$(BinDir)System.Globalization.Native.dylib" />
<CrossGenBinary Include="$(BinDir)System.Private.CoreLib.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen" />
</ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/src/.nuget/descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
"Description": "Provides support for building IL projects.",
"CommonTypes": [ ]
},
{
"Name": "Microsoft.NETCore.Native",
"Description": "Native shims for .NET Core runtime",
"CommonTypes": [ ]
},
{
"Name": "Microsoft.NETCore.Crossgen2",
"Description": "The .NET Crossgen2 compiler.",
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/src/.nuget/packages.builds
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<ItemGroup Condition="'$(__SkipNativeBuild)'==''">
<ProjectReference Include="Microsoft.NETCore.Jit\Microsoft.NETCore.Jit.builds" />
<ProjectReference Include="Microsoft.NETCore.TestHost\Microsoft.NETCore.TestHost.builds" />
<ProjectReference Include="Microsoft.NETCore.Native\Microsoft.NETCore.Native.builds" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 0 additions & 18 deletions src/coreclr/src/corefx/.clang-format

This file was deleted.

14 changes: 0 additions & 14 deletions src/coreclr/src/corefx/CMakeLists.txt

This file was deleted.

40 changes: 0 additions & 40 deletions src/coreclr/src/corefx/format-code.sh

This file was deleted.

20 changes: 0 additions & 20 deletions src/coreclr/verify-so.sh

This file was deleted.

1 change: 1 addition & 0 deletions src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ endif()
add_subdirectory(System.Native)

if (NOT CLR_CMAKE_PLATFORM_WASM)
add_subdirectory(System.Globalization.Native)
add_subdirectory(System.Net.Security.Native)
add_subdirectory(System.Security.Cryptography.Native)
endif()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
project(System.Globalization.Native C)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options(-Wno-switch-enum)
add_compile_options(-Wno-covered-switch-default)

add_definitions(-DPIC)
add_definitions(-DBIT64)
# Workaround for warnings produced by ICU headers
add_compile_options(-Wno-reserved-id-macro)
add_compile_options(-Wno-documentation)
add_compile_options(-Wno-documentation-unknown-command)

# Workaround for https://unicode-org.atlassian.net/browse/ICU-20601
add_compile_options(-Wno-extra-semi-stmt)
add_compile_options(-Wno-unknown-warning-option)

set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include")

Expand All @@ -13,26 +20,34 @@ if(UTYPES_H STREQUAL UTYPES_H-NOTFOUND)
return()
endif()

if (NOT CLR_CMAKE_PLATFORM_DARWIN)
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_library(ICUCORE icucore)
if(ICUCORE 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=\"${ICUCORE}\")
add_definitions(-DU_DISABLE_RENAMING)
else()
find_library(ICUUC icuuc)
if(ICUUC STREQUAL ICUUC-NOTFOUND)
message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)")
return()
endif()

find_library(ICUI18N icui18n)
if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)")
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=\"${ICUCORE}\")
add_custom_command(TARGET System.Globalization.Native POST_BUILD
COMMENT "Verifying System.Globalization.Native.so dependencies"
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-so.sh
$<TARGET_FILE:System.Globalization.Native>
"Verification failed. System.Globalization.Native.so has undefined dependencies. These are likely ICU APIs that need to be added to icushim.h."
VERBATIM
)
endif()

include(configure.cmake)
Expand All @@ -52,46 +67,26 @@ set(NATIVEGLOBALIZATION_SOURCES

include_directories(${UTYPES_H})

_add_library(System.Globalization.Native
add_library(System.Globalization.Native
SHARED
${NATIVEGLOBALIZATION_SOURCES}
${VERSION_FILE_PATH}
)

target_link_libraries(System.Globalization.Native
dl
)

_add_library(System.Globalization.Native_Static
install_library_and_symbols (System.Globalization.Native)

add_library(System.Globalization.Native-Static
STATIC
${NATIVEGLOBALIZATION_SOURCES}
${VERSION_FILE_PATH}
)

# Disable the "lib" prefix.
set_target_properties(System.Globalization.Native PROPERTIES PREFIX "")

# Disable the "lib" prefix and override default name
set_target_properties(System.Globalization.Native_Static PROPERTIES PREFIX "")
set_target_properties(System.Globalization.Native_Static PROPERTIES OUTPUT_NAME System.Globalization.Native)

if(NOT CLR_CMAKE_PLATFORM_DARWIN)
if (NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
target_link_libraries(System.Globalization.Native
dl
)
target_link_libraries(System.Globalization.Native_Static
dl
)
endif()
else()
target_link_libraries(System.Globalization.Native
dl
)

add_definitions(-DU_DISABLE_RENAMING)
endif()

verify_dependencies(
System.Globalization.Native
"Verification failed. System.Globalization.Native.so has undefined dependencies. These are likely ICU APIs that need to be added to icushim.h."
)
set_target_properties(System.Globalization.Native-Static PROPERTIES PREFIX "")
set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1)

# add the install targets
install_clr(TARGETS System.Globalization.Native)
install_clr(TARGETS System.Globalization.Native DESTINATION sharedFramework SKIP_STRIP)
install(TARGETS System.Globalization.Native_Static DESTINATION .)
install (TARGETS System.Globalization.Native-Static DESTINATION .)
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ CHECK_C_SOURCE_COMPILES("
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()
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CMAKE_REQUIRED_LIBRARIES ${ICUCORE})
else()
set(CMAKE_REQUIRED_LIBRARIES ${ICUUC} ${ICUI18N})
endif()

check_symbol_exists(
Expand Down
Loading

0 comments on commit 5cc6019

Please sign in to comment.