|
53 | 53 |
|
54 | 54 | BASE_HOST_CFLAGS="$BASE_CFLAGS"
|
55 | 55 |
|
56 |
| -if [ "$HOST_OSX" = "true" ]; then |
| 56 | +if [ "$MACOS_SDK" = "" -a "$HOST_OSX" = "true" ]; then |
| 57 | + MACOS_SDK="$(xcrun --show-sdk-path)" |
| 58 | + [ "$MACOS_SDK" = "" ] && exit 1 |
| 59 | +fi |
| 60 | + |
| 61 | +if [ "$MACOS_SDK" != "" ]; then |
57 | 62 | export MACOSX_DEPLOYMENT_TARGET=10.9
|
58 |
| - LOCAL_CFLAGS="$LOCAL_CFLAGS --target=$HOST_PLATFORM -isysroot$(xcrun --show-sdk-path) -mmacosx-version-min=10.9" |
59 |
| - BASE_HOST_CFLAGS="$BASE_HOST_CFLAGS --target=$HOST_PLATFORM -isysroot$(xcrun --show-sdk-path) -mmacosx-version-min=10.9" |
60 |
| - # Targeting aarch64 appears to be supported only starting with Big Sur, so check it before use |
61 |
| - clang -o /dev/null $BASE_HOST_CFLAGS --target=aarch64-apple-darwin -mcpu=apple-a14 genbindings_path_map_test_file.c && |
62 |
| - export CFLAGS_aarch64_apple_darwin="$BASE_HOST_CFLAGS --target=aarch64-apple-darwin -mcpu=apple-a14" || |
63 |
| - echo "WARNING: Can not build targeting aarch64-apple-darin. Upgrade to Big Sur or try upstream clang" |
| 63 | + BASE_HOST_OSX_CFLAGS="$BASE_HOST_CFLAGS -isysroot$MACOS_SDK -mmacosx-version-min=10.9" |
| 64 | + export CFLAGS_aarch64_apple_darwin="$BASE_HOST_OSX_CFLAGS --target=aarch64-apple-darwin -mcpu=apple-a14" |
| 65 | + export CFLAGS_x86_64_apple_darwin="$BASE_HOST_OSX_CFLAGS --target=x86_64-apple-darwin -march=sandybridge -mtune=sandybridge" |
| 66 | + if [ "$HOST_OSX" = "true" ]; then |
| 67 | + LOCAL_CFLAGS="$LOCAL_CFLAGS --target=$HOST_PLATFORM -isysroot$MACOS_SDK -mmacosx-version-min=10.9" |
| 68 | + BASE_HOST_CFLAGS="$BASE_HOST_OSX_CFLAGS --target=$HOST_PLATFORM" |
| 69 | + fi |
64 | 70 | fi
|
65 | 71 |
|
66 | 72 | rm genbindings_path_map_test_file.c
|
|
214 | 220 | cd lightning-c-bindings
|
215 | 221 |
|
216 | 222 | RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS
|
217 |
| -if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then |
| 223 | +if [ "$CFLAGS_aarch64_apple_darwin" != "" -a "$HOST_OSX" = "true" ]; then |
218 | 224 | RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" cargo build $CARGO_BUILD_ARGS --target aarch64-apple-darwin
|
219 | 225 | fi
|
220 | 226 | cbindgen -v --config cbindgen.toml -o include/lightning.h >/dev/null 2>&1
|
@@ -454,7 +460,7 @@ if [ "$HOST_PLATFORM" = "x86_64-unknown-linux-gnu" -o "$HOST_PLATFORM" = "x86_64
|
454 | 460 | sed -i .bk 's/,"cdylib"]/]/g' Cargo.toml
|
455 | 461 | fi
|
456 | 462 |
|
457 |
| - if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then |
| 463 | + if [ "$CFLAGS_aarch64_apple_darwin" != "" -a "$HOST_OSX" = "true" ]; then |
458 | 464 | RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" RUSTC_BOOTSTRAP=1 cargo rustc $CARGO_BUILD_ARGS --target aarch64-apple-darwin -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
|
459 | 465 | fi
|
460 | 466 | RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" RUSTC_BOOTSTRAP=1 cargo rustc $CARGO_BUILD_ARGS -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
|
@@ -541,18 +547,27 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
|
541 | 547 | # packaging than simply shipping the rustup binaries (eg Debian should Just Work
|
542 | 548 | # here).
|
543 | 549 | LINK_ARG_FLAGS="-C link-arg=-fuse-ld=$LLD"
|
544 |
| - if [ "$HOST_OSX" = "true" ]; then |
545 |
| - export LDK_CLANG_PATH=$(which $CLANG) |
| 550 | + export LDK_CLANG_PATH=$(which $CLANG) |
| 551 | + if [ "$MACOS_SDK" != "" ]; then |
546 | 552 | export CLANG="$(pwd)/../deterministic-build-wrappers/clang-lto-link-osx"
|
547 |
| - for ARG in "CFLAGS_aarch64_apple_darwin"; do |
| 553 | + for ARG in $CFLAGS_aarch64_apple_darwin; do |
548 | 554 | MANUAL_LINK_CFLAGS="$MANUAL_LINK_CFLAGS -C link-arg=$ARG"
|
549 | 555 | done
|
550 | 556 | export CFLAGS_aarch64_apple_darwin="$CFLAGS_aarch64_apple_darwin -O3 -fPIC -fembed-bitcode"
|
551 |
| - LINK_ARG_FLAGS="$LINK_ARG_FLAGS -C link-arg="-isysroot$(xcrun --show-sdk-path)" -C link-arg=-mmacosx-version-min=10.9" |
552 |
| - RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target aarch64-apple-darwin |
| 557 | + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort |
| 558 | + if [ "$HOST_OSX" != "true" ]; then |
| 559 | + # If we're not on OSX but can build OSX binaries, build the x86_64 OSX release now |
| 560 | + MANUAL_LINK_CFLAGS="" |
| 561 | + for ARG in $CFLAGS_x86_64_apple_darwin; do |
| 562 | + MANUAL_LINK_CFLAGS="$MANUAL_LINK_CFLAGS -C link-arg=$ARG" |
| 563 | + done |
| 564 | + export CFLAGS_x86_64_apple_darwin="$CFLAGS_x86_64_apple_darwin -O3 -fPIC -fembed-bitcode" |
| 565 | + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort |
| 566 | + fi |
553 | 567 | fi
|
554 | 568 | # If we're on an M1 don't bother building X86 binaries
|
555 | 569 | if [ "$HOST_PLATFORM" != "aarch64-apple-darwin" ]; then
|
| 570 | + [ "$HOST_OSX" != "true" ] && export CLANG="$LDK_CLANG_PATH" |
556 | 571 | export CFLAGS_$ENV_TARGET="$BASE_HOST_CFLAGS -O3 -fPIC -fembed-bitcode"
|
557 | 572 | # Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
|
558 | 573 | cargo clean --release
|
|
0 commit comments