Skip to content
Merged
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*.slnx text=auto eol=lf
*.sh eol=lf
*.ps1 eol=lf
# Keep eol stable so hashFiles() over this file yields the same cache key on every
# runner OS (it's part of the sentry-native cache key in build.yml). See #5298.
*.cmake eol=lf
CHANGELOG.md merge=union


Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-${{ matrix.rid }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-${{ matrix.rid }}-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
enableCrossOsArchive: true

- run: scripts/build-sentry-native.ps1
Expand Down Expand Up @@ -143,47 +143,47 @@ jobs:
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-linux-x64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-linux-x64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (linux-arm64)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.rid == 'linux-arm64') }}
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-linux-arm64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-linux-arm64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (linux-musl-x64)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.rid == 'linux-musl-x64') }}
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-linux-musl-x64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-linux-musl-x64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (linux-musl-arm64)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.rid == 'linux-musl-arm64') }}
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-linux-musl-arm64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-linux-musl-arm64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (macos)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.rid == 'macos') }}
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-macos-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-macos-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (win-x64)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.rid == 'win-x64') }}
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-win-x64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-win-x64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true
enableCrossOsArchive: true

Expand All @@ -192,7 +192,7 @@ jobs:
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-win-arm64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-win-arm64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true
enableCrossOsArchive: true

Expand Down Expand Up @@ -314,7 +314,7 @@ jobs:
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-win-x64-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-win-x64-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true
enableCrossOsArchive: true

Expand Down Expand Up @@ -408,7 +408,7 @@ jobs:
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-macos-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-macos-${{ hashFiles('scripts/build-sentry-native.ps1', 'src/Sentry/Platforms/Native/windows-config.cmake') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Setup Environment
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes 🐛

- fix: LNK4291 when publishing a Native AOT `WinExe` with Control Flow Guard enabled by @jamescrosswell in [#5298](https://github.com/getsentry/sentry-dotnet/pull/5298)
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated

## 6.6.0

### Features ✨
Expand Down
17 changes: 15 additions & 2 deletions src/Sentry/Platforms/Native/windows-config.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Include debug info in the static library itself. See https://github.com/getsentry/sentry-native/issues/895 for context.
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "C Flags for RelWithDebInfo" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "CXX Flags for RelWithDebInfo" FORCE)
set(_sentry_msvc_flags "/Z7 /O2 /Ob1 /DNDEBUG")

# Build the static lib with Control Flow Guard metadata so a Native AOT consumer that links it
# with <ControlFlowGuard>Guard</ControlFlowGuard> doesn't get LNK4291 against every __try/__except
# translation unit ("module may contain '__except' but was not compiled with /guard:ehcont").
# See https://github.com/getsentry/sentry-dotnet/issues/4801.
# /guard:cf applies to both x64 and arm64; /guard:ehcont (EH continuation metadata) is x64-only,
# and LNK4291 itself is an x64-only warning, so only emit ehcont for the x64 build.
string(APPEND _sentry_msvc_flags " /guard:cf")
Comment thread
jamescrosswell marked this conversation as resolved.
Outdated
if("$ENV{PROCESSOR_ARCHITECTURE}" STREQUAL "AMD64")
string(APPEND _sentry_msvc_flags " /guard:ehcont")
endif()
Comment thread
sentry[bot] marked this conversation as resolved.
Outdated

set(CMAKE_C_FLAGS_RELWITHDEBINFO "${_sentry_msvc_flags}" CACHE STRING "C Flags for RelWithDebInfo" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${_sentry_msvc_flags}" CACHE STRING "CXX Flags for RelWithDebInfo" FORCE)
Loading