This is an archive of the discontinued LLVM Phabricator instance.

Clang: add support to mingw driver for compiler-rt, libc++ and lld
AbandonedPublic

Authored by martell on Jul 9 2015, 12:21 PM.

Details

Reviewers
yaron.keren
rnk
Summary

In terms of clang and mingw-w64 going forward I think the goal should be to get clang working without gcc.
I have achieved this but currently we look relative to the gcc program.
I need input on how to best change this

The patch does several things atm

  1. it adds the -no-pthread option

while mingw doesn't add -lpthread by default mingw-w64 does.
I saw a note recently in the source with a FIXME on how to handle this.

I think the best way to fix this would be to set a bool in the driver.
Currently we check for mingw-w64's folder layout and then mingw org if that fails
We could set the bool here and use that to decide if we should use pthread by default ?

Ideally however mingw-w64 should support c11 threads and we should not link to pthreads by default but thats not down to us
I may work on this in the future from that end.

mingw-w64 is provided with a -no-pthread option by gcc because of this inconsistency and it is needed to build mingw-w64 from source.
To have clang be able to build mingw-w64 we nned to handle / ignore this option without ending complination.

  1. It adds support for using compiler-rt and sets it to the default

The user can override this with -rtlib=libgcc if they want that but I think the default should be a clang standalone toolchain
Relative compiler-rt diff http://reviews.llvm.org/D11085

  1. It adds support for using libc++ and sets it to the default

The user can override this with -stdlib=libstdc++ if they want that but I think the default should be libc++ for that standalone toolchain

  1. It adds support for lld but does not set it to the default because it is not ready for gnu mode on windows

I have submitted patches to lld to support this

  1. It adds support for thumb2pe machine for the linker

I have patches for binutils that will be merged once I fill in my FSF waiver and get it merged

Thanks for taking the time to read :)

Diff Detail

Event Timeline

martell updated this revision to Diff 29371.Jul 9 2015, 12:21 PM
martell retitled this revision from to Clang: add support to mingw driver for compiler-rt, libc++ and lld.
martell updated this object.
martell added reviewers: yaron.keren, rnk.
yaron.keren edited edge metadata.Jul 9 2015, 1:02 PM

Could you break this into five independent patches so they may be discussed (and approved) one by one?

martell updated this object.Jul 9 2015, 2:27 PM
martell edited edge metadata.
martell added a comment.EditedJul 9 2015, 2:35 PM

Could you break this into five independent patches so they may be discussed (and approved) one by one?

Sure, I'll abandon this once the others are done

EDIT:

I think it would be best to have 2 and 3 in the same patch because they both depend on common lines of code.

To get them merged I will leave the default as libstdc++ and libgcc
I will mark it as adding support for -rtlib and -stdlib to the driver

Also 4 and 5 would probably best put together also as lld is the program that came up with the name thumb2pe and there is no code in binutils for this atm

Update 1,4 and 5 have been merged
Will do a patch for 2,3 and then abandon this

martell abandoned this revision.Jul 22 2015, 1:35 PM

All the components of this have been merged :)
Thanks guys