Skip to content

Enable EHCONT and CETCOMPAT for some binaries on Windows - #56173

Merged
kouvel merged 3 commits into
dotnet:mainfrom
kouvel:EnableEhCont
Aug 12, 2021
Merged

Enable EHCONT and CETCOMPAT for some binaries on Windows#56173
kouvel merged 3 commits into
dotnet:mainfrom
kouvel:EnableEhCont

Conversation

@kouvel

@kouvelkouvel commented Jul 22, 2021

Copy link
Copy Markdown
Contributor

@kouvelkouvel added NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) area-VM-coreclr labels Jul 22, 2021
@kouvelkouvel added this to the 6.0.0 milestone Jul 22, 2021
@kouvel
kouvel requested a review from janvorliJuly 22, 2021 17:47
@kouvelkouvel self-assigned this Jul 22, 2021

@janvorlijanvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@kouvel
kouvel marked this pull request as draft July 22, 2021 18:01
@kouvelkouvel added NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) and removed NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) labels Jul 22, 2021
@kouvel
kouvel marked this pull request as ready for review July 22, 2021 19:32
@kouvel
kouvel requested a review from janvorliJuly 22, 2021 19:32
@kouvel

Copy link
Copy Markdown
ContributorAuthor

The changes to configurecompiler.cmake were a bit too global and affecting mono builds too. I have moved the addition of switches to more local places for coreclr. @janvorli could you please take another look?

Comment threadeng/native/configurecet.cmake Outdated

@janvorlijanvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@kouvelkouvel closed this Jul 23, 2021
@kouvelkouvel reopened this Jul 23, 2021
@kouvel
kouvel marked this pull request as draft July 27, 2021 00:39
@kouvelkouvel removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 27, 2021
@kouvel
kouvel marked this pull request as ready for review August 9, 2021 18:15
@kouvelkouvel closed this Aug 9, 2021
@kouvelkouvel reopened this Aug 9, 2021
Koundinya Veluri added 3 commits August 11, 2021 13:04
- Followup to #55942
- Intended to be merged into a PR that updates to use new PGO profile data collected with the above change
- Enabled `/guard:ehcont` as a linker option for EXEs and DLLs
- Enabled `/cetcompat` as a linker option for DLLs
@kouvel
kouvel merged commit 4e850c7 into dotnet:mainAug 12, 2021
@kouvel
kouvel deleted the EnableEhCont branch August 12, 2021 01:01
@jakobbotsch

jakobbotsch commented Aug 13, 2021

Copy link
Copy Markdown
Member

Does this require compiler updates? After this change I am getting

 libucrtd.lib(cvt.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(wcrtomb.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(wcstombs.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(debug_heap.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(getmodulefilenamea.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(dbgrptt.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(terminate.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(argv_wildcards.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(exit.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(onexit.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(fdopen.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(fgetc.obj) : error LNK2046: module contains _local_unwind but was not compiled with /guard:ehcont
libucrtd.lib(fputc.obj) : error LNK2046: module contains _local_unwind but was not compiled with /guard:ehcont
libucrtd.lib(qsort.obj) : error LNK2047: module contains C++ EH or complex EH metadata but was not compiled with /guard:ehcont
libucrtd.lib(fpctrl.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
libucrtd.lib(ieee.obj) : warning LNK4291: module may contain '__except' (Structured Exception Handling) but was not compiled with /guard:ehcont; generating conservative metadata
jit\clrjit_unix_x64_x64.dll : fatal error LNK1386: could not generate metadata for one or more modules not compiled with /guard:ehcont; use /force:guardehcont to link anyways
ninja: build stopped: subcommand failed.
BUILD: Error: native component build failed. Refer to the build log files for details.
"D:\dev\dotnet\runtime\src\coreclr\..\..\artifacts\log\Debug\CoreCLR_windows__x64__Debug.log"
"D:\dev\dotnet\runtime\src\coreclr\..\..\artifacts\log\Debug\CoreCLR_windows__x64__Debug.wrn"
"D:\dev\dotnet\runtime\src\coreclr\..\..\artifacts\log\Debug\CoreCLR_windows__x64__Debug.err"

EDIT: Installing the latest Windows SDK fixed the issue.

@kouvel

Copy link
Copy Markdown
ContributorAuthor

The new switch /guard:ehcont requires compiler and linker updates, which I believe have been available for roughly a year or so. If static libraries are being used they would also have to be compiled with the new switch, mismatches would probably result in these kinds of errors.

@sandreenko

Copy link
Copy Markdown
Contributor

The new switch /guard:ehcont requires compiler and linker updates, which I believe have been available for roughly a year or so. If static libraries are being used they would also have to be compiled with the new switch, mismatches would probably result in these kinds of errors.

When I saw these errors I did git clean -dfx and updated VS to the last version (Version 16.11.0), and it did not help, what am I missing?

@kouvel

Copy link
Copy Markdown
ContributorAuthor

That's pretty much all I did too, what errors are you seeing @sandreenko?

@sandreenko

Copy link
Copy Markdown
Contributor

Thanks @jakobbotsch for the help, VS update does not install new SDKs automatically, so I needed to do "VS installer->modify->add Windows 10 SDK (10.0.19/20)"->install

@ghostghost locked as resolved and limited conversation to collaborators Sep 12, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@kouvel@jakobbotsch@sandreenko@janvorli