1

I am trying to build LLVM using MinGW-w64 (GCC 8.1.0). After cmake .. -G"Mingw Makefiles" and mingw32-make it started building, but after a while this error hapenned:

<...>
[  5%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CTagsEmitter.cpp.obj
[  5%] Built target obj.llvm-tblgen
[  5%] Linking CXX executable ..\..\bin\llvm-tblgen.exe
../../lib/libLLVMSupport.a(Threading.cpp.obj): In function `IterateProcInfo<getProcessorGroups()::<lambda()>::<lambda(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)> >':
C:/.../llvm-12.0.0.src/lib/Support/Windows/Threading.inc:143: undefined reference to `_imp__GetLogicalProcessorInformationEx@12'
C:/.../llvm-12.0.0.src/lib/Support/Windows/Threading.inc:148: undefined reference to `_imp__GetLogicalProcessorInformationEx@12'
C:/.../llvm-12.0.0.src/lib/Support/Windows/Threading.inc:143: undefined reference to `_imp__GetLogicalProcessorInformationEx@12'
C:/.../llvm-12.0.0.src/lib/Support/Windows/Threading.inc:148: undefined reference to `_imp__GetLogicalProcessorInformationEx@12'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [utils\TableGen\CMakeFiles\llvm-tblgen.dir\build.make:192: bin/llvm-tblgen.exe] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:9445: utils/TableGen/CMakeFiles/llvm-tblgen.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2

I would guess that the error is linked with this question, and there is/are some missing libraries and adding those using -D"CMAKE_CXX_FLAGS=-l..." would fix the error. But what are those libraries? I got the error at 5% and there might be more libraries that I need to link (and the 5% already took pretty long time, so I don't want to wait for 50% to find out that there was an error).
So, What libraries do I need to link LLVM with?

galaxy001
  • 404
  • 5
  • 16
  • https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlogicalprocessorinformationex – Alan Birtles May 24 '21 at 16:47
  • @AlanBirtles What library is it in? I tried adding `-D"CMAKE_CXX_F:AGS=-lkernel32"` to cmake, but it still failed at the same place. What should I change? – galaxy001 May 25 '21 at 17:54

1 Answers1

3

-DCMAKE_CXX_FLAGS= is for compiler flags, not linker flags. Try something like this: -DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -lkernel32".

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40