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

MinGW: Enable C++ threads with mcfgthreads #73195

Merged
merged 11 commits into from
Nov 12, 2019

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Nov 11, 2019

Motivation for this change

This uses https://github.com/lhmouse/mcfgthread to get C++ threads with mingw without the slow POSIX threads emulation. The bootstrapping infrastructure is set up so this is factored through threadsCross attribute which could be parameterized to support both gthreads (GCC's threading interface) implementations. In any case, the threading library is built with gccCrossStageStatic + libcCross / lldClangNoCXX, which works.

I declare this worth merging because I cross compiled Nix with it!

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @angerman @volth

Currently this is set up to be mcfgthreads, but it could be something
else instead.
Seems to build just fine without it, maybe it was just using C++ threads
which mcfgthread provides?
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Nov 11, 2019
Working around broken build for now.
I think those deps could be made to build, but I didn't want to get
bogged down investigating further. "Use flags" are always a good thing,
so this is fine for now.
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 12, 2019
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 12, 2019
@Ericson2314 Ericson2314 merged commit 01429fc into NixOS:master Nov 12, 2019
@Ericson2314 Ericson2314 deleted the mingw-mcfthreads branch November 12, 2019 02:43
@angerman
Copy link
Contributor

This is pretty neat as it will likely allow to build rocksdb, however, we should note the following somewhere I believe:

This project uses a number of undocumented NT system calls for efficiency reasons and may be broken in future Windows versions.
The author gives no warranty for this project. Use it at your own risk.

I'm not sure what implications this might or might not incur wrt to building and distributing binaries for windows.


stdenv.mkDerivation {
pname = "mcfgthreads";
version = "git";
Copy link
Member

Choose a reason for hiding this comment

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

We usually use date of commit here instead of git.

@Ericson2314
Copy link
Member Author

@angerman I think it's probably fine for now; MS cares more about binary compat that anyone else, including these sorts of unstable interfaces. If it becomes a problem, it's all set up to be easy to switch to the pthreads emulation approach.

@Mic92 Thanks, will fix.

@tex tex mentioned this pull request Nov 15, 2019
10 tasks
@angerman
Copy link
Contributor

angerman commented Jun 5, 2020

@Ericson2314 I'm running into lots of issues with this. I'm appreciative of this, however

  • it doesn't compile on macOS, and such breaks macOS -> windows cross compilation for at least haskell.nix
  • I can't get a linux -> windows rust compiler built with this.

Is there a global switch to turn this off?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: fetch 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants