Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Add support for mingw-gcc. #171

Closed
wants to merge 4 commits into from
Closed

Add support for mingw-gcc. #171

wants to merge 4 commits into from

Conversation

rubensf
Copy link

@rubensf rubensf commented Mar 10, 2021

Note that this is also blocked by #130.
That error also affects @llvm-project/llvm:llvm-mca-headers.

This doesn't build everything. Particularly, the last
error I got through was on setenv not being declared in
llvm/llvm/unittests/Support/ThreadPool.cpp. I imagine the issue might be
related to some of the other headers that we're including for linux and
posix only.

Note that I can't get mingw-gcc to work with RBE. GCC on windows
will try to canonize paths that look shorter than the original ones:
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libcpp/files.c#L405.

That means that relative includes (eg "lib/Support/../../", eg [1]) are made
absolute, which end up showing an absolute path on the .d files.

[1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/AArch64TargetParser.cpp#L58

###############################################################################

# Other windows toolchains have these by default
build:mingw_gcc --cxxopt=-DHAVE_UNISTD_H=1 --host_cxxopt=-DHAVE_UNISTD_H=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I could run builds (at least partially) using clang-cl and msvc without those on config.bzl - it seems they're picked by default?

Since only mingw needed them, I put them here instead. Wdyt? Or do you mean setting a bazel constraint set for when mingw is used?

(my compiler-foo-ness is subpar so bear with me if I'm missing something obvious :))

Copy link
Contributor

Choose a reason for hiding this comment

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

Or do you mean setting a bazel constraint set for when mingw is used?

I meant this. This is ok though.

What we should really do is detect the machine capabilities and encode it that way. The current method is really just a shortcut because Bazel is not well-equipped for that.

Copy link
Author

Choose a reason for hiding this comment

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

I tried doing what you asked, but bazel is really challenging. Trying to set select conditions on anything that's not @bazel_tools//src/conditions:os (eg @bazel_tools//tools/cpp:mingw, //:my_platform, //:my_constraint) yielded either a "Your target can't be found" or "Your BUILD file can't be found" or "invalid constraint key" :/

Comment on lines 77 to 90
build:mingw_gcc --linkopt=-lole32 --host_linkopt=-lole32
build:mingw_gcc --linkopt=-luuid --host_linkopt=-luuid
build:mingw_gcc --linkopt=-lversion --host_linkopt=-lversion
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing these are deps of particular libraries? It would be nice to not have to add them globally

Copy link
Author

Choose a reason for hiding this comment

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

I moved them into the specific libraries. I also tried compiling them with msvc, which would complain about LNK4044... I tried adding (host_)linkopt=/IGNORE:4044 but no luck, the warnings are still there.

Copy link
Contributor

Choose a reason for hiding this comment

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

So as currently configured (with them on the specific targets), this adds LNK4044 warnings to MSVC? That's worse than having them in the bazelrc, I think. I can take a look next week about trying to detect mingw properly, but otherwise let's just leave things in the bazelrc as you had previously. @chandlerc thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

When trying to run with

bazelisk build --config=msvc --compiler=msvc @llvm-project//llvm:llvm-tblgen
...
LINK : warning LNK4044: unrecognized option '/lole32'; ignored
LINK : warning LNK4044: unrecognized option '/luuid'; ignored
...

I think these are safe, albeit annoyingly verbose?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah warning spam is IMO indirectly unsafe though because it makes people ignore other warnings. I think it's not fair to degrade the MSVC build experience to add support for mingw_gcc

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@GMNGeoffrey GMNGeoffrey requested a review from chandlerc March 10, 2021 22:08
rubensf added 3 commits March 12, 2021 19:52
Note that this is also blocked by #130.
That error also affects @llvm-project/llvm:llvm-mca-headers.

This doesn't build _everything_. Particularly, the last
error I got through was on setenv not being declared in
llvm/llvm/unittests/Support/ThreadPool.cpp. I imagine the issue might be
related to some of the other headers that we're including for linux and
posix only.
@rubensf
Copy link
Author

rubensf commented Mar 12, 2021

Also added --compiler=mingw-gcc

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants