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

fixes #18146; fixes #19372; disable tlsEmulation on windows; static link pthreads with mingw #21668

Merged
merged 2 commits into from
Apr 14, 2023

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Apr 14, 2023

fixes #18146
fixes #19372

@ringabout ringabout changed the title fixes #15392; disable tlsEmulation on windows; Bstatic lpthread fixes #15392; disable tlsEmulation on windows; static link libwinthreads DLL Apr 14, 2023
@ringabout ringabout changed the title fixes #15392; disable tlsEmulation on windows; static link libwinthreads DLL fixes #18146; disable tlsEmulation on windows; static link libwinthreads DLL Apr 14, 2023
@ringabout ringabout changed the title fixes #18146; disable tlsEmulation on windows; static link libwinthreads DLL fixes #18146; disable tlsEmulation on windows; static link libwinthreads DLL with mingw Apr 14, 2023
@ringabout ringabout changed the title fixes #18146; disable tlsEmulation on windows; static link libwinthreads DLL with mingw fixes #18146; fixes #19372; disable tlsEmulation on windows; static link libwinthreads DLL with mingw Apr 14, 2023
@ringabout ringabout marked this pull request as draft April 14, 2023 14:59
@ringabout ringabout changed the title fixes #18146; fixes #19372; disable tlsEmulation on windows; static link libwinthreads DLL with mingw fixes #18146; fixes #19372; disable tlsEmulation on windows; static link pthreads with mingw Apr 14, 2023
@ringabout ringabout marked this pull request as ready for review April 14, 2023 16:15
@ringabout
Copy link
Member Author

ringabout commented Apr 14, 2023

I tested it by deleting libwinthreads.dll. I assume it's the only dep that is affected when disabling tlsemulation.

@Araq Araq merged commit 512517c into devel Apr 14, 2023
@Araq Araq deleted the pr_tls_off_on_windows branch April 14, 2023 20:52
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 512517c

Hint: mm: orc; opt: speed; options: -d:release
166804 lines; 8.917s; 612.586MiB peakmem

@rockcavera
Copy link
Contributor

rockcavera commented Apr 19, 2023

I tested it by deleting libwinthreads.dll. I assume it's the only dep that is affected when disabling tlsemulation.

@ringabout I tested it here, after this PR, but it keeps dynamically linking pthread. Tested with the gcc compilers provided by Nim.

How did I test and verify that I needed "libwinpthread-1.dll"? Steps to reproduce:

  • 1: open Windows cmd
  • 2: nim c some_nim_code
  • 3: set PATH=""
  • 4: some_nim_code

When trying to run it will give an error saying that it needs "libwinpthread-1.dll".

@ringabout
Copy link
Member Author

Looking into it

@ringabout
Copy link
Member Author

ringabout commented Apr 19, 2023

It seems that apart from the direct use of libpthread, there is another shared dll using libwinpthread since {.passl: "-Wl,-Bstatic -lpthread".} works.

@rockcavera
Copy link
Contributor

It seems that apart from the direct use of libpthread, there is another shared dll using libwinpthread since {.passl: "-Wl,-Bstatic -lpthread".} works.

Yes, it works. That's how I was able to link statically. I'm just not sure it will force static link to all the other -lLibs passed as well. Perhaps a way to add -Wl,-Bstatic -lpthread as the last link parameter on Windows?

@ringabout
Copy link
Member Author

Here is the link parameter

-Bstatic -lpthread -Bdynamic -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 c:/users/blue/desktop/exe/mingw64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/crtend.o

It seems that -lpthread will be passed twice so the first one is canceled.

@ringabout
Copy link
Member Author

ringabout commented Apr 20, 2023

It seems that if -Bstatic -lpthread is added in config, it will be appended after user configs.

capocasa pushed a commit to capocasa/Nim that referenced this pull request May 15, 2023
…indows; static link pthreads with mingw (nim-lang#21668)

* fixes nim-lang#18146; disable tlsEmulation on windows; static link libwinthreads DLL

* whatever
capocasa pushed a commit to capocasa/Nim that referenced this pull request May 16, 2023
…indows; static link pthreads with mingw (nim-lang#21668)

* fixes nim-lang#18146; disable tlsEmulation on windows; static link libwinthreads DLL

* whatever
bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
…indows; static link pthreads with mingw (nim-lang#21668)

* fixes nim-lang#18146; disable tlsEmulation on windows; static link libwinthreads DLL

* whatever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tlsEmulation:on doesn't work with IC Combine --gc:arc with --threads:on slow down the performance heavily.
3 participants