diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 87e6ec997c1a..0599891f0490 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,6 +21,18 @@ runs: restore-keys: ${{ runner.os }} max-size: 10000M + - name: Set up mold (Linux) + uses: rui314/setup-mold@v1 + if: runner.os == 'Linux' + with: + make-default: false + - name: Set up mold (macOS) + shell: bash + if: runner.os == 'macOS' + run: | + brew update + brew install mold + - name: Cache Gradle dependencies uses: actions/cache@v4 with: diff --git a/build.py b/build.py index 1a8ddc23ff7f..a30e14e516a8 100755 --- a/build.py +++ b/build.py @@ -361,6 +361,8 @@ def build_native(): os.environ["CARGO_INCREMENTAL"] = "0" if ccache := shutil.which("ccache"): os.environ["NDK_CCACHE"] = ccache + if mold := shutil.which("mold"): + os.environ["NDK_MOLD"] = mold build_rust_src(targets) build_cpp_src(targets) diff --git a/native/src/Application.mk b/native/src/Application.mk index 82f8c272d257..0aaafce5e277 100644 --- a/native/src/Application.mk +++ b/native/src/Application.mk @@ -7,6 +7,10 @@ APP_THIN_ARCHIVE := true APP_STRIP_MODE := none APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true +ifdef NDK_MOLD +APP_LDFLAGS += -fuse-ld=$(NDK_MOLD) -Wl,-z,muldefs +endif + ifdef MAGISK_DEBUG NDK_APP_OUT := ./obj/debug