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

Windows: support more Mingw-w64 versions #2578

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 8 additions & 3 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ else:
switch("passC", "-mno-avx512f")
switch("passL", "-mno-avx512f")

# omitting frame pointers in nim breaks the GC
# Omitting frame pointers in nim breaks the GC:
# https://github.com/nim-lang/Nim/issues/10625
switch("passC", "-fno-omit-frame-pointer")
switch("passL", "-fno-omit-frame-pointer")
if not defined(windows):
# ...except on Windows where the Nim bug doesn't manifest and this option
Copy link
Contributor

@zah zah May 27, 2021

Choose a reason for hiding this comment

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

Why wouldn't the Nim bug manifest on Windows?

This is not a frequently appearing bug, but a theoretical risk in the way the conservative stack scanning is implemented that might result in a crash that would be extremely hard to track down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No pointer mangling in the Mingw version of glibc. See this issue for the mechanism: nim-lang/Nim#10625

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you point me to the documentation regarding the lack of pointer mangling in mingw? Perhaps there is some compile-time assertions that can added to the code to verify that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

A check for the definition of PTR_MANGLE would be a good additional precaution - it could be added at the bottom of the main nim module:

{.emit: """

#ifdef ASSUME_NO_PTR_MANGLE
#ifdef PTR_MANGLE
#error "This build assumes that pointer mangling is disabled. See config.nims for details"
#endif
#endif

""".}

# crashes GCC in some Mingw-w64 versions:
# https://sourceforge.net/p/mingw-w64/bugs/880/
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86593
switch("passC", "-fno-omit-frame-pointer")
switch("passL", "-fno-omit-frame-pointer")

--threads:on
--opt:speed
Expand Down