Hi,

On Tue, 4 Sep 2018, Frédéric wrote:

I use mingw-w64 5.0.4 and gcc 8.2.0 with success on linux to build
Windows programs. I use the binutils and standard ld for that. ld is
extremely slow and I would like to know if there is any possibility to
use llvm linker (lld) instead with object files created by gcc/g++.

I have already tried to replace g++ by clang++ on the link command
line with the option -fuse-ld=lld but got the following error:
/usr/bin/ld.lld: error: file.o: invalid data encoding

Then I added option -target i686-w64-mingw32 (for 32 bits) and got the
following error:
lld: error: unable to find library -lgcc_eh

I found on internet that this could be fixed by creating a symlink in
lib/gcc/i686-w64-mingw32/8.2.0/: libgcc_eh.a -> libgcc.a

Then I got this:
lld-link: error: file.o: undefined symbol: _pthread_mutex_destroy
lld-link: error: file.o: undefined symbol: _pthread_mutex_lock
lld-link: error: file.o: undefined symbol: _pthread_mutex_unlock
lld-link: error: file.o: undefined symbol: _pthread_mutex_init

I then add -lpthread (-lwinpthread gives the same as the 2 files are
the same); I got this:
lld-link: error: libsqlite3.a(sqlite3.o): undefined symbol:
_InterlockedCompareExchange@12
libsqlite3.a was made by ar from binutils.

Here I am stucked! Any idea how to continue? Is it the right think to do?

Yes, this is feasible, with a few caveats.

However, lld isn't fully compatible with all details of the GNU linker for the mingw target - in particular, lld can't handle import libraries produced by binutils. So it's not right now usable as a drop-in replacement in an existing mingw setup, you need a separate mingw environment built from scratch with llvm-dlltool.

I'm maintaining a setup for building just such an environment, have a look at https://github.com/mstorsjo/llvm-mingw. I'm only using compiler_rt/libunwind/libcxxabi/libcxx instead of libgcc/libstdc++ though, but for most practical matters it should pretty much work. See the readme there for known issues though. (There's work in progress for remedying some of them as well.)

This toolchain assumes a very much bleeding edge Clang/LLD (the build scripts will check out a known working version and build that). Right now it should also work pretty well to replace the build-llvm.sh step with a prebuilt version of the 7.0 release candidates, in case they happen to include the llvm-dlltool binary.

// Martin
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to