diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index 2748162a..f3b19b96 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -17,20 +17,27 @@ runs: if: ${{ runner.os == 'macOS' }} run: | brew install gnu-sed + mkdir -p /tmp/gnu-bin + ln -s "$(command -v gsed)" /tmp/gnu-bin/sed - name: Checkout Rust-Lightning and LDK-C-Bindings git shell: bash run: | echo `pwd` mkdir -p ${{ inputs.destination }}/bin - git clone --branch 0.0.124-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning - git clone --branch main https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings + git clone --branch 0.0.125-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning + git clone --branch 0.0.125 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings + - name: Configure default Rust toolchain + shell: bash + run: | + rustup install 1.73.0 + rustup default 1.73.0 - name: Install Rust, required targets if: ${{ inputs.configureRustNightly == 'true' }} shell: bash run: | - rustup toolchain install nightly-2022-05-13 + rustup toolchain install nightly-2022-06-24 rustup target add aarch64-apple-darwin aarch64-apple-ios x86_64-apple-ios - rustup component add rust-src --toolchain nightly-2022-05-13-x86_64-apple-darwin + rustup component add rust-src --toolchain nightly-2022-06-24-aarch64-apple-darwin - name: Load Cache if: ${{ inputs.configureRustNightly == 'true' }} uses: actions/cache@v3 @@ -45,11 +52,15 @@ runs: - name: Pin cbindgen v24 shell: bash run: | - cargo install --version 0.24.5 cbindgen + echo "DEVELOPER_DIR:" + echo $DEVELOPER_DIR + cargo install --force --version 0.24.5 cbindgen - name: Generate C Bindings shell: bash run: | - export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" + # Alias sed as gsed, if applicable + export PATH="/tmp/gnu-bin:$PATH" + pushd ${{ inputs.destination }}/ldk-c-bindings if [ "$RUNNER_OS" == "macOS" ]; then ./genbindings.sh ../rust-lightning true skip-tests diff --git a/.github/actions/upload-xcframework-artifact/action.yml b/.github/actions/upload-xcframework-artifact/action.yml index 464d19fc..cc1c6936 100644 --- a/.github/actions/upload-xcframework-artifact/action.yml +++ b/.github/actions/upload-xcframework-artifact/action.yml @@ -14,7 +14,7 @@ runs: python3 ./scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework ditto -c -k --sequesterRsrc --keepParent /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework LightningDevKit-no-symlinks.xcframework.zip - name: Upload Framework Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: LightningDevKit path: | diff --git a/.github/workflows/build-xcframework-parallel-archives.yml b/.github/workflows/build-xcframework-parallel-archives.yml index d2eb0ab7..c10fc09e 100644 --- a/.github/workflows/build-xcframework-parallel-archives.yml +++ b/.github/workflows/build-xcframework-parallel-archives.yml @@ -20,7 +20,7 @@ concurrency: jobs: build-xcarchives: name: Build xcarchive for ${{ matrix.configuration['human_readable_platform'] }} - runs-on: macos-12 + runs-on: macos-latest strategy: fail-fast: false matrix: @@ -34,14 +34,18 @@ jobs: - destination: 'macOS,variant=Mac Catalyst' human_readable_platform: 'catalyst' env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings LDK_C_BINDINGS_BINARY_DIRECTORY: ${{ github.workspace }}/bindings/artifacts/bin steps: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 + - name: Print Xcode SDK availability + shell: bash + run: + xcodebuild -showsdks - name: Checkout uses: actions/checkout@v3 - name: Install Dependencies @@ -57,27 +61,37 @@ jobs: - name: Xcarchive hack run: touch ./bindings_root.txt - name: Upload xcarchive - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: bindings + name: bindings-${{ matrix.configuration['human_readable_platform'] }} path: ./bindings/**/bin/release/${{ matrix.configuration['human_readable_platform'] }}/${{ matrix.configuration['human_readable_platform'] }}.xcarchive generate: name: Combine xcarchives into xcframework - runs-on: macos-12 + runs-on: macos-latest needs: [ build-xcarchives ] env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings steps: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 - name: Checkout uses: actions/checkout@v3 - name: Download xcarchives - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ./bindings + - name: Print post-artifact-download directory structure + shell: bash + run: | + echo "Current path:" + pwd + echo "Recursive enumeration" + find "$PWD" - name: Generate xcframework shell: bash run: diff --git a/.github/workflows/build-xcframework-parallel-libldk.yml b/.github/workflows/build-xcframework-parallel-libldk.yml index ade74b15..f35befcc 100644 --- a/.github/workflows/build-xcframework-parallel-libldk.yml +++ b/.github/workflows/build-xcframework-parallel-libldk.yml @@ -20,9 +20,9 @@ concurrency: jobs: build-libldks: name: Build & lipo libldk.a for ${{ matrix.configuration['human_readable_platform'] }} - runs-on: macos-12 + runs-on: macos-latest env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings strategy: fail-fast: true @@ -49,7 +49,7 @@ jobs: if: matrix.configuration['human_readable_platform'] == 'catalyst' uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 - name: Checkout uses: actions/checkout@v3 - name: Install Dependencies @@ -65,9 +65,9 @@ jobs: LLVM_TARGET_TRIPLE_SUFFIX: ${{ matrix.configuration['llvm_target_triple_suffix'] }} ARCHS: ${{ matrix.configuration['architectures'] }} - name: Upload binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: bindings + name: bindings-${{ matrix.configuration['human_readable_platform'] }} path: | ./bindings/**/artifacts/ldk-c-bindings/lightning-c-bindings/include/*.h ./bindings/**/artifacts/ldk-c-bindings/ldk-net/ldk_net.* @@ -75,19 +75,29 @@ jobs: generate-parallel: name: Build xcarchives and generate xcframework needs: [ build-libldks ] - runs-on: macos-12 + runs-on: macos-latest env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings steps: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 - name: Checkout uses: actions/checkout@v3 - name: Download libldks - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ./bindings + - name: Print post-artifact-download directory structure + shell: bash + run: | + echo "Current path:" + pwd + echo "Recursive enumeration" + find "$PWD" - name: Generate Swift Bindings shell: bash run: | diff --git a/.github/workflows/build-xcframework-sequential.yml b/.github/workflows/build-xcframework-sequential.yml index bcb1e932..7deb0872 100644 --- a/.github/workflows/build-xcframework-sequential.yml +++ b/.github/workflows/build-xcframework-sequential.yml @@ -20,15 +20,20 @@ concurrency: jobs: generate-sequential: name: Build libldks, build xcarchives, and combine into xcframework - runs-on: macos-12 + runs-on: macos-latest env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings steps: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 + - name: Print Xcode SDK availability + shell: bash + run: | + xcodebuild -showsdks + ls /Applications/ - name: Checkout uses: actions/checkout@v3 - name: Install Dependencies diff --git a/.github/workflows/direct-bindings-app-tests.yml b/.github/workflows/direct-bindings-app-tests.yml index 7e8b8650..a785a52f 100644 --- a/.github/workflows/direct-bindings-app-tests.yml +++ b/.github/workflows/direct-bindings-app-tests.yml @@ -20,7 +20,7 @@ concurrency: jobs: build: name: Build (${{ matrix.configuration['scheme'] }} - ${{ matrix.configuration['platform'] }}) - runs-on: macos-12 + runs-on: macos-latest continue-on-error: true strategy: fail-fast: false @@ -41,7 +41,7 @@ jobs: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 - name: Checkout uses: actions/checkout@v2 - name: Install Dependencies diff --git a/.github/workflows/release-framework.yml b/.github/workflows/release-framework.yml index 0c34358a..874f4b65 100644 --- a/.github/workflows/release-framework.yml +++ b/.github/workflows/release-framework.yml @@ -16,15 +16,15 @@ on: jobs: generate-xcframework: name: Generate XCFramework - runs-on: macos-12 + runs-on: macos-latest env: - DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings steps: - name: Configure Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest + xcode-version: 15.4.0 - name: Checkout uses: actions/checkout@v3 - name: Update Package.swift tag to ${{ github.event.inputs.tag }} diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index a1eab14a..912b5a2d 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -33,6 +33,16 @@ jobs: sudo apt-get update # sudo apt-get -y upgrade sudo apt-get -y install cargo lld git g++ clang curl + rustup install 1.73.0 + rustup default 1.73.0 + - name: Print updated environment details + run: | + set -x + rustup --version + clang --version + clang --print-resource-dir + ls -ll "$(clang -print-resource-dir)" + ls -ll "$(clang -print-resource-dir)/lib/linux" - name: Install Dependencies uses: ./.github/actions/install-dependencies with: @@ -84,27 +94,53 @@ jobs: - name: Verify generated output recency run: | git diff --exit-code out/ ':(exclude)out/VersionDescriptor.swift' - - name: Build Swift bindings package + - name: Build Swift bindings package with address sanitizer run: | cd ci/LDKSwift + # should be /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a + export LLVM_CLANG_ASAN_PATH="$(clang -print-resource-dir)/lib/linux/libclang_rt.asan-x86_64.a" ../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift build env: LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings - LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a RUST_BACKTRACE: 1 - - name: Test Swift bindings package without address sanitizer + - name: Test Swift bindings package with address sanitizer + continue-on-error: true run: | cd ci/LDKSwift + # should be /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.asan-x86_64.a + export LLVM_CLANG_ASAN_PATH="$(clang -print-resource-dir)/lib/linux/libclang_rt.asan-x86_64.a" ../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v env: LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings RUST_BACKTRACE: 1 - - name: Test Swift bindings package with address sanitizer - continue-on-error: true + - name: Prepare release-optimized rust binaries + run: | + env + pushd ${{ github.workspace }}/ci/ldk-c-bindings/lightning-c-bindings + cargo clean + cargo build --release --features std + + # debug the target + find ./target + env: + RUST_BACKTRACE: 1 + RUSTFLAGS: --cfg=c_bindings -C embed-bitcode=yes -C lto + CARGO_PROFILE_RELEASE_LTO: true + - name: Build Swift bindings package without address sanitizer + run: | + env + cd ci/LDKSwift + ../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift build + env: + LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings + LDK_C_BINDINGS_BINARY_DIRECTORY: ${{ github.workspace }}/ci/ldk-c-bindings/lightning-c-bindings/target/release + RUST_BACKTRACE: 1 + - name: Test Swift bindings package without address sanitizer run: | + env cd ci/LDKSwift ../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v env: LDK_C_BINDINGS_BASE: ${{ github.workspace }}/ci/ldk-c-bindings - LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a + LDK_C_BINDINGS_BINARY_DIRECTORY: ${{ github.workspace }}/ci/ldk-c-bindings/lightning-c-bindings/target/release RUST_BACKTRACE: 1 diff --git a/.github/workflows/test-artifacts.yml b/.github/workflows/test-artifacts.yml index 6b43b409..bfab679d 100644 --- a/.github/workflows/test-artifacts.yml +++ b/.github/workflows/test-artifacts.yml @@ -11,7 +11,7 @@ on: jobs: create-artifact: name: Add ${{ matrix.configuration['human_readable_platform'] }} to artifact - runs-on: macos-12 + runs-on: macos-latest strategy: fail-fast: false matrix: @@ -32,14 +32,14 @@ jobs: mkdir -p ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }} touch ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }}/${{ matrix.configuration['human_readable_platform'] }}.xcarchive - name: Upload emulated xcarchive - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: uploaded-artifact-name path: ./bindings/**/bin/release/${{ matrix.configuration['human_readable_platform'] }}/${{ matrix.configuration['human_readable_platform'] }}.xcarchive download-artifact: name: Download artifact - runs-on: macos-12 + runs-on: macos-latest needs: [ create-artifact ] steps: - name: Checkout diff --git a/README.md b/README.md index e4ea5afb..dacb7edf 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ In order to generate these bindings from scratch, you will need to clone two dep **[rust-lightning](https://github.com/lightningdevkit/rust-lightning)**, (a specific branch built for bindings compatibility): ```shell -git clone --branch 0.0.124-bindings https://github.com/lightningdevkit/rust-lightning /path/to/rust-lightning +git clone --branch 0.0.125-bindings https://github.com/lightningdevkit/rust-lightning /path/to/rust-lightning ``` **[ldk-c-bindings](https://github.com/lightningdevkit/ldk-c-bindings)**: diff --git a/scripts/build_individual_libldk.py b/scripts/build_individual_libldk.py index 180bcd9e..a1f74f90 100644 --- a/scripts/build_individual_libldk.py +++ b/scripts/build_individual_libldk.py @@ -6,8 +6,12 @@ from script_config import ScriptConfig, BuildConfig RUSTUP_PATH = os.getenv('HOME') + '/.cargo/bin/rustup' +RUSTC_PATH = os.getenv('HOME') + '/.cargo/bin/rustc' CARGO_PATH = os.getenv('HOME') + '/.cargo/bin/cargo' +# 1.62: nightly-2022-05-13 +NIGHTLY_TOOLCHAIN = 'nightly-2022-06-24' # 1.63 + def run(config: ScriptConfig): if len(config.LIBLDK_BUILD_CONFIGURATIONS) != 1: @@ -55,7 +59,10 @@ def run(config: ScriptConfig): child_environment['RUSTFLAGS'] = '--cfg=c_bindings' child_environment['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' - subprocess.check_call([RUSTUP_PATH, 'override', 'set', 'nightly-2022-05-13'], cwd=config.LDK_C_BINDINGS_DIRECTORY) + # stop cargo's obsession with x86_64-apple-ios13.0-macabi when nobody asked for it + child_environment['CFLAGS_x86_64_apple_ios_macabi'] = '--target=x86_64-apple-ios-macabi' + + subprocess.check_call([RUSTUP_PATH, 'override', 'set', NIGHTLY_TOOLCHAIN], cwd=config.LDK_C_BINDINGS_DIRECTORY) lipo_executables_input: [str] = [] @@ -95,8 +102,16 @@ def run(config: ScriptConfig): shutil.rmtree(cargo_target_directory, ignore_errors=True) subprocess.check_call([CARGO_PATH, 'clean'], cwd=config.LDK_C_BINDINGS_DIRECTORY) + rust_target_triplet = f'{rust_architecture}-apple-{rust_target_os}' + + print('Rust architecture:', rust_architecture) + print('Rust target OS:', rust_target_os) + print('Target:', rust_target_triplet) + + subprocess.check_call([RUSTC_PATH, f'+{NIGHTLY_TOOLCHAIN}', '-Z', 'unstable-options', '--print', 'target-spec-json', '--target', rust_target_triplet]) + # cargo build -Z build-std=panic_abort,std --features "std" --target "${RUST_ARCH}-apple-${RUST_TARGET_OS}" $RUST_CONFIGURATION_FLAG - build_arguments = [CARGO_PATH, 'build', '-Z', 'build-std=panic_abort,std', '--features', 'std', '--target', f'{rust_architecture}-apple-{rust_target_os}'] + build_arguments = [CARGO_PATH, 'build', '-Z', 'build-std=panic_abort,std', '--features', 'std', '--target', rust_target_triplet] if config.RUST_CONFIGURATION_FLAG: build_arguments.append(config.RUST_CONFIGURATION_FLAG) subprocess.check_call(