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

[mono] Stop exporting ICU symbols from Mono #99449

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,15 @@ if(NOT DISABLE_SHARED_LIBS)
# to avoid a conflict we rename the import library with the .import.lib suffix
set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib")
endif()
target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})
if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS})
add_linker_flag(-Wl,-L${ICU_LIBDIR})
add_linker_flag(-Wl,-hidden-licuuc)
add_linker_flag(-Wl,-hidden-licui18n)
add_linker_flag(-Wl,-hidden-licudata)
else()
target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})
endif()
if(ICU_LDFLAGS)
set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}")
endif()
Expand Down
10 changes: 9 additions & 1 deletion src/native/libs/System.Globalization.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ set(NATIVEGLOBALIZATION_SOURCES

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)
if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
add_linker_flag(-Wl,-L${CMAKE_ICU_DIR}/lib)
add_linker_flag(-Wl,-hidden-licuuc)
add_linker_flag(-Wl,-hidden-licui18n)
add_linker_flag(-Wl,-hidden-licudata)
else()
link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a)
endif()

link_libraries(stdc++)
endif()

Expand Down
11 changes: 8 additions & 3 deletions src/tasks/AppleAppBuilder/Xcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,14 @@ public string GenerateCMake(
}
else if (forceAOT || !(preferDylibs && dylibExists))
{
// these libraries are pinvoked
// -force_load will be removed once we enable direct-pinvokes for AOT
toLink += $" \"-force_load {lib}\"{Environment.NewLine}";
// do not export symbols from ICU libraries
if (libName == "libicui18n" || libName == "libicudata" || libName == "libicuuc") {
toLink += $" \"-load_hidden {lib}\"{Environment.NewLine}";
} else {
// these libraries are pinvoked
// -force_load will be removed once we enable direct-pinvokes for AOT
toLink += $" \"-force_load {lib}\"{Environment.NewLine}";
}
}
}

Expand Down
Loading