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

Introduce macOS universal library build support #6

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
strategy:
matrix:
os: [windows-2022, macos-12, ubuntu-22.04]
os: [windows-2022, macos-15, ubuntu-22.04]
addrsize: ["64"]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -19,7 +19,7 @@ jobs:
choco install -y nasm jom
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\ProgramData\chocolatey\lib\jom\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: secondlife/action-autobuild@v4
- uses: secondlife/action-autobuild@v5
with:
addrsize: ${{ matrix.addrsize }}
release:
Expand Down
14 changes: 7 additions & 7 deletions autobuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>3a6593c71c59ace76d1349483759fcde4b719a76</string>
<string>4d437afc7fc3988cf0c78ed05853a211cc6bf8b8</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.1-r2/zlib_ng-2.2.1-r2-darwin64-10324415171.tar.zst</string>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.2-r1/zlib_ng-2.2.2-dev0.gcaa101e.d20241120-darwin64-11943461931.tar.zst</string>
</map>
<key>name</key>
<string>darwin64</string>
Expand All @@ -30,11 +30,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>fbadeb0b8c771cb06c0055c9fab6d40c6764dacd</string>
<string>70c1d8728b85481bd42904c1213ed50264e77be1</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.1-r2/zlib_ng-2.2.1-r2-linux64-10324415171.tar.zst</string>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.2-r1/zlib_ng-2.2.2-dev0.gcaa101e.d20241120-linux64-11943461931.tar.zst</string>
</map>
<key>name</key>
<string>linux64</string>
Expand All @@ -58,11 +58,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>0094031715662be626f5106ff6c814f4fc3dacfa</string>
<string>f98c30b20120511ecceab8bf1b5eba048b10aade</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.1-r2/zlib_ng-2.2.1-r2-windows64-10324415171.tar.zst</string>
<string>https://github.com/secondlife/3p-zlib-ng/releases/download/v2.2.2-r1/zlib_ng-2.2.2-dev0.gcaa101e.d20241120-windows64-11943461931.tar.zst</string>
</map>
<key>name</key>
<string>windows64</string>
Expand All @@ -75,7 +75,7 @@
<key>copyright</key>
<string>Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler</string>
<key>version</key>
<string>2.2.1-r2</string>
<string>2.2.2-dev0.gcaa101e.d20241120</string>
<key>name</key>
<string>zlib-ng</string>
<key>canonical_repo</key>
Expand Down
154 changes: 74 additions & 80 deletions build-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ pushd "$OPENSSL_SOURCE_DIR"
;;

darwin*)
# workaround for finding makedepend on OS X
export PATH="$PATH":/usr/X11/bin/

# Install name for dylibs based on major version number
# Not clear exactly why Configure/make generates lib*.1.0.0.dylib
# for ${major_version}.${minor_version}.${build_version} == 1.0.1,
Expand All @@ -128,90 +125,87 @@ pushd "$OPENSSL_SOURCE_DIR"
fi
done

# Normally here we'd insert -arch $AUTOBUILD_CONFIGURE_ARCH before
# $LL_BUILD_RELEASE. But the way we must pass these $opts into
# Configure doesn't seem to work for -arch: we get tons of:
# clang: warning: argument unused during compilation: '-arch=x86_64'
# Anyway, selection of $targetname (below) appears to handle the
# -arch switch implicitly.
opts="${TARGET_OPTS:-$LL_BUILD_RELEASE}"
opts="$(remove_cxxstd $opts)"
# As of 2017-09-08:
# clang: error: unknown argument: '-gdwarf-with-dsym'
opts="$(replace_switch -gdwarf-with-dsym -gdwarf-2 $opts)"
export CFLAGS="$opts"
export LDFLAGS="-Wl,-headerpad_max_install_names"

if [ "$AUTOBUILD_ADDRSIZE" = 32 ]
then
targetname='darwin-i386-cc 386'
else
targetname='darwin64-x86_64-cc'
fi

# deploy target
export MACOSX_DEPLOYMENT_TARGET=${LL_BUILD_DARWIN_DEPLOY_TARGET}

# It seems to be important to Configure to pass (e.g.)
# "-iwithsysroot=/some/path" instead of just glomming them on
# as separate arguments. So make a pass over $opts, collecting
# switches with args in that form into a bash array.
packed=()
pack=()
function flush {
local IFS="="
# Flush 'pack' array to the next entry of 'packed'.
# ${pack[*]} concatenates all of pack's entries into a single
# string separated by the first char from $IFS.
packed+=("${pack[*]:-}")
for arch in x86_64 arm64 ; do
opts="${TARGET_OPTS:-$LL_BUILD_RELEASE}"
cc_opts="$(remove_cxxstd $opts)"
ld_opts="-Wl,-headerpad_max_install_names"

# It seems to be important to Configure to pass (e.g.)
# "-iwithsysroot=/some/path" instead of just glomming them on
# as separate arguments. So make a pass over $opts, collecting
# switches with args in that form into a bash array.
packed=()
pack=()
}
for opt in $opts $LDFLAGS
do
if [ "x${opt#-}" != "x$opt" ]
then
# 'opt' does indeed start with dash.
flush
fi
# append 'opt' to 'pack' array
pack+=("$opt")
function flush {
local IFS="="
# Flush 'pack' array to the next entry of 'packed'.
# ${pack[*]} concatenates all of pack's entries into a single
# string separated by the first char from $IFS.
packed+=("${pack[*]:-}")
pack=()
}
for opt in $cc_opts $ld_opts
do
if [ "x${opt#-}" != "x$opt" ]
then
# 'opt' does indeed start with dash.
flush
fi
# append 'opt' to 'pack' array
pack+=("$opt")
done
# When we exit the above loop, we've got one more pending entry in
# 'pack'. Flush that too.
flush
# We always have an extra first entry in 'packed'. Get rid of that.
unset packed[0]

mkdir -p "build_$arch"
pushd "build_$arch"
CFLAGS="$cc_opts" \
CXXFLAGS="$opts" \
LDFLAGS="$ld_opts" \
../Configure --release zlib no-zlib-dynamic threads no-shared darwin64-"$arch"-cc \
--prefix="$stage" --libdir="lib/release/$arch" --openssldir="share" \
--with-zlib-include="$stage/packages/include/zlib-ng" \
--with-zlib-lib="$stage/packages/lib/release" \
"${packed[@]}"
make depend
make -j$AUTOBUILD_CPU_COUNT
# Avoid plain 'make install' because, at least on Yosemite,
# installing the man pages into the staging area creates problems
# due to the number of symlinks. Thanks to Cinder for suggesting
# this make target.
make install_sw

# Modify .dylib path information. Do this after install
# to the copies rather than built or the dylib's will be
# linked again wiping out the install_name.
# crypto_stage_name="${stage}/lib/release/${crypto_target_name}"
# ssl_stage_name="${stage}/lib/release/${ssl_target_name}"
# chmod u+w "${crypto_stage_name}" "${ssl_stage_name}"
# install_name_tool -id "${ssl_install_name}" "${ssl_stage_name}"
# install_name_tool -id "${crypto_install_name}" "${crypto_stage_name}"
# install_name_tool -change "${crypto_stage_name}" "${crypto_install_name}" "${ssl_stage_name}"

# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
make test
fi

make clean
popd
done
# When we exit the above loop, we've got one more pending entry in
# 'pack'. Flush that too.
flush
# We always have an extra first entry in 'packed'. Get rid of that.
unset packed[0]

# Release
./Configure zlib no-zlib-dynamic threads no-shared $targetname \
--prefix="$stage" --libdir="lib/release" --openssldir="share" \
--with-zlib-include="$stage/packages/include/zlib-ng" \
--with-zlib-lib="$stage/packages/lib/release" \
"${packed[@]}"
make depend
make -j$AUTOBUILD_CPU_COUNT
# Avoid plain 'make install' because, at least on Yosemite,
# installing the man pages into the staging area creates problems
# due to the number of symlinks. Thanks to Cinder for suggesting
# this make target.
make install_sw

# Modify .dylib path information. Do this after install
# to the copies rather than built or the dylib's will be
# linked again wiping out the install_name.
# crypto_stage_name="${stage}/lib/release/${crypto_target_name}"
# ssl_stage_name="${stage}/lib/release/${ssl_target_name}"
# chmod u+w "${crypto_stage_name}" "${ssl_stage_name}"
# install_name_tool -id "${ssl_install_name}" "${ssl_stage_name}"
# install_name_tool -id "${crypto_install_name}" "${crypto_stage_name}"
# install_name_tool -change "${crypto_stage_name}" "${crypto_install_name}" "${ssl_stage_name}"

# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
make test
fi
# create stage structure
mkdir -p "$stage/lib/release"

make clean
# create fat libraries
lipo -create -output ${stage}/lib/release/libcrypto.a ${stage}/lib/release/x86_64/libcrypto.a ${stage}/lib/release/arm64/libcrypto.a
lipo -create -output ${stage}/lib/release/libssl.a ${stage}/lib/release/x86_64/libssl.a ${stage}/lib/release/arm64/libssl.a
;;

linux*)
Expand Down