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

Fix cross-compilation on macOS with SDK and ARCH #849

Merged
merged 4 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 28 additions & 0 deletions .github/workflows/test-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,31 @@ jobs:
echo "Secure Session: socket interface"
cc -o session_test client.c server.c session_test.c -lthemis -pthread
./session_test

macos-cross-compile:
name: macOS cross toolchain
runs-on: macos-10.15
steps:
- name: Install system dependencies
run: |
brew install cmake ninja
- name: Check out code
uses: actions/checkout@v2
with:
submodules: true
# We can't test OpenSSL builds since this requires OpenSSL libraries
# built for the target architecture (and Homebrew doesn't have any).
#
# GitHub's virtual environemnts can change the default version of Xcode
# and that changes the available SDKs. Check the combinations here:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode
- name: Build Themis Core (BoringSSL, arm64)
run: make SDK=macosx11.1 ARCH=arm64 ENGINE=boringssl
# Of course we can't run unit tests either because there is no emulator.
# So I will be satisifed to see the build succeed and produce binaries
# with expected architecture.
- name: Check binary architecture
run: |
set -x
test $(lipo -archs build/libsoter.0.dylib) = arm64
Copy link
Contributor

Choose a reason for hiding this comment

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

hah, that's clever!

test $(lipo -archs build/libthemis.0.dylib) = arm64
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ _Code:_
</details>

- Fixed multiple buffer overflows in Secure Message ([#763](https://github.com/cossacklabs/themis/pull/763)).
- Fixed cross-compilation on macOS by setting `ARCH` and `SDK` variables ([#849](https://github.com/cossacklabs/themis/pull/849)).

- **Android**

Expand Down Expand Up @@ -169,6 +170,8 @@ _Infrastructure:_
- Added automated tests for Android example project ([#813](https://github.com/cossacklabs/themis/pull/813)).
- Added automated tests for desktop Java example project ([#816](https://github.com/cossacklabs/themis/pull/816)).
- Embedded BoringSSL now builds faster if Ninja is available ([#837](https://github.com/cossacklabs/themis/pull/837)).
- Embedded BoringSSL can now be cross-compiled on macOS by setting `ARCH` and `SDK` variables ([#849](https://github.com/cossacklabs/themis/pull/849)).


## [0.13.10](https://github.com/cossacklabs/themis/releases/tag/0.13.10), May 26th 2021

Expand Down
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ configure_macos_toolchain() {
set_variable FRAMEWORKS "$SDK_BASE/System/Library/Frameworks/"
set_variable SDK_INCLUDES "$SDK_BASE/usr/include"
append_variable CFLAGS "-isysroot \"$SDK_BASE\""
append_variable LDFLAGS "-isysroot \"$SDK_BASE\""
fi

if [ -n "${ARCH:-}" ]
then
append_variable CFLAGS "-arch $ARCH"
append_variable LDFLAGS "-arch $ARCH"
fi
}

Expand Down
10 changes: 10 additions & 0 deletions src/soter/boringssl/soter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ ifneq ($(NINJA),)
SOTER_ENGINE_CMAKE_FLAGS += -G Ninja
endif

# Cross-compilation support for macOS
ifdef IS_MACOS
ifdef SDK
SOTER_ENGINE_CMAKE_FLAGS += -DCMAKE_OSX_SYSROOT=$(SDK)
endif
ifdef ARCH
SOTER_ENGINE_CMAKE_FLAGS += -DCMAKE_OSX_ARCHITECTURES=$(ARCH)
endif
endif

ifdef IS_LINUX
RENAME_BORINGSSL_SYMBOLS = yes
endif
Expand Down