[llvm-dev] using the bat script build_llvm_package.bat on windows

Alexandre Ganea via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 12 20:25:18 PDT 2020


You have Strawberry Perl installed, and that comes with MinGW. cmake picks up the GNU binutils inside that distribution, instead of MSVC cl.exe. Like Brian suggested, there are too many link jobs going on, so you could re-run `ninja check-all -j 2`, but that will be slower to build.

If you want to build the first stage with MSVC, do this (because cmake doesn’t like backslashes):

D:\llvm-project> set VS2017=%VCToolsInstallDir:\=/%

And the re-run cmake, telling it explicitly which compiler it should use (similar to what you’ll do for the second stage):
D:\llvm-project\build1> cmake -GNinja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS="llvm;clang;lld" -DCMAKE_C_COMPILER="%VS2017%/bin/HostX64/x64/cl.EXE" -DCMAKE_CXX_COMPILER="%VS2017%/bin/HostX64/x64/cl.EXE" -DCMAKE_LINKER="%VS2017%/bin/HostX64/x64/link.EXE"

De : llvm-dev <llvm-dev-bounces at lists.llvm.org> De la part de blackthirt33n . via llvm-dev
Envoyé : April 12, 2020 6:59 PM
À : llvm-dev at lists.llvm.org
Objet : Re: [llvm-dev] using the bat script build_llvm_package.bat on windows

after following the instructions for  ninja check-all:

FAILED: bin/libclang.dll lib/liblibclang.dll.a
cmd.exe /C "cd . && C:\Strawberry\c\bin\c++.exe  -Wa,-mbig-obj -Werror=date-time
 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-fi
eld-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-unin
itialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno
-comment -fno-common -Woverloaded-virtual -fno-strict-aliasing  -O2  C:/temp/llv
m-build/llvm-project/build1/tools/clang/tools/libclang/libclang.def -shared -o b
in\libclang.dll -Wl,--out-implib,lib\liblibclang.dll.a -Wl,--major-image-version
,11,--minor-image-version,0 @CMakeFiles\libclang.rsp  && cd ."
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-m
ingw32/bin/ld.exe: cannot find lib/libLLVMCore.a: Too many open files
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-m
ingw32/bin/ld.exe: cannot find lib/libLLVMRemarks.a: Too many open files
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-m
ingw32/bin/ld.exe: cannot find lib/libLLVMBitstreamReader.a: Too many open files

On Sun, Apr 12, 2020 at 1:25 PM Alexandre Ganea <alexandre.ganea at ubisoft.com<mailto:alexandre.ganea at ubisoft.com>> wrote:
build_llvm_package.bat is only a template for building releases.

You can use it as reference, but for a two-stage build the simplest you can do is:


  1.  Ensure cmake, ninja build, python, GnuWin32 are installed and available in %PATH%.
  2.  Start “x64 Native Tools Command Prompt for VS 2017” from the Start menu/Visual Studio 2017.
  3.  ‘cd’ to the root of your git checkout and run:


D:\llvm-project> mkdir build1 && cd build1

D:\llvm-project\build1> cmake -GNinja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS="llvm;clang;lld"
(…)

D:\llvm-project\build1> ninja check-all

The first stage will therefore use MSVC. If the above commands succeed, you can move on to stage 2:

D:\llvm-project\build1> cd .. && mkdir build2 && cd build2

D:\llvm-project\build2> cmake -GNinja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_LIBXML2=OFF -DCMAKE_C_COMPILER="../build1/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER="../build1/bin/clang-cl.exe" -DCMAKE_LINKER="../build1/bin/lld-link.exe" -DLLVM_ENABLE_LLD=ON -DCMAKE_CXX_FLAGS="-Xclang -O3" -DCMAKE_C_FLAGS="-Xclang -O3" -DLLVM_ENABLE_PROJECTS="llvm;clang;lld" -DCLANG_TABLEGEN="../build1/bin/clang-tblgen.exe" -DLLVM_TABLEGEN="../build1/bin/llvm-tblgen.exe"

D:\llvm-project\build2> ninja check-all

You should have now the binaries for the second stage in build2\bin.

This is only an example. You can then take a look at https://llvm.org/docs/CMake.html for extra cmake flags that can be used to tweak your build. You could for example use ThinLTO on the second stage, by adding -DLLVM_ENABLE_LTO=Thin. You can also use `cmake-gui` if you don’t want to go through command-lines (ensure it points to the right build stage).

Best,
Alex.

De : llvm-dev <llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>> De la part de blackthirt33n . via llvm-dev
Envoyé : April 11, 2020 7:46 PM
À : llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
Objet : [llvm-dev] using the bat script build_llvm_package.bat on windows

where should the file build_llvm_package.bat be placed and how should the build_llvm_package.bat be called?
or
is there a another way to do a two stage build of the llvm project on windows starting with using visual studio 2017 community.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200413/14f44a67/attachment.html>


More information about the llvm-dev mailing list