-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Simplify build on macOS #35570
Simplify build on macOS #35570
Conversation
Tagging subscribers to this area: @ViktorHofer |
* Check for OpenSSL (and pkg-config) in the check_prereqs() function * Simplify OpenSSL installation instructions * Automatically pick the OpenSSL version installed by Homebrew by exporting the proper PKG_CONFIG_PATH environment variable * Improve the error message if cmake can't find OpenSSL The previous instructions were asking the user to add symbolic links inside /usr/local/lib/ and /usr/local/lib/pkgconfig/ for OpenSSL related files. There is no need for a complicated setup with symbolic links when the PKG_CONFIG_PATH environment variable points to the right pkgconfig, which is now done in build-commons.sh.
It's not needed since everything is properly handled in the System.Globalization.Native CMakeLists.txt file: https://github.com/dotnet/runtime/blob/e301ec16723437561c84f7b9a8c773def67b81fd/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt#L17 Anyway, recent versions of Homebrew refuse to link icu4c: ```sh $ brew link --force icu4c Warning: Refusing to link macOS provided/shadowed software: icu4c If you need to have icu4c first in your PATH run: echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc For compilers to find icu4c you may need to set: export LDFLAGS="-L/usr/local/opt/icu4c/lib" export CPPFLAGS="-I/usr/local/opt/icu4c/include" For pkg-config to find icu4c you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig" ```
7589316
to
a860726
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was bugging me for a long time, thanks for fixing it!
Use install-native-dependencies.sh instead of duplicating the list of native dependencies in the build job yaml files, just like it's done in other build jobs (eng/pipelines/common/templates/runtimes/build-test-job.yml, eng/pipelines/coreclr/templates/build-job.yml and eng/pipelines/mono/templates/build-job.yml)
3151be0
to
1956d5e
Compare
Looks like this gets further now but |
I tried to fix the The
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus the open question about openssl 1.1 lgtm
ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/ | ||
ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/ | ||
ln -s /usr/local/opt/openssl\@1.1/lib/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/ | ||
brew install cmake autoconf automake icu4c libtool openssl pkg-config python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if one can run tests locally without the links? (we would not see it the in CI as tests do run on different machine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming Homebrew is still not linking the libraries into /usr/local/lib/, we need to keep the runtime dependencies section.
But as long as src\libraries\Native\build-native.sh is sourcing the script that adds the default homebrew path to the pkg-config probe path, we can remove the pkgconfig-specific steps from the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is meant for developers, I'm wondering if we can add rpath so runtime would find them as well automatically. Or add note that somebody can set LD_LIBRARY_PATH as alternative to linking.
In either case I would be nice if one does not have to do any linking and direct file manipulation.
src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt
Outdated
Show resolved
Hide resolved
Since you touching this, can you accommodate #34150 ? Perhaps have |
if ! pkg-config openssl ; then | ||
# We export the proper PKG_CONFIG_PATH where openssl was installed by Homebrew | ||
# It's important to _export_ it since build-commons.sh is sourced by other scripts such as build-native.sh | ||
export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this should set the value additively, not as a replacement...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think replacement is correct here. build-commons.sh
is sourced by other scripts and we really just need openssl. Also, the default directory will be searched anyway, see the pkg-config documentation about the PKG_CONFIG_PATH
environment variable:
PKG_CONFIG_PATH
A colon-separated (on Windows, semicolon-separated) list of
directories to search for .pc files. The default directory will
always be searched after searching the path; the default is
libdir/pkgconfig:datadir/pkgconfig where libdir is the libdir
for pkg-config and datadir is the datadir for pkg-config when it
was installed.
Co-Authored-By: Jeremy Barton <jbarton@microsoft.com>
"Or newer" may not be true
…ies.sh" This reverts commit 277c5b5. It turns out the sh was necessary, else we get this error when running on continuous integration: > /Users/runner/runners/2.166.4/work/_temp/56691a53-a761-472c-b9ab-a9b4eb004f5d.sh: line 1: /Users/runner/runners/2.166.4/work/1/s/eng/install-native-dependencies.sh: Permission denied
43a3d87
to
c695125
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thanks.
c695125
to
c6f19d6
Compare
Anything holding the merge? |
The previous instructions were asking the user to add symbolic links inside /usr/local/lib/ and /usr/local/lib/pkgconfig/ for OpenSSL related files. There is no need for a complicated setup with symbolic links when the PKG_CONFIG_PATH environment variable points to the right pkgconfig, which is now done in build-commons.sh.