Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce number of dynamically linked dependencies for Windows binaries #675

Open
wants to merge 4 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build]
# These targets are used by the language server powering the IDE, st. we have cross-platform
# suport, at leat to some extent. They do not necessarily correspond to the targets used by the CI.
target = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]

[target.x86_64-pc-windows-msvc]
rustflags = [
"-C", "target-feature=+crt-static",
# see https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170
# we disable as many as possible
"-C", "link-args=/DEFAULTLIB:libucrt.lib",
"-C", "link-args=/NODEFAULTLIB:libucrtd.lib",
"-C", "link-args=/NODEFAULTLIB:ucrt.lib",
"-C", "link-args=/NODEFAULTLIB:ucrtd.lib",
"-C", "link-args=/DEFAULTLIB:libvcruntime.lib",
"-C", "link-args=/NODEFAULTLIB:libvcruntimed.lib",
"-C", "link-args=/NODEFAULTLIB:vcruntime.lib",
"-C", "link-args=/NODEFAULTLIB:vcruntimed.lib",
"-C", "link-args=/DEFAULTLIB:libcmt.lib",
"-C", "link-args=/NODEFAULTLIB:libcmtd.lib",
"-C", "link-args=/NODEFAULTLIB:msvcrt.lib",
"-C", "link-args=/NODEFAULTLIB:msvcrtd.lib",
"-C", "link-args=/NODEFAULTLIB:msvcmrt.lib",
"-C", "link-args=/NODEFAULTLIB:msvcmrtd.lib",
"-C", "link-args=/NODEFAULTLIB:libcpmt.lib",
"-C", "link-args=/NODEFAULTLIB:libcpmtd.lib",
"-C", "link-args=/NODEFAULTLIB:msvcprt.lib",
"-C", "link-args=/NODEFAULTLIB:msvcprtd.lib",
]
29 changes: 22 additions & 7 deletions .github/workflows/rcc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@ on:
workflow_call: {}

env:
RCC_TAG: "v17.18.0" # Update omd/Licenses.csv in the Checkmk repo when changing this.
RCC_REF: "v17.29.1_micromamba_v1.5.8_from_github" # Update omd/Licenses.csv in the Checkmk repo when changing this.
GO_VERSION: "1.20.x"
RUBY_VERSION: "2.7"

jobs:
analyse_changes:
if: always()
runs-on: ubuntu-latest
outputs:
rcc_yaml_changed: ${{ steps.filter.outputs.rcc_yaml }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
rcc_yaml:
- '.github/workflows/rcc.yaml'

check_cache:
runs-on: ubuntu-latest
outputs:
Expand All @@ -18,20 +32,21 @@ jobs:
- id: restore-from-cache
uses: actions/cache/restore@v4
with:
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
key: rcc-${{ env.RCC_REF }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
path: build
lookup-only: true

build_and_cache:
runs-on: ubuntu-latest
needs:
- analyse_changes
- check_cache
if: ${{ needs.check_cache.outputs.cache_hit != 'true' }}
if: ${{ (needs.analyse_changes.outputs.rcc_yaml_changed == 'true') || (needs.check_cache.outputs.cache_hit != 'true') }}
steps:
- uses: actions/checkout@v4
with:
repository: robocorp/rcc
ref: ${{ env.RCC_TAG }}
repository: elabit/rcc
ref: ${{ env.RCC_REF }}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
Expand All @@ -42,7 +57,7 @@ jobs:
- run: rake test
- uses: actions/cache/save@v4
with:
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
key: rcc-${{ env.RCC_REF }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
path: build

upload:
Expand All @@ -57,7 +72,7 @@ jobs:
- uses: actions/cache/restore@v4
with:
path: build
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
key: rcc-${{ env.RCC_REF }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
fail-on-cache-miss: true
- uses: actions/upload-artifact@v4
with:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/robotmk_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ jobs:

- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
target: x86_64-pc-windows-gnu
# 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-pc-windows-gnu --release
- run: cargo build --target=x86_64-pc-windows-msvc --release

- uses: actions/upload-artifact@v4
with:
name: rmk_windows64
path: |
${{ github.workspace }}/target/x86_64-pc-windows-gnu/release/robotmk_scheduler.exe
${{ github.workspace }}/target/x86_64-pc-windows-gnu/release/robotmk_agent_plugin.exe
${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/robotmk_scheduler.exe
${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/robotmk_agent_plugin.exe
if-no-files-found: error
8 changes: 6 additions & 2 deletions .github/workflows/system_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
target: x86_64-pc-windows-gnu
- run: cargo test --target=x86_64-pc-windows-gnu --test test_scheduler -- --nocapture --ignored
# 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 test --target=x86_64-pc-windows-msvc --test test_scheduler -- --nocapture --ignored
env:
TEST_DIR: C:\test_scheduler
RCC_BINARY_PATH: C:\windows64\rcc.exe
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
type:
- { os: windows-latest, target: x86_64-pc-windows-gnu }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
steps:
- uses: actions/checkout@v4
Expand All @@ -22,7 +22,11 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
components: rustfmt, clippy
target: ${{ matrix.type.target }}
# 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 fmt -- --check
- run: cargo test --all-targets --target ${{ matrix.type.target }} -- --skip test_scheduler
- run: cargo run --example termination --target ${{ matrix.type.target }}
Expand Down
2 changes: 1 addition & 1 deletion ci
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ main() {
;;

'cargo-examples')
cargo run --example termination
cargo run --example termination --target "${target}"
;;

'check-all')
Expand Down
11 changes: 11 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The channel and the targets defined here are taken into account by
# actions-rust-lang/setup-rust-toolchain when setting up the CI environment.

[toolchain]
channel = "1.83"

[toolchain.linux]
targets = ["x86_64-unknown-linux-gnu"]

[toolchain.windows]
targets = ["x86_64-pc-windows-msvc"]
Loading