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

Enable EHCONT and CETCOMPAT for some binaries on Windows #56173

Merged
merged 3 commits into from
Aug 12, 2021

Conversation

kouvel
Copy link
Member

@kouvel kouvel commented Jul 22, 2021

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

@janvorli janvorli left a comment

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
@kouvel kouvel 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 janvorli July 22, 2021 19:32
@kouvel
Copy link
Member Author

kouvel commented Jul 22, 2021

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?

Copy link
Member

@janvorli janvorli left a comment

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 closed this Jul 23, 2021
@kouvel kouvel reopened this Jul 23, 2021
@kouvel kouvel marked this pull request as draft July 27, 2021 00:39
@kouvel kouvel 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
@kouvel kouvel closed this Aug 9, 2021
@kouvel kouvel reopened this Aug 9, 2021
- Followup to dotnet#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:main Aug 12, 2021
@kouvel kouvel deleted the EnableEhCont branch August 12, 2021 01:01
@jakobbotsch
Copy link
Member

jakobbotsch commented Aug 13, 2021

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
Member Author

kouvel commented Aug 13, 2021

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
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
Member Author

kouvel commented Aug 13, 2021

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

@sandreenko
Copy link
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

@ghost ghost locked as resolved and limited conversation to collaborators Sep 12, 2021
Sign up for free to 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