[LLVMdev] llvm build errors on windows/mingw32

162 views
Skip to first unread message

Ronald Pijnacker

unread,
Oct 1, 2009, 7:22:37 AM10/1/09
to llv...@cs.uiuc.edu, Ronald Pijnacker
Hi all,

When I try to build llvm on windows/mingw32, I get the following error:

In file included from c:/work/mingw/src/llvm/lib/System/Signals.cpp:33:
c:/work/mingw/src/llvm/lib/System/Win32/Signals.inc: In function 'LONG LLVMUnhandledExceptionFilter(_EXCEPTION_POINTERS*)':
c:/work/mingw/src/llvm/lib/System/Win32/Signals.inc:275: error: exception handling disabled, use -fexceptions to enable
make[1]: *** [/c/work/mingw/src/build.llvm/lib/System/Release/Signals.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/c/work/mingw/src/build.llvm/lib/System'

Thanks,

Ronald
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

罗勇刚(Yonggang Luo)

unread,
Oct 1, 2009, 4:41:18 PM10/1/09
to Ronald Pijnacker, LLVM Dev
Wow, I also meet this error before, I'll be pleasure if anyone can
solve this problem, and by the way, are you using msys as the building
env? It's seems that mingw/cmake is working but mingw/msys, and I
didn't ever try with mingw/cygwin:) thanks.

2009/10/1, Ronald Pijnacker <pijn...@dse.nl>:

--
从我的移动设备发送

此致

罗勇刚
Yours
sincerely,
Yonggang Luo

罗勇刚(Yonggang Luo)

unread,
Oct 1, 2009, 7:07:43 PM10/1/09
to Ronald Pijnacker, LLVM Dev
Well, Now I get the solution.

Please, someone can apply the patch.

Just modify the makefile resident in lib/System

But, a new error is appeared
llvm[2]: Linking Debug unit test ADT
d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78: undefined reference to `GetProcessMemoryInfo@12'
collect2: ld returned 1 exit status
make[2]: *** [Debug/ADTTests.exe] Error 1
make[2]: Leaving directory `/d/objs/llvm/msys/unittests/ADT'
make[1]: *** [ADT/.makeall] Error 2
make[1]: Leaving directory `/d/objs/llvm/msys/unittests'
make: *** [all] Error 1


I don't know why, And Pijnacker, do you get the same error?

path-for-msys.patch

Óscar Fuentes

unread,
Oct 1, 2009, 9:30:21 PM10/1/09
to llv...@cs.uiuc.edu
"罗勇刚(Yonggang Luo)" <luoyo...@gmail.com> writes:

> Well, Now I get the solution.
> Please, someone can apply the patch.
>
> Just modify the makefile resident in lib/System

I'm afraid this patch is not acceptable. It activates C++ exception
support unconditionally while building libLLVMSystem, which is used
everywhere.

You'll better investigate why exception support is required for MSYS
while all other configure-based builds work fine without it.

[snip]

--
Óscar

罗勇刚(Yonggang Luo)

unread,
Oct 2, 2009, 12:41:36 AM10/2/09
to Óscar Fuentes, LLVM Dev

I'm afraid this patch is not acceptable. It activates C++ exception
support unconditionally while building libLLVMSystem, which is used
everywhere.

You'll better investigate why exception support is required for MSYS
while all other configure-based builds work fine without it.

Sorry, I got no idea to solve this problem, do you have a method to get it done? 
Yours
   sincerely,
Yonggang Luo

Jay Foad

unread,
Oct 2, 2009, 7:01:49 AM10/2/09
to Óscar Fuentes, llv...@cs.uiuc.edu
> You'll better investigate why exception support is required for MSYS
> while all other configure-based builds work fine without it.

Surely it's required for any system that uses
lib/System/Win32/Signals.inc, because there's code in that file that
uses try/catch.

MingW is the only system I know of that uses that file; Cygwin
pretends to be Unix-like, so it uses lib/System/Unix/Signals.inc
instead. So I'd suggest the attached (untested) patch.

Jay.

libsystem.patch

Ronald Pijnacker

unread,
Oct 2, 2009, 5:44:00 AM10/2/09
to 罗勇刚(Yonggang Luo), Ronald Pijnacker, LLVM Dev

Yes, I get the same error.

Dimitry Andric

unread,
Oct 2, 2009, 10:08:05 AM10/2/09
to luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
On 2009-10-02 01:07, 罗勇刚(Yonggang Luo) wrote:
> Well, Now I get the solution.
> Please, someone can apply the patch.
>
> Just modify the makefile resident in lib/System
>
> But, a new error is appeared
> llvm[2]: Linking Debug unit test ADT
> d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78:
> undefined reference to `GetProcessMemoryInfo@12'

GetProcessMemoryInfo should be defined in psapi.lib, but AFAICS mingw32
doesn't have this import lib. It is included in the MS Platform SDK,
but I'm not sure whether you can link that into mingw32 programs...

Ronald Pijnacker

unread,
Oct 2, 2009, 1:34:05 PM10/2/09
to Dimitry Andric, luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
> On 2009-10-02 01:07, 罗勇刚(Yonggang Luo) wrote:
> > Well, Now I get the solution.
> > Please, someone can apply the patch.
> >
> > Just modify the makefile resident in lib/System
> >
> > But, a new error is appeared
> > llvm[2]: Linking Debug unit test ADT
> > d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78:
> > undefined reference to `GetProcessMemoryInfo@12'
>
> GetProcessMemoryInfo should be defined in psapi.lib, but AFAICS mingw32
> doesn't have this import lib. It is included in the MS Platform SDK,
> but I'm not sure whether you can link that into mingw32 programs...

msdn suggests kernel32, but that is already included.

Ronald

Dimitry Andric

unread,
Oct 2, 2009, 2:25:27 PM10/2/09
to Jay Foad, Óscar Fuentes, llv...@cs.uiuc.edu
On 2009-10-02 13:01, Jay Foad wrote:
> Surely it's required for any system that uses
> lib/System/Win32/Signals.inc, because there's code in that file that
> uses try/catch.
>
> MingW is the only system I know of that uses that file; Cygwin
> pretends to be Unix-like, so it uses lib/System/Unix/Signals.inc
> instead. So I'd suggest the attached (untested) patch.

It won't work as-is, because HOST_OS is not defined at that point in the
Makefile. Including Makefile.config helps, at least in my case. :)

E.g:

Index: lib/System/Makefile
===================================================================
--- lib/System/Makefile (revision 83249)
+++ lib/System/Makefile (working copy)
@@ -11,6 +11,12 @@
LIBRARYNAME = LLVMSystem
BUILD_ARCHIVE = 1

+include $(LEVEL)/Makefile.config
+
+ifeq ($(HOST_OS),MingW)
+REQUIRES_EH := 1
+endif
+
EXTRA_DIST = Unix Win32 README.txt

include $(LEVEL)/Makefile.common

Dimitry Andric

unread,
Oct 2, 2009, 2:51:17 PM10/2/09
to Ronald Pijnacker, luoyo...@gmail.com, LLVM Dev
On 2009-10-02 19:34, Ronald Pijnacker wrote:
>> On 2009-10-02 01:07, 罗勇刚(Yonggang Luo) wrote:
>>> d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78:
>>> undefined reference to `GetProcessMemoryInfo@12'
>> GetProcessMemoryInfo should be defined in psapi.lib, but AFAICS mingw32
>> doesn't have this import lib. It is included in the MS Platform SDK,
>> but I'm not sure whether you can link that into mingw32 programs...
> msdn suggests kernel32, but that is already included.

My apologies, I was mistaken, as Yonggang pointed out to me privately;
mingw32 does come with a libpsapi.lib file, but in your case it does not
get added to the libs to be linked with, apparently.

In my case, the configure script does check for the existence of
libpsapi.a, and adds both a HAVE_LIBPSAPI define to config.h, and
-lpsapi to LIBS.

Can you find anything in your config.log file about libpsapi?

Ronald Pijnacker

unread,
Oct 2, 2009, 2:59:56 PM10/2/09
to Dimitry Andric, luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
> >>> d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78:
> >>> undefined reference to `GetProcessMemoryInfo@12'
> >> GetProcessMemoryInfo should be defined in psapi.lib, but AFAICS mingw32
> >> doesn't have this import lib. It is included in the MS Platform SDK,
> >> but I'm not sure whether you can link that into mingw32 programs...
> > msdn suggests kernel32, but that is already included.
>
> My apologies, I was mistaken, as Yonggang pointed out to me privately;
> mingw32 does come with a libpsapi.lib file, but in your case it does not
> get added to the libs to be linked with, apparently.
>
> In my case, the configure script does check for the existence of
> libpsapi.a, and adds both a HAVE_LIBPSAPI define to config.h, and
> -lpsapi to LIBS.
>
> Can you find anything in your config.log file about libpsapi?

#define HAVE_LIBPSAPI 1
in config.h

Ronald

Ronald Pijnacker

unread,
Oct 2, 2009, 3:07:18 PM10/2/09
to Dimitry Andric, luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
> > >>> d:/objs/llvm/msys/Debug/lib/libLLVMSystem.a(Process.o):e:/Downloads/llvm-trunk/lib/System/Win32/Process.inc:78:
> > >>> undefined reference to `GetProcessMemoryInfo@12'
> > >> GetProcessMemoryInfo should be defined in psapi.lib, but AFAICS mingw32
> > >> doesn't have this import lib. It is included in the MS Platform SDK,
> > >> but I'm not sure whether you can link that into mingw32 programs...
> > > msdn suggests kernel32, but that is already included.
> >
> > My apologies, I was mistaken, as Yonggang pointed out to me privately;
> > mingw32 does come with a libpsapi.lib file, but in your case it does not
> > get added to the libs to be linked with, apparently.
> >
> > In my case, the configure script does check for the existence of
> > libpsapi.a, and adds both a HAVE_LIBPSAPI define to config.h, and
> > -lpsapi to LIBS.
> >
> > Can you find anything in your config.log file about libpsapi?
>
> #define HAVE_LIBPSAPI 1
> in config.h

I had a close look at the link line, and -lpsapi is specified before -lLLVMSystem (which is giving the error).
When I put -lpsapi after -lLLVMSystem, it links ok.

Benjamin Kramer

unread,
Oct 2, 2009, 3:37:41 PM10/2/09
to Ronald Pijnacker, luoyo...@gmail.com, LLVM Dev

Am 02.10.2009 um 21:07 schrieb Ronald Pijnacker:

> I had a close look at the link line, and -lpsapi is specified before
> -lLLVMSystem (which is giving the error).
> When I put -lpsapi after -lLLVMSystem, it links ok.

I commited a fix for this problem and a modified version of Jay's
patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090928/088265.html

I hope MingW builds work again now :)

Dimitry Andric

unread,
Oct 2, 2009, 4:00:52 PM10/2/09
to Benjamin Kramer, luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
On 2009-10-02 21:37, Benjamin Kramer wrote:
>> I had a close look at the link line, and -lpsapi is specified before
>> -lLLVMSystem (which is giving the error).
>> When I put -lpsapi after -lLLVMSystem, it links ok.
>
> I commited a fix for this problem and a modified version of Jay's
> patch here:
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090928/088265.html
>
> I hope MingW builds work again now :)

Now the problem comes from another side, as GNU ld seems rather picky
about the library order:

$ g++ -I/d/Home/Dim/Src/llvm/include -I/d/Home/Dim/Src/llvm/obj/include -I/d/Home/Dim/Src/llvm/obj/unittests/Transforms/Utils -I/d/Home/Dim/Src/llvm/unittests/Transforms/Utils -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/d/Home/Dim/Src/llvm/utils/unittest/googletest/include/ -Wno-variadic-macros -g -fno-exceptions -Woverloaded-virtual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -g -L/d/Home/Dim/Src/llvm/obj/Debug/lib -L/d/Home/Dim/Src/llvm/obj/Debug/lib -o Debug/UtilsTests.exe /d/Home/Dim/Src/llvm/obj/unittests/Transforms/Utils/Debug/Cloning.o -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMSystem -lpthread -lpsapi -limagehlp -lm -lGoogleTest -lUnitTestMain
d:/Home/Dim/Src/llvm/obj/Debug/lib/libGoogleTest.a(gtest.o):gtest.cc:(.text$_ZN4llvm14raw_os_ostreamC1ERSo[llvm::raw_os_ostream::raw_os_ostream(std::basic_ostre
am<char, std::char_traits<char> >&)]+0x1e): undefined reference to `vtable for llvm::raw_os_ostream'
d:/Home/Dim/Src/llvm/obj/Debug/lib/libGoogleTest.a(gtest.o):gtest.cc:(.text$_ZN4llvm23convertible_fwd_ostreamD1Ev[llvm::convertible_fwd_ostream::~convertible_fw
d_ostream()]+0x2b): undefined reference to `llvm::raw_os_ostream::~raw_os_ostream()'
d:/Home/Dim/Src/llvm/obj/Debug/lib/libGoogleTest.a(gtest.o):gtest.cc:(.text$_ZN4llvm23convertible_fwd_ostreamD0Ev[llvm::convertible_fwd_ostream::~convertible_fw
d_ostream()]+0x2b): undefined reference to `llvm::raw_os_ostream::~raw_os_ostream()'


collect2: ld returned 1 exit status

E.g. now libGoogletest.a requires some symbols from libLLVMSupport.a,
and it has been moved to the end of the linking command line.

When I make the order:

-lGoogleTest
-lUnitTestMain
-lLLVMTransformUtils
-lLLVMipa
-lLLVMAnalysis
-lLLVMTarget
-lLLVMMC
-lLLVMCore
-lLLVMSupport
-lLLVMSystem
-lpthread
-lpsapi
-limagehlp
-lm

it links okay. I have tested a similar fix as r83252, which I saw you
just committed, and that seems to work. At least, it's far into the
examples directory by now, without problems...

Dimitry Andric

unread,
Oct 2, 2009, 4:08:34 PM10/2/09
to Benjamin Kramer, luoyo...@gmail.com, Ronald Pijnacker, LLVM Dev
On 2009-10-02 22:00, Dimitry Andric wrote:
> it links okay. I have tested a similar fix as r83252, which I saw you
> just committed, and that seems to work. At least, it's far into the
> examples directory by now, without problems...

Apologies for replying to myself, but I just want to confirm that it now
(with r83252) builds completely to the end. Thanks for the quick fix.

Ronald Pijnacker

unread,
Oct 2, 2009, 6:30:01 PM10/2/09
to Dimitry Andric, Ronald Pijnacker, luoyo...@gmail.com, LLVM Dev
> On 2009-10-02 22:00, Dimitry Andric wrote:
> > it links okay. I have tested a similar fix as r83252, which I saw you
> > just committed, and that seems to work. At least, it's far into the
> > examples directory by now, without problems...
>
> Apologies for replying to myself, but I just want to confirm that it now
> (with r83252) builds completely to the end. Thanks for the quick fix.
>

Thanks. Indeed it builds ok now.

Ronald

Reply all
Reply to author
Forward
0 new messages