Build problems on MinGW

Hello everyone,

I'm struggling to get a working LLVM installation on MinGW on Windows
Vista. I have the following packages:

* LLVM 2.4
* Gnu make 3.81
* GCC 3.4.5 (mingw-vista special r3)
* Perl 5.6.1
* Texinfo 4.11
* LD (which I took to be representative of Binutils version) 2.17.50 20060824

None of these are marked "bad" in your compatibility matrix, but not
many of them are marked "good" either.

During build I get lots of missing symbol errors from LD. Near the end
it goes through a monster link step that spews many screenfuls of link
errors. Here's an example from near the end:

c:/mingw/src/llvm-2.4/Release/lib/libLLVMBitWriter.a(ValueEnumerator.o):ValueEnumerator.cpp:(.text$_ZNSt6vectorIN4llvm11
AttrListPtrESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_[std::vector<llvm::AttrListPtr,
std::al
locator<llvm::AttrListPtr>

::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::AttrListPtr*,

std::vector<llvm::AttrListP
tr, std::allocator<llvm::AttrListPtr> > >, llvm::AttrListPtr
const&)]+0x1b5): undefined reference to `llvm::AttrListPtr:
:AttrListPtr(llvm::AttrListPtr const&)'
collect2: ld returned 1 exit status

I'm not concerned with working on LLVM itself - I just want to use it,
so if there's an alternative way to get a working system on Windows
I'm open to suggestions.

Thanks for your help,
Duncan Pierce

Hello, Duncan

  • LD (which I took to be representative of Binutils version) 2.17.50 20060824

None of these are marked “bad” in your compatibility matrix, but not
many of them are marked “good” either.

During build I get lots of missing symbol errors from LD. Near the end
it goes through a monster link step that spews many screenfuls of link
errors. Here’s an example from near the end:

Smells like binutils problem. In the past I filled 2 or 3 binutils bugs as a result of LLVM compilation on mingw (all of them were fixed, but I don’t recall the specific versions of binutils, unfortunately).

Why you’re using such old binutils? 2.18.50-20080109 definitely worked for me (and release binaries were built so…).

Thank you for your reply Anton. I'm sorry it's taken a while to get
back to you. This binutils came with the MinGW installer. I have made
some progress by reinstalling according to these instructions, though
I took slightly more recent versions in some cases and also found I
needed Perl (thank you Anton and Ted):

http://blogs.tedneward.com/2008/02/24/Building+LLVM+On+Windows+Using+MinGW32.aspx

Now I can compile and install llvm-2.4 but the first step in the
tutorial fails for me with another missing symbol:

$ g++ -g tut1.cpp `llvm-config --cxxflags --ldflags --libs core` -o tut1
/mingw/lib/libLLVMSystem.a(Process.o):Process.cpp:(.text+0x8d):
undefined reference to `GetProcessMemoryInfo@12'
collect2: ld returned 1 exit status

I'm using GNU ld (GNU Binutils) 2.18.50.20080109.

Thanks for any further help you can provide,

Duncan Pierce

Hello, Duncan

$ g++ -g tut1.cpp `llvm-config --cxxflags --ldflags --libs core` -o tut1
/mingw/lib/libLLVMSystem.a(Process.o):Process.cpp:(.text+0x8d):
undefined reference to `GetProcessMemoryInfo@12'
collect2: ld returned 1 exit status

I believe you will need additional libraries like imagehlp and psapi.

Hi Anton

$ g++ -g tut1.cpp `llvm-config --cxxflags --ldflags --libs core` -o tut1
/mingw/lib/libLLVMSystem.a(Process.o):Process.cpp:(.text+0x8d):
undefined reference to `GetProcessMemoryInfo@12'
collect2: ld returned 1 exit status

I believe you will need additional libraries like imagehlp and psapi.

I have /lib/libimagehlp.a and /lib/libpsapi.a

nm --defined-only /lib/libpsapi.a | grep "GetProcessMemoryInfo" -

returns:

00000000 T _GetProcessMemoryInfo@12
00000000 I __imp__GetProcessMemoryInfo@12

And llvm-config seems to be asking for them to be picked up:

-I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2
-fomit-frame-pointer -Woverloaded-virtual
-L//lib -lpsapi -limagehlp -lm
-lLLVMCore -lLLVMSupport -lLLVMSystem

So I'm still mystified.

Best regards,
Duncan

Duncan Pierce <duncan@duncanpierce.org> writes:

I have /lib/libimagehlp.a and /lib/libpsapi.a

nm --defined-only /lib/libpsapi.a | grep "GetProcessMemoryInfo" -

returns:

00000000 T _GetProcessMemoryInfo@12
00000000 I __imp__GetProcessMemoryInfo@12

And llvm-config seems to be asking for them to be picked up:

-I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2
-fomit-frame-pointer -Woverloaded-virtual
-L//lib -lpsapi -limagehlp -lm
-lLLVMCore -lLLVMSupport -lLLVMSystem

So I'm still mystified.

Put them at the end of the library list:

-lLLVMCore -lLLVMSupport -lLLVMSystem -limagehlp -lpsapi -lm

Unless recently changed, mingw's ld resolves symbols sequentially on the
library list, it does not look on previously processed libraries, so
order is relevant.

If llvm-config puts psapi and imagehlp at the beginning of the list,
that probably is a bug on llvm-config. But llvm-config's source code
does not mention psapi and/or imagehlp at all.

Are you sure that -lpsapi and -limagehlp are on the output of
llvm-config? They are not on my mingw's LLVM, although it is several
weeks old.

Óscar Fuentes <ofv <at> wanadoo.es> writes:

Duncan Pierce <duncan <at> duncanpierce.org> writes:

> I have /lib/libimagehlp.a and /lib/libpsapi.a
> And llvm-config seems to be asking for them to be picked up:
>
> -I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2
> -fomit-frame-pointer -Woverloaded-virtual
> -L//lib -lpsapi -limagehlp -lm
> -lLLVMCore -lLLVMSupport -lLLVMSystem
>
> So I'm still mystified.

Put them at the end of the library list:

-lLLVMCore -lLLVMSupport -lLLVMSystem -limagehlp -lpsapi -lm

This works. I had a look at changing the llvm-config.in.in but my Perl hacking
skills aren't up to getting --libnames and --libfiles to work as well as --libs.

I discovered one other thing that was causing me problems on MinGW: if I use the
msys.bat to open a terminal llvm-config inserts double slashes at the start of
any absolute path it generates (e.g. //lib/LLVMX86CodeGen.o) - this breaks g++.

If I do the same thing from a DOS prompt running bash, slashes don't get doubled
and everything works fine.

Thanks once again Óscar and Anton.

Duncan Pierce

Duncan Pierce <duncan@duncanpierce.org> writes:

> I have /lib/libimagehlp.a and /lib/libpsapi.a
> And llvm-config seems to be asking for them to be picked up:
>
> -I//include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2
> -fomit-frame-pointer -Woverloaded-virtual
> -L//lib -lpsapi -limagehlp -lm
> -lLLVMCore -lLLVMSupport -lLLVMSystem
>
> So I'm still mystified.

Put them at the end of the library list:

-lLLVMCore -lLLVMSupport -lLLVMSystem -limagehlp -lpsapi -lm

This works. I had a look at changing the llvm-config.in.in but my Perl hacking
skills aren't up to getting --libnames and --libfiles to work as well as --libs.

Would you like to file a bug report? This is the way of getting it
fixed.

I discovered one other thing that was causing me problems on MinGW: if I use the
msys.bat to open a terminal llvm-config inserts double slashes at the start of
any absolute path it generates (e.g. //lib/LLVMX86CodeGen.o) - this breaks g++.

If I do the same thing from a DOS prompt running bash, slashes don't get doubled
and everything works fine.

This one also deserves a bug report. My guess is that llvm-config is
throwing backslashes (\) which are escaped at some intermediate point
and finally translated to double slashes by MSYS.

Thanks once again Óscar and Anton.

You're welcome.

This works. I had a look at changing the llvm-config.in.in but my Perl hacking
skills aren't up to getting --libnames and --libfiles to work as well as --libs.

Would you like to file a bug report? This is the way of getting it
fixed.

Done (3347)

This one also deserves a bug report. My guess is that llvm-config is
throwing backslashes (\) which are escaped at some intermediate point
and finally translated to double slashes by MSYS.

3348 - I've taken the liberty of pasting your comment here into the report.

Duncan Pierce

Hello, Duncan

I discovered one other thing that was causing me problems on MinGW: if I use the
msys.bat to open a terminal llvm-config inserts double slashes at the start of
any absolute path it generates (e.g. //lib/LLVMX86CodeGen.o) - this breaks g++.

That's strange, never seen this before. Do you have two different
version of perl installed? (for example, one msys DTK and another one
- standalone ActivePerl, etc.)

I have a /usr/bin/perl.exe (bash under DOS prompt finds this one) and
a /bin/perl.exe (msys.bat finds this one). But these are the same
according to diff --binary. I only installed one. In fact, I deleted
my entire first MinGW installation when I first found I couldn't llvm
working and reinstalled cleanly, using perl from msys.

Duncan