Skip to content

Commit

Permalink
Make linker flags consistent between release and local development.
Browse files Browse the repository at this point in the history
The /DEPENDENTLOADFLAG was not actually applying to the release builds.
  • Loading branch information
AustinWise committed Apr 6, 2024
1 parent ecd873e commit bfaf686
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
11 changes: 0 additions & 11 deletions .cargo/config

This file was deleted.

23 changes: 23 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# NOTE NOTE NOTE NOTE NOTE NOTE
#
# For some reason these flags are NOT respected when running in GitHub actions. They are respected
# when building locally. So keep these settings in sync with .github/workflows/release.yml .
#
# NOTE NOTE NOTE NOTE NOTE NOTE


# Use LLD since it is faster.
# TODO: figure out how to make this work in CI
#[target.x86_64-unknown-linux-gnu]
#rustflags = ["-C", "link-arg=-fuse-ld=lld"]
#[target.aarch64-unknown-linux-gnu]
#rustflags = ["-C", "link-arg=-fuse-ld=lld"]

# We only link to DLLs in System32, so limit the OS loader to looking in there.
# https://learn.microsoft.com/cpp/build/reference/dependentloadflag
# Build all crates with a statically linked MSVCRT. Specifically crates
# that use `cc` in their build scripts (like libgit2-sys), will detect this
# and compile objects appropriately. If there is a way to put this into a
# Cargo config file some where, let me know. .cargo/config did not work.
[target.'cfg(target_env = "msvc")']
rustflags = ["-C", "link-arg=/DEPENDENTLOADFLAG:0x800", "-C", "target-feature=+crt-static"]
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ jobs:

steps:

# Build all crates with a statically linked MSVCRT. Specifically crates
# that use `cc` in their build scripts (like libgit2-sys), will detect this
# and compile objects appropriatly. If there is a way to put this into a
# Cargo config file some where, let me know. .cargo/config did not work.
- name: Statically link MSVCRT
# NOTE NOTE NOTE NOTE NOTE NOTE
#
# See .cargo/config.toml for an explination of these settings.
# Keep these settings and that file in sync.
#
# NOTE NOTE NOTE NOTE NOTE NOTE
- name: Rust Flags
shell: bash
if: matrix.os == 'windows'
run: |
echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV
echo "RUSTFLAGS=-C target-feature=+crt-static -C target-feature=+crt-static" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
Expand Down

0 comments on commit bfaf686

Please sign in to comment.