-
Notifications
You must be signed in to change notification settings - Fork 144
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
Fix cross-compilation on macOS with SDK and ARCH #849
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Surprisingly, it's possible to cross-compile Themis Core for different SDKs and architectures using our makefile. For example, make SDK=macosx11.0 ARCH=arm64 will compile for Apple Silicon, provided that your Xcode toolchain is actually capable of building that architecture. You also need to have OpenSSL binaries with desired architecture installed (for which you might need to tweak ENGINE_INCLUDE_PATH and ENGINE_LIB_PATH separately). Or build ENGINE=boringssl to use embedded BoringSSL that we can cross-compile too. However, cross-compilation does not work because the architecture and system library directries are not set at link time, so libthemis.dylib it attempted to be linked for the native target which does not work. Pass proper settings to LDFLAGS at configuration time so that cross-compilation has a chance to work.
If we seem to be cross-compiling, tell CMake what SDK it should use and what architecture it should be building. It knows what to do next.
Throw in a job to make sure that cross-compilations stays in working order. Unfortunately, we can't actually run unit tests, but hey, at least it compiles.
vixentael
approved these changes
Jun 29, 2021
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.
Surprise-surprise..
Thank you @ilammy <3
vixentael
reviewed
Jun 29, 2021
- name: Check binary architecture | ||
run: | | ||
set -x | ||
test $(lipo -archs build/libsoter.0.dylib) = arm64 |
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.
hah, that's clever!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-BoringSSL
Crypto provider: BoringSSL
core
Themis Core written in C, its packages
O-macOS 💻
Operating system: macOS
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Surprisingly, it's possible to cross-compile Themis Core for different SDKs and architectures using our makefile. For example,
will compile for Apple Silicon, provided that your Xcode toolchain is actually capable of building that architecture.
You also need to have OpenSSL binaries with desired architecture installed (for which you might need to tweak ENGINE_INCLUDE_PATH and ENGINE_LIB_PATH separately). Or build
ENGINE=boringssl
to use embedded BoringSSL that we can cross-compile too.There were some missing bits here and there to make it work, but now it works. See commit messages for details.
Checklist