From 1d8868b3c621eebba8d960d92a86f646ba6d79bf Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:10:34 +0000 Subject: [PATCH 1/5] merge bitcoin#30451: remove Darwin ENV unsetting --- contrib/guix/libexec/build.sh | 12 +++++++++--- depends/hosts/darwin.mk | 10 ++-------- depends/packages/qt.mk | 2 ++ depends/patches/qt/darwin_no_libm.patch | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 depends/patches/qt/darwin_no_libm.patch diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index ea1d5079ee3d..b44eff598e22 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -73,11 +73,9 @@ unset OBJCPLUS_INCLUDE_PATH export C_INCLUDE_PATH="${NATIVE_GCC}/include" export CPLUS_INCLUDE_PATH="${NATIVE_GCC}/include/c++:${NATIVE_GCC}/include" -export OBJC_INCLUDE_PATH="${NATIVE_GCC}/include" -export OBJCPLUS_INCLUDE_PATH="${NATIVE_GCC}/include/c++:${NATIVE_GCC}/include" case "$HOST" in - *darwin*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; + *darwin*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; # Required for qt/qmake *mingw*) export LIBRARY_PATH="${NATIVE_GCC}/lib" ;; *) NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)" @@ -182,6 +180,14 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \ x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \ x86_64_linux_STRIP=x86_64-linux-gnu-strip +case "$HOST" in + *darwin*) + # Unset now that Qt is built + unset C_INCLUDE_PATH + unset CPLUS_INCLUDE_PATH + unset LIBRARY_PATH + ;; +esac ########################### # Source Tarball Building # diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 564381d1e930..a50e36110dc0 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -50,17 +50,11 @@ darwin_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip") # Disable adhoc codesigning (for now) when using LLVM tooling, to avoid # non-determinism issues with the Identifier field. -darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \ - -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \ - -u LIBRARY_PATH \ - $(clang_prog) --target=$(host) \ +darwin_CC=$(clang_prog) --target=$(host) \ -isysroot$(OSX_SDK) -nostdlibinc \ -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks -darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \ - -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \ - -u LIBRARY_PATH \ - $(clangxx_prog) --target=$(host) \ +darwin_CXX=$(clangxx_prog) --target=$(host) \ -isysroot$(OSX_SDK) -nostdlibinc \ -iwithsysroot/usr/include/c++/v1 \ -iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 18c01e7cf063..575a0e76f49e 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -25,6 +25,7 @@ $(package)_patches += memory_resource.patch $(package)_patches += clang_18_libpng.patch $(package)_patches += utc_from_string_no_optimize.patch $(package)_patches += windows_lto.patch +$(package)_patches += darwin_no_libm.patch $(package)_patches += zlib-timebits64.patch $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) @@ -258,6 +259,7 @@ define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/fast_fixed_dtoa_no_optimize.patch && \ patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ patch -p1 -i $($(package)_patch_dir)/windows_lto.patch && \ + patch -p1 -i $($(package)_patch_dir)/darwin_no_libm.patch && \ patch -p1 -i $($(package)_patch_dir)/zlib-timebits64.patch && \ mkdir -p qtbase/mkspecs/macx-clang-linux &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ diff --git a/depends/patches/qt/darwin_no_libm.patch b/depends/patches/qt/darwin_no_libm.patch new file mode 100644 index 000000000000..38a94beeb7a6 --- /dev/null +++ b/depends/patches/qt/darwin_no_libm.patch @@ -0,0 +1,17 @@ +build: remove explicit -lm link from qttools + +This causes issues with at least the macOS cross build, and shouldn't +actually be required anywhere else. GCC with libstdc++ will already get libm. + +--- a/qtbase/src/corelib/tools/tools.pri ++++ b/qtbase/src/corelib/tools/tools.pri +@@ -111,9 +111,6 @@ qtConfig(easingcurve) { + tools/qtimeline.cpp + } + +-# Note: libm should be present by default becaue this is C++ +-unix:!macx-icc:!vxworks:!haiku:!integrity:!wasm: LIBS_PRIVATE += -lm +- + TR_EXCLUDE += ../3rdparty/* + + # MIPS DSP From 2f28f3e5af525221507c386b41f6a99a5bccdc1d Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:21:58 +0000 Subject: [PATCH 2/5] ci: replace `runner.os` with adding CI `Dockerfile` to `hashFiles` `runner.os` is irrelevant since we run everything inside Docker containers, we should instead be relying on the file that defines the base image. --- .github/workflows/build-depends.yml | 6 +++--- .github/workflows/build-src.yml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-depends.yml b/.github/workflows/build-depends.yml index e942a59776f8..fedb8760f712 100644 --- a/.github/workflows/build-depends.yml +++ b/.github/workflows/build-depends.yml @@ -61,10 +61,10 @@ jobs: path: | depends/built depends/${{ steps.setup.outputs.HOST }} - key: ${{ runner.os }}-depends-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-${{ hashFiles('depends/packages/*') }} + key: depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-${{ hashFiles('depends/packages/*') }} restore-keys: | - ${{ runner.os }}-depends-${{ inputs.build-target }}-${{ hashFiles('depends/packages/*') }} - ${{ runner.os }}-depends-${{ inputs.build-target }} + depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}- + depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}- - name: Build depends run: env ${{ steps.setup.outputs.DEP_OPTS }} HOST=${{ steps.setup.outputs.HOST }} make -j$(nproc) -C depends diff --git a/.github/workflows/build-src.yml b/.github/workflows/build-src.yml index 45411eaa51f5..dfbecc9a3956 100644 --- a/.github/workflows/build-src.yml +++ b/.github/workflows/build-src.yml @@ -58,11 +58,11 @@ jobs: with: path: | /cache - key: ${{ runner.os }}-${{ inputs.build-target }}-${{ github.sha }} + key: ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-${{ inputs.build-target }}-${{ github.sha }} - ${{ runner.os }}-${{ inputs.build-target }}-${{ steps.setup.outputs.HOST }} - ${{ runner.os }}-${{ inputs.build-target }} + ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }} + ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.HOST }} + ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }} - name: Build source and run unit tests run: | From 9841155ead6586159e32ab192e3466744c3808aa Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:42:20 +0000 Subject: [PATCH 3/5] ci: cleanup restore keys `restore-keys` is only meant to specify fallback keys if the primary key doesn't result in a cache hit. re-specifying the primary key is redundant also, remove keys that are unlikely to exist --- .github/workflows/build-depends.yml | 1 - .github/workflows/build-src.yml | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-depends.yml b/.github/workflows/build-depends.yml index fedb8760f712..d3b855a575a3 100644 --- a/.github/workflows/build-depends.yml +++ b/.github/workflows/build-depends.yml @@ -51,7 +51,6 @@ jobs: depends/sources key: depends-sources-${{ hashFiles('depends/packages/*') }} restore-keys: | - depends-sources-${{ hashFiles('depends/packages/*') }} depends-sources- - name: Restore cached depends diff --git a/.github/workflows/build-src.yml b/.github/workflows/build-src.yml index dfbecc9a3956..7caaf232c909 100644 --- a/.github/workflows/build-src.yml +++ b/.github/workflows/build-src.yml @@ -60,9 +60,7 @@ jobs: /cache key: ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }} restore-keys: | - ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }} - ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.HOST }} - ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }} + ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}- - name: Build source and run unit tests run: | From 56d8a8e7d614530e3efb91fdfc2730738e54f776 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 18 Feb 2025 08:09:49 +0000 Subject: [PATCH 4/5] ci: add SDK (extracted) sources to separate SDK cache We cannot add it to the sources cache because we share the cache among all variants and as the caches are immutable, the first one to finish will decide the cache for all subsequent use. This will prevent the SDKs from being saved and will cause failures in the next step as it fetches the common cache, most likely saved by a Linux variant and finds no cache. Saving it in the source cache isn't a great option either because it will get frequently invalidated. Better to just give it its own cache. --- .github/workflows/build-depends.yml | 17 ++++++++++++++++- .github/workflows/build-src.yml | 9 +++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-depends.yml b/.github/workflows/build-depends.yml index d3b855a575a3..5eafd46f9ca5 100644 --- a/.github/workflows/build-depends.yml +++ b/.github/workflows/build-depends.yml @@ -53,6 +53,16 @@ jobs: restore-keys: | depends-sources- + - name: Cache SDKs + uses: actions/cache@v4 + if: inputs.build-target == 'mac' + with: + path: | + depends/SDKs + key: depends-sdks-${{ hashFiles('depends/hosts/darwin.mk') }} + restore-keys: | + depends-sdks- + - name: Restore cached depends uses: actions/cache/restore@v4 id: restore @@ -66,7 +76,12 @@ jobs: depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}- - name: Build depends - run: env ${{ steps.setup.outputs.DEP_OPTS }} HOST=${{ steps.setup.outputs.HOST }} make -j$(nproc) -C depends + run: | + export HOST="${{ steps.setup.outputs.HOST }}" + if [ "${HOST}" = "x86_64-apple-darwin" ]; then + ./contrib/containers/guix/scripts/setup-sdk + fi + env ${{ steps.setup.outputs.DEP_OPTS }} make -j$(nproc) -C depends - name: Save depends cache uses: actions/cache/save@v4 diff --git a/.github/workflows/build-src.yml b/.github/workflows/build-src.yml index 7caaf232c909..88f91811f118 100644 --- a/.github/workflows/build-src.yml +++ b/.github/workflows/build-src.yml @@ -44,6 +44,15 @@ jobs: echo "PR_BASE_SHA=${{ github.event.pull_request.base.sha || '' }}" >> $GITHUB_OUTPUT shell: bash + - name: Restore SDKs cache + uses: actions/cache/restore@v4 + if: inputs.build-target == 'mac' + with: + path: | + depends/SDKs + key: depends-sdks-${{ hashFiles('depends/hosts/darwin.mk') }} + fail-on-cache-miss: true + - name: Restore depends cache uses: actions/cache/restore@v4 with: From 106500c1124073c80869fae4eddb3f0a407ca670 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 14 Feb 2025 11:27:48 +0000 Subject: [PATCH 5/5] ci: add x86_64 macOS cross-compilation build to GitHub Actions --- .github/workflows/build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 424e47e43665..6b14bf2dfa1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,6 +49,14 @@ jobs: build-target: linux64_nowallet container-path: ${{ needs.container.outputs.path }} + depends-mac: + name: x86_64-apple-darwin + uses: ./.github/workflows/build-depends.yml + needs: [container] + with: + build-target: mac + container-path: ${{ needs.container.outputs.path }} + depends-win64: name: x86_64-w64-mingw32 uses: ./.github/workflows/build-depends.yml @@ -129,6 +137,15 @@ jobs: container-path: ${{ needs.container.outputs.path }} depends-key: ${{ needs.depends-linux64.outputs.key }} + src-mac: + name: mac-build + uses: ./.github/workflows/build-src.yml + needs: [container, depends-mac] + with: + build-target: mac + container-path: ${{ needs.container.outputs.path }} + depends-key: ${{ needs.depends-mac.outputs.key }} + src-win64: name: win64-build uses: ./.github/workflows/build-src.yml