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

Hardcode path to ICU on macOS #39833

Merged
merged 1 commit into from
Jul 23, 2020
Merged

Conversation

akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Jul 23, 2020

For some reason the path ends up being /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libicucore.tbd instead of the expected /usr/lib/libicucore.dylib recently on the build machines.

Fixes https://github.com/dotnet/core-eng/issues/10304


EDIT:

To sum up the findings, this is because of the recent cmake upgrade to 3.18 that got pushed to brew with Homebrew/homebrew-core@7927380.

A build that ran 8hours ago (presumably with cmake 3.17.2) still got the expected /usr/lib/libicucore.dylib, a build from 4hours ago got the Xcode path.

@ghost
Copy link

ghost commented Jul 23, 2020

Tagging subscribers to this area: @tarekgh, @safern, @krwq
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

Thanks 👍 👍 👍

@@ -28,7 +28,7 @@ if(CLR_CMAKE_TARGET_UNIX)
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(-DOSX_ICU_LIBRARY_PATH=\"/usr/lib/libicucore.dylib\")
Copy link
Member

Choose a reason for hiding this comment

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

nit: does setting CMAKE_FIND_LIBRARY_SUFFIXES=.dylib before the introspection line above (find_library) and unsetting it after the introspection works? That will save us using the hard-coded path.

Copy link
Member

Choose a reason for hiding this comment

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

e.g.

if(CMAKE_STATIC_LIB_LINK)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif(CMAKE_STATIC_LIB_LINK)

Copy link
Member

Choose a reason for hiding this comment

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

let's do that in a follow-up PR to unblock CI.

Copy link
Member Author

Choose a reason for hiding this comment

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

it might, but I see no reason why we should not use the hardcoded path since that is where ICU will always be on macOS.

Copy link
Member

Choose a reason for hiding this comment

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

That defeats the purpose of using find_library (the call above). :)

Copy link
Member

Choose a reason for hiding this comment

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

Is CMAKE_REQUIRED_LIBRARIES setting to libicucore.tbd considered ok? maybe we need to change that as well; .tbd is a metadata (YAML) file.

Even better, if we could avoid introducing more hardcoded paths using set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib), it will at least keep it consistent with other usages of find_* macros (under platform conditions or platform specific cmake files), IMHO. e.g. in theory, someone can build libicu locally on macOS (for experiments) and have it installed in other place present in PATH.

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't seem to be needed though, will send a PR to remove it ;)

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this is what you're discussing here, but from https://gitlab.kitware.com/cmake/cmake/-/issues/21007

The .tbd files in the SDK are the preferred way to link to system libraries on macOS. This is in preparation for macOS 11 where the /usr/lib/*.dylib files do not even exist on disk.

Is it correct that /usr/lib/libicucore.dylib does not exist on Big Sur? If so will this change break there?

cc @ViktorHofer

Copy link
Member

Choose a reason for hiding this comment

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

If this doesn't exist in Big Sur I will hit it soon as I will be fixing: #39583

So if that's the case I will also fix this to work on Big Sur.

Copy link
Member Author

Choose a reason for hiding this comment

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

@danmosemsft @safern I commented on the cmake gitlab issue, but copying here:

I checked on a macOS 11 system and the file is indeed not on disk but you can apparently still load it via dlopen() so we should still be able to use it.

They probably do some tricks in the dynamic loader to allow loading libicucore.dylib even though it doesn't exist at that location on disk. We don't know whether Apple will keep that or remove at some later point though.

@ViktorHofer ViktorHofer merged commit 05f17e3 into dotnet:master Jul 23, 2020
@akoeplinger akoeplinger deleted the hardcode-icu branch July 23, 2020 12:15
@akoeplinger
Copy link
Member Author

To sum up the findings, we're 99% sure this is because of the recent cmake upgrade to 3.18 that got pushed to brew with Homebrew/homebrew-core@7927380.

A build that ran 8hours ago (presumably with cmake 3.17.2) still got the expected /usr/lib/libicucore.dylib, a build from 4hours ago got the Xcode path.

ViktorHofer pushed a commit to ViktorHofer/runtime that referenced this pull request Jul 23, 2020
ViktorHofer added a commit that referenced this pull request Jul 23, 2020
@akoeplinger
Copy link
Member Author

Filed an issue with CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/21007

@tarekgh tarekgh mentioned this pull request Jul 23, 2020
akoeplinger added a commit to akoeplinger/runtime that referenced this pull request Jul 24, 2020
… config

Follow-up to dotnet#39833.

We don't link against ICU on macOS but load it via `dlopen()` at runtime and compilation uses headers from homebrew.
That means `HAVE_SET_MAX_VARIABLE` and `HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS` will always be defined and we don't need the ICUCORE variable.
akoeplinger added a commit that referenced this pull request Jul 24, 2020
… config (#39900)

Follow-up to #39833.

We don't link against ICU on macOS but load it via `dlopen()` at runtime and compilation uses headers from homebrew.
That means `HAVE_SET_MAX_VARIABLE` and `HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS` will always be defined and we don't need the ICUCORE variable.

* PR feedback

Co-authored-by: Adeel Mujahid <[email protected]>
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
… config (dotnet#39900)

Follow-up to dotnet#39833.

We don't link against ICU on macOS but load it via `dlopen()` at runtime and compilation uses headers from homebrew.
That means `HAVE_SET_MAX_VARIABLE` and `HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS` will always be defined and we don't need the ICUCORE variable.

* PR feedback

Co-authored-by: Adeel Mujahid <[email protected]>
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants