Commit 87e3114d authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Initial m1 build support

parent 7f3d97f0
Pipeline #1433 passed with stages
in 1 minute and 46 seconds
include:
- project: 'alchemy/infrastructure/gitlab-ci-config'
file: '3p-library.yml'
file: '3p-library-m1.yml'
......@@ -62,8 +62,8 @@
</map>
<key>manifest</key>
<array>
<string>lib/debug/*.dylib*</string>
<string>lib/release/*.dylib*</string>
<string>lib/debug/*.a</string>
<string>lib/release/*.a</string>
</array>
<key>name</key>
<string>darwin</string>
......
......@@ -89,34 +89,37 @@ pushd "$top/$EXPAT_SOURCE_DIR"
# Setup osx sdk platform
SDKNAME="macosx"
export SDKROOT=$(xcodebuild -version -sdk ${SDKNAME} Path)
export MACOSX_DEPLOYMENT_TARGET=10.15
# Deploy Targets
X86_DEPLOY=10.15
ARM64_DEPLOY=11.0
# Setup build flags
ARCH_FLAGS="-arch x86_64"
SDK_FLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -isysroot ${SDKROOT}"
DEBUG_COMMON_FLAGS="$ARCH_FLAGS $SDK_FLAGS -Og -g -msse4.2 -fPIC -DPIC"
RELEASE_COMMON_FLAGS="$ARCH_FLAGS $SDK_FLAGS -Ofast -ffast-math -flto -g -msse4.2 -fPIC -DPIC -fstack-protector-strong"
ARCH_FLAGS_X86="-arch x86_64 -mmacosx-version-min=${X86_DEPLOY} -isysroot ${SDKROOT} -msse4.2"
ARCH_FLAGS_ARM64="-arch arm64 -mmacosx-version-min=${ARM64_DEPLOY} -isysroot ${SDKROOT}"
DEBUG_COMMON_FLAGS="-O0 -g -fPIC -DPIC"
RELEASE_COMMON_FLAGS="-O3 -g -fPIC -DPIC -fstack-protector-strong"
DEBUG_CFLAGS="$DEBUG_COMMON_FLAGS"
RELEASE_CFLAGS="$RELEASE_COMMON_FLAGS"
DEBUG_CXXFLAGS="$DEBUG_COMMON_FLAGS -std=c++17"
RELEASE_CXXFLAGS="$RELEASE_COMMON_FLAGS -std=c++17"
DEBUG_CPPFLAGS="-DPIC"
RELEASE_CPPFLAGS="-DPIC"
DEBUG_LDFLAGS="$ARCH_FLAGS $SDK_FLAGS -Wl,-headerpad_max_install_names -Wl,-macos_version_min,$MACOSX_DEPLOYMENT_TARGET"
RELEASE_LDFLAGS="$ARCH_FLAGS $SDK_FLAGS -Wl,-headerpad_max_install_names -Wl,-macos_version_min,$MACOSX_DEPLOYMENT_TARGET"
DEBUG_LDFLAGS="-Wl,-headerpad_max_install_names"
RELEASE_LDFLAGS="-Wl,-headerpad_max_install_names"
mkdir -p "$STAGING_DIR/lib/debug"
mkdir -p "$STAGING_DIR/lib/release"
# x86 Deploy Target
export MACOSX_DEPLOYMENT_TARGET=${X86_DEPLOY}
mkdir -p "build_debug"
pushd "build_debug"
CFLAGS="$DEBUG_CFLAGS" \
CXXFLAGS="$DEBUG_CXXFLAGS" \
mkdir -p "build_debug_x86"
pushd "build_debug_x86"
CFLAGS="$ARCH_FLAGS_X86 $DEBUG_CFLAGS" \
CXXFLAGS="$ARCH_FLAGS_X86 $DEBUG_CXXFLAGS" \
CPPFLAGS="$DEBUG_CPPFLAGS" \
LDFLAGS="$DEBUG_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF \
-DCMAKE_C_FLAGS="$DEBUG_CFLAGS" \
-DCMAKE_CXX_FLAGS="$DEBUG_CXXFLAGS" \
LDFLAGS="$ARCH_FLAGS_X86 $DEBUG_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="$ARCH_FLAGS_X86 $DEBUG_CFLAGS" \
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS_X86 $DEBUG_CXXFLAGS" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL="0" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH=NO \
-DCMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS=YES \
......@@ -130,27 +133,27 @@ pushd "$top/$EXPAT_SOURCE_DIR"
-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DCMAKE_OSX_SYSROOT=${SDKROOT} \
-DCMAKE_MACOSX_RPATH=YES -DCMAKE_INSTALL_PREFIX=$STAGING_DIR
-DCMAKE_MACOSX_RPATH=YES \
-DCMAKE_INSTALL_PREFIX="$STAGING_DIR/debug_x86"
cmake --build . --config Debug
cmake --install . --config Debug
# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
ctest -C Debug
fi
cp -a Debug/libexpat*.dylib* "${STAGING_DIR}/lib/debug/"
popd
mkdir -p "build_release"
pushd "build_release"
CFLAGS="$RELEASE_CFLAGS" \
CXXFLAGS="$RELEASE_CXXFLAGS" \
mkdir -p "build_release_x86"
pushd "build_release_x86"
CFLAGS="$ARCH_FLAGS_X86 $RELEASE_CFLAGS" \
CXXFLAGS="$ARCH_FLAGS_X86 $RELEASE_CXXFLAGS" \
CPPFLAGS="$RELEASE_CPPFLAGS" \
LDFLAGS="$RELEASE_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF \
-DCMAKE_C_FLAGS="$RELEASE_CFLAGS" \
-DCMAKE_CXX_FLAGS="$RELEASE_CXXFLAGS" \
LDFLAGS="$ARCH_FLAGS_X86 $RELEASE_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="$ARCH_FLAGS_X86 $RELEASE_CFLAGS" \
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS_X86 $RELEASE_CXXFLAGS" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL="fast" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH=YES \
-DCMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS=YES \
......@@ -164,32 +167,97 @@ pushd "$top/$EXPAT_SOURCE_DIR"
-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DCMAKE_OSX_SYSROOT=${SDKROOT} \
-DCMAKE_MACOSX_RPATH=YES -DCMAKE_INSTALL_PREFIX=$STAGING_DIR
-DCMAKE_MACOSX_RPATH=YES \
-DCMAKE_INSTALL_PREFIX="$STAGING_DIR/release_x86"
cmake --build . --config Release
cmake --install . --config Release
# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
ctest -C Release
fi
cp -a Release/libexpat*.dylib* "${STAGING_DIR}/lib/release/"
popd
pushd "${STAGING_DIR}/lib/debug"
fix_dylib_id "libexpat.dylib"
strip -x -S libexpat.dylib
# ARM64 Deploy Target
export MACOSX_DEPLOYMENT_TARGET=${ARM64_DEPLOY}
mkdir -p "build_debug_arm64"
pushd "build_debug_arm64"
CFLAGS="$ARCH_FLAGS_ARM64 $DEBUG_CFLAGS" \
CXXFLAGS="$ARCH_FLAGS_ARM64 $DEBUG_CXXFLAGS" \
CPPFLAGS="$DEBUG_CPPFLAGS" \
LDFLAGS="$ARCH_FLAGS_ARM64 $DEBUG_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="$ARCH_FLAGS_ARM64 $DEBUG_CFLAGS" \
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS_ARM64 $DEBUG_CXXFLAGS" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL="0" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH=NO \
-DCMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS=YES \
-DCMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT=dwarf-with-dsym \
-DCMAKE_XCODE_ATTRIBUTE_LLVM_LTO=NO \
-DCMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING=YES \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++17" \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="" \
-DCMAKE_OSX_ARCHITECTURES:STRING=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DCMAKE_OSX_SYSROOT=${SDKROOT} \
-DCMAKE_MACOSX_RPATH=YES \
-DCMAKE_INSTALL_PREFIX="$STAGING_DIR/debug_arm64"
cmake --build . --config Debug
cmake --install . --config Debug
# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
ctest -C Debug
fi
popd
pushd "${STAGING_DIR}/lib/release"
fix_dylib_id "libexpat.dylib"
strip -x -S libexpat.dylib
mkdir -p "build_release_arm64"
pushd "build_release_arm64"
CFLAGS="$ARCH_FLAGS_ARM64 $RELEASE_CFLAGS" \
CXXFLAGS="$ARCH_FLAGS_ARM64 $RELEASE_CXXFLAGS" \
CPPFLAGS="$RELEASE_CPPFLAGS" \
LDFLAGS="$ARCH_FLAGS_ARM64 $RELEASE_LDFLAGS" \
cmake .. -GXcode -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS="$ARCH_FLAGS_ARM64 $RELEASE_CFLAGS" \
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS_ARM64 $RELEASE_CXXFLAGS" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL="fast" \
-DCMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH=YES \
-DCMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS=YES \
-DCMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT=dwarf-with-dsym \
-DCMAKE_XCODE_ATTRIBUTE_LLVM_LTO=YES \
-DCMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING=YES \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++17" \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" \
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="" \
-DCMAKE_OSX_ARCHITECTURES:STRING=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-DCMAKE_OSX_SYSROOT=${SDKROOT} \
-DCMAKE_MACOSX_RPATH=YES \
-DCMAKE_INSTALL_PREFIX="$STAGING_DIR/release_arm64"
cmake --build . --config Release
cmake --install . --config Release
# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
ctest -C Release
fi
popd
INCLUDE_DIR="$STAGING_DIR/include/expat"
mkdir -p "$INCLUDE_DIR"
cp lib/expat.h "$INCLUDE_DIR"
cp lib/expat_external.h "$INCLUDE_DIR"
mkdir -p "$STAGING_DIR/include/expat"
mkdir -p "$STAGING_DIR/lib/debug"
mkdir -p "$STAGING_DIR/lib/release"
# create fat libraries
lipo -create ${STAGING_DIR}/debug_x86/lib/libexpat.a ${STAGING_DIR}/debug_arm64/lib/libexpat.a -output ${STAGING_DIR}/lib/debug/libexpat.a
lipo -create ${STAGING_DIR}/release_x86/lib/libexpat.a ${STAGING_DIR}/release_arm64/lib/libexpat.a -output ${STAGING_DIR}/lib/release/libexpat.a
# copy headers
mv $STAGING_DIR/release_x86/include/* $STAGING_DIR/include/expat/
;;
linux*)
# Default target per --address-size
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment