-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[mono][NativeAOT] System.Globalization.Native build improvements #82393
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
Changes from all commits
e9805a2
9092d1c
e78a32d
c83a2dc
628cb70
3689be7
2edeebd
5ec149f
3156ff7
556fc43
a92c289
a202612
ccfd1e1
122c1fa
67b0a6e
560e08f
a57c67e
8371518
fa9b2ff
5d0700a
8e07a43
80cc2dc
3c823b8
42ae535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ target_link_libraries(dotnet | |
| ${MONO_ARTIFACTS_DIR}/libmono-profiler-browser.a | ||
| ${NATIVE_BIN_DIR}/wasm-bundled-timezones.a | ||
| ${NATIVE_BIN_DIR}/libSystem.Native.a | ||
| ${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must admit I don't understand big picture. Could you please explain the consequences of this for browser ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of building the ICU shim as part of the Mono runtime build, it moves the build to libs.native part of the build. Then it links the resulting static library back. The end result should be roughly identical to the previous status quo. There are several reasons for this change:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /cc @steveisok LibraryBuilder targets should also be aware of this change (although I suspect it doesn't matter to the library builder where the static lib came from, as long as it's there)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what I can see the LibraryBuilder doesn't need updating since it just takes all *.a files |
||
| ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a) | ||
|
|
||
| set_target_properties(dotnet PROPERTIES | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,21 @@ | ||
| project(System.Globalization.Native C) | ||
|
|
||
| if(CLR_CMAKE_TARGET_UNIX) | ||
| if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) | ||
akoeplinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| add_compile_options(-Wno-switch-enum) | ||
| add_compile_options(-Wno-covered-switch-default) | ||
|
|
||
| # 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) | ||
| add_compile_options(-Wno-reserved-identifier) | ||
filipnavara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Workaround for https://unicode-org.atlassian.net/browse/ICU-20601 | ||
| add_compile_options(-Wno-extra-semi-stmt) | ||
| add_compile_options(-Wno-unknown-warning-option) | ||
|
|
||
| if (NOT CLR_CMAKE_TARGET_ANDROID) | ||
| if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) | ||
| if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) | ||
| if (CLR_CMAKE_TARGET_OSX) | ||
| execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") | ||
| endif() | ||
|
|
@@ -25,7 +26,7 @@ if(CLR_CMAKE_TARGET_UNIX) | |
| return() | ||
| endif() | ||
|
|
||
| if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) | ||
| if(CLR_CMAKE_TARGET_OSX) | ||
| add_definitions(-DOSX_ICU_LIBRARY_PATH="/usr/lib/libicucore.dylib") | ||
| add_definitions(-DU_DISABLE_RENAMING) | ||
| else() | ||
|
|
@@ -59,6 +60,17 @@ set(NATIVEGLOBALIZATION_SOURCES | |
| pal_normalization.c | ||
| ) | ||
|
|
||
| if (DEFINED CMAKE_ICU_DIR) | ||
| include_directories(${CMAKE_ICU_DIR}/include) | ||
| link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) | ||
| link_libraries(stdc++) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious why did we not have to do this in mono?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It always happens somewhere, either at linking the runtime as dynamic library, or as part of the final linking of the application. In this particular case we happen to build .dylib for iOS which may not be strictly necessary. Since the project is marked as using the "C" language and not "CXX" the C++ standard library is not included implicitly. We can exclude the .dylib builds for iOS-like platforms as an alternative (but that will exclude all the dylib builds of native libs, so there could be some unforeseen consequences).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'm mostly worried about Android where we can't introduce this stdc++ dependency. For Android we're loading ICU .so via dlopen from the system location so we just need to make sure this doesn't apply for Android. I'd probably move the two
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Android you will end up linking to the libmono*.so that has the ICU shim built-in. This PR doesn't affect that. We do build an additional libSystem.Globalization.Native.[a/so] and it likely is not necessary. While not necessary for the supported configurations, it is nice to have for the unsupported NativeAOT/Android builds. |
||
| endif() | ||
|
|
||
| if (CMAKE_USE_PTHREADS) | ||
| add_compile_options(-pthread) | ||
| add_linker_flag(-pthread) | ||
| endif() | ||
|
|
||
| if (LOCAL_BUILD) | ||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
| set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) | ||
|
|
@@ -69,6 +81,9 @@ if (LOCAL_BUILD) | |
| # For minipal files | ||
| include_directories(../../) | ||
| include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
| elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) | ||
| add_definitions(-DSTATIC_ICU) | ||
| set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) | ||
| else() | ||
| set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim.c) | ||
| endif() | ||
|
|
@@ -82,10 +97,6 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) | |
| set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) | ||
| endif() | ||
|
|
||
| if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) | ||
| set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} entrypoints.c) | ||
| endif() | ||
|
|
||
| if (MSVC) | ||
| set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) | ||
| endif() | ||
|
|
@@ -116,9 +127,10 @@ endif() | |
| add_library(System.Globalization.Native-Static | ||
| STATIC | ||
| ${NATIVEGLOBALIZATION_SOURCES} | ||
| entrypoints.c | ||
| ) | ||
|
|
||
| if(CLR_CMAKE_TARGET_UNIX) | ||
| if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) | ||
| set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1) | ||
| endif() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #pragma once | ||
|
|
||
| #cmakedefine01 HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS | ||
| #cmakedefine01 HAVE_SET_MAX_VARIABLE | ||
| #cmakedefine01 HAVE_SET_MAX_VARIABLE | ||
| #cmakedefine01 HAVE_UCOL_CLONE |
Uh oh!
There was an error while loading. Please reload this page.