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

Compile openssl from source for macos #2535

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,24 @@ jobs:

Build_macOs:
needs: [macos_helper]
runs-on: macos-12
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Protobuf
run: brew install protobuf

- name: Building Macos Binary
run: MACOSX_DEPLOYMENT_TARGET=10.14 OPENSSL_STATIC=1 OPENSSL_DIR="/usr/local/opt/openssl" cargo build --release -p witnet -p witnet_toolkit
- name: Compile openssl 1.0.2p from source
run: sh ./docker/cross-compilation/openssl-macos.sh

- name: Build Macos Binary
env:
MACOSX_DEPLOYMENT_TARGET: "10.14"
OPENSSL_STATIC: "1"
OPENSSL_DIR: "/usr/local/openssl"
run: |
cargo build --release -p witnet -p witnet_toolkit

- name: Upload Build
uses: actions/upload-artifact@v4
Expand Down
46 changes: 46 additions & 0 deletions docker/cross-compilation/openssl-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -ex

main() {
local version=1.0.2p
local install_dir="/usr/local/openssl"

# Install dependencies using brew
brew install \
m4 \
make

# Create temporary directory
td=$(mktemp -d)
pushd $td

# Download and extract OpenSSL
wget https://www.openssl.org/source/openssl-$version.tar.gz
tar --strip-components=1 -xzvf openssl-$version.tar.gz

# Configure OpenSSL for arm64, disabling assembly
./Configure \
--prefix="$install_dir" \
darwin64-x86_64-cc \
no-dso \
no-asm \
-fPIC \
${@:1}

# Modify the generated Makefile to use arm64
perl -pi -e 's/-arch x86_64/-arch arm64/g' Makefile

# Build using all available cores
KERNEL_BITS=64 make -j$(sysctl -n hw.ncpu)

# Install
sudo make install

popd

# Cleanup
rm -rf $td
}

main "${@}"