From 04c10f6665c9a99a055f5a720b7e06299b988415 Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Fri, 23 Aug 2024 14:41:39 +0200 Subject: [PATCH] Linux: Build static binaries CMK-18811 --- .github/workflows/rcc.yaml | 3 ++- .github/workflows/robotmk_build.yaml | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rcc.yaml b/.github/workflows/rcc.yaml index 46deb90a..2952e161 100644 --- a/.github/workflows/rcc.yaml +++ b/.github/workflows/rcc.yaml @@ -38,8 +38,9 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ env.RUBY_VERSION }} - - run: rake build + - run: CGO_ENABLED=0 rake build - run: rake test + - run: ldd build/linux64/rcc | grep "statically linked" - uses: actions/cache/save@v4 with: key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }} diff --git a/.github/workflows/robotmk_build.yaml b/.github/workflows/robotmk_build.yaml index ba454336..2fbdc6b4 100644 --- a/.github/workflows/robotmk_build.yaml +++ b/.github/workflows/robotmk_build.yaml @@ -33,21 +33,25 @@ jobs: steps: - uses: actions/checkout@v4 + - run: sudo apt-get update + - run: sudo apt-get install -y musl-tools - uses: actions-rust-lang/setup-rust-toolchain@v1.9 with: - target: x86_64-unknown-linux-gnu + target: x86_64-unknown-linux-musl # By default, setup-rust-toolchain sets "-D warnings". As a side effect, the settings in # .cargo/config.toml are ignored: # https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags # "There are four mutually exclusive sources of extra flags" rustflags: "" - - run: cargo build --target=x86_64-unknown-linux-gnu --release + - run: cargo build --target=x86_64-unknown-linux-musl --release + - run: ldd target/x86_64-unknown-linux-musl/release/robotmk_scheduler | grep "statically linked" + - run: ldd target/x86_64-unknown-linux-musl/release/robotmk_agent_plugin | grep "statically linked" - uses: actions/upload-artifact@v4 with: name: rmk_linux64 path: | - target/x86_64-unknown-linux-gnu/release/robotmk_scheduler - target/x86_64-unknown-linux-gnu/release/robotmk_agent_plugin + target/x86_64-unknown-linux-musl/release/robotmk_scheduler + target/x86_64-unknown-linux-musl/release/robotmk_agent_plugin if-no-files-found: error