Skip to content

Commit

Permalink
linux: use mold linker for prebuilt binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilledheart committed May 25, 2024
1 parent dc66778 commit d094922
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/releases-linux-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ jobs:
path: |
${{ github.workspace }}/debian_bullseye_${{ matrix.arch }}-sysroot
key: ${{ runner.os }}-sysroot-${{ matrix.arch }}-${{ hashFiles('scripts/sysroots.json') }}-v3
- name: Setup mold linker
uses: rui314/setup-mold@v1
with:
make-default: false
- name: Setup build flags for mold
if: ${{ matrix.arch != 'riscv32' && matrix.arch != 'mipsel' && matrix.arch != 'mips64el' }}
run: |
echo "EXTRA_BUILD_FLAGS=-use-mold -enable-lto=false" >> $GITHUB_ENV
- name: Build build tool
run: |
cd tools
Expand Down Expand Up @@ -165,12 +173,12 @@ jobs:
rm -f *.tar.gz
- name: Build TGZ packages (CLI and Server)
run: |
./tools/build --variant cli --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
./tools/build --variant server --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
./tools/build --variant cli --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc ${{ env.EXTRA_BUILD_FLAGS }}
./tools/build --variant server --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc ${{ env.EXTRA_BUILD_FLAGS }}
- name: Build TGZ packages (GUI)
if: ${{ matrix.arch != 'riscv64' && matrix.arch != 'riscv32' }}
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
./tools/build --variant gui --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc ${{ env.EXTRA_BUILD_FLAGS }}
- name: Run tests (i386 and amd64)
if: ${{ matrix.arch == 'i386' || matrix.arch == 'amd64' }}
run: |
Expand Down
7 changes: 7 additions & 0 deletions tools/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var cmakeBuildConcurrencyFlag int
var clangPath string
var useLibCxxFlag bool
var enableLtoFlag bool
var useMoldFlag bool
var useTcmallocFlag bool

var clangTidyModeFlag bool
Expand Down Expand Up @@ -168,6 +169,7 @@ func InitFlag() {

flag.BoolVar(&useLibCxxFlag, "use-libcxx", true, "Use Custom libc++")
flag.BoolVar(&enableLtoFlag, "enable-lto", true, "Enable lto")
flag.BoolVar(&useMoldFlag, "use-mold", false, "Use Mold Linker")
flag.BoolVar(&useTcmallocFlag, "use-tcmalloc", true, "Use tcmalloc if possible")

flag.BoolVar(&clangTidyModeFlag, "clang-tidy-mode", getEnvBool("ENABLE_CLANG_TIDY", false), "Enable Clang Tidy Build")
Expand Down Expand Up @@ -801,6 +803,11 @@ func buildStageGenerateBuildScript() {
} else {
cmakeArgs = append(cmakeArgs, "-DENABLE_LTO=off")
}
if useMoldFlag {
cmakeArgs = append(cmakeArgs, "-DUSE_MOLD=on")
} else {
cmakeArgs = append(cmakeArgs, "-DUSE_MOLD=off")
}
if clangTidyModeFlag {
cmakeArgs = append(cmakeArgs, "-DENABLE_CLANG_TIDY=on", fmt.Sprintf("-DCLANG_TIDY_EXECUTABLE=%s", clangTidyExecutablePathFlag))
}
Expand Down

0 comments on commit d094922

Please sign in to comment.