Skip to content

Commit 5c4f3be

Browse files
committed
Use MSBuild when building LLVM on Windows due to PDB issues with Ninja.
1 parent f65d410 commit 5c4f3be

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

build/scripts/Build.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function get_msbuild_path()
1414
end
1515

1616
function msbuild(sln, conf)
17-
local msbuild_path = path.normalize(path.join(get_msbuild_path(), "msbuild.exe"))
17+
local msbuild_path = "msbuild.exe"
1818
local sln = path.normalize(sln)
1919

2020
local cmd = msbuild_path .. " " .. sln

build/scripts/LLVM.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ function cmake(gen, conf, builddir, options)
221221
options = options .. " -DLLVM_USE_LINKER=/usr/bin/ld.lld"
222222
end
223223

224+
if os.ishost("windows") then
225+
options = options .. "-Thost=x64"
226+
end
227+
224228
local cmd = cmake .. " -G " .. '"' .. gen .. '"'
225229
.. ' -DLLVM_BUILD_TOOLS=false'
226230
.. ' -DLLVM_ENABLE_DUMP=true'
@@ -360,7 +364,7 @@ function build_llvm(llvm_build)
360364
os.mkdir(llvm_build)
361365

362366
local conf = get_llvm_configuration_name()
363-
local use_msbuild = false
367+
local use_msbuild = true
364368
if os.ishost("windows") and use_msbuild then
365369
cmake(get_cmake_generator(), conf, llvm_build)
366370
local llvm_sln = path.join(llvm_build, "LLVM.sln")
@@ -372,6 +376,7 @@ function build_llvm(llvm_build)
372376
if is32bits then
373377
options = options .. (is32bits and " -DLLVM_BUILD_32_BITS=true" or "")
374378
end
379+
375380
cmake("Ninja", conf, llvm_build, options)
376381
ninja('"' .. llvm_build .. '"')
377382
ninja('"' .. llvm_build .. '"', "clang-headers")
@@ -393,25 +398,26 @@ function package_llvm(conf, llvm, llvm_build)
393398
os.copydir(llvm_build .. "/include", out .. "/build/include")
394399

395400
local llvm_msbuild_libdir = "/" .. conf .. "/lib"
396-
local lib_dir = os.ishost("windows") and os.isdir(llvm_msbuild_libdir)
401+
local lib_dir = (os.ishost("windows") and os.isdir(llvm_build .. llvm_msbuild_libdir))
397402
and llvm_msbuild_libdir or "/lib"
398403
local llvm_build_libdir = llvm_build .. lib_dir
399404

400405
if os.ishost("windows") and os.isdir(llvm_build_libdir) then
401-
os.copydir(llvm_build_libdir, out .. "/build" .. lib_dir, "*.lib")
406+
os.copydir(llvm_build_libdir, out .. "/build/lib", "*.lib")
402407
else
403408
os.copydir(llvm_build_libdir, out .. "/build/lib", "*.a")
404409
end
405410

406411
os.copydir(llvm .. "/tools/clang/include", out .. "/tools/clang/include")
407412
os.copydir(llvm_build .. "/tools/clang/include", out .. "/build/tools/clang/include")
408-
os.copydir(llvm_build .. "/lib/clang", out .. "/lib/clang")
413+
414+
os.copydir(llvm_build_libdir .. "/clang", out .. "/lib/clang")
409415

410416
os.copydir(llvm .. "/tools/clang/lib/CodeGen", out .. "/tools/clang/lib/CodeGen", "*.h")
411417
os.copydir(llvm .. "/tools/clang/lib/Driver", out .. "/tools/clang/lib/Driver", "*.h")
412418
os.copydir(llvm .. "/tools/clang/lib/Driver/ToolChains", out .. "/tools/clang/lib/Driver/ToolChains", "*.h")
413419

414-
local out_lib_dir = out .. "/build" .. lib_dir
420+
local out_lib_dir = out .. "/build/lib"
415421
if os.ishost("windows") then
416422
os.rmfiles(out_lib_dir, "LLVM*ObjCARCOpts*.lib")
417423
os.rmfiles(out_lib_dir, "clang*ARC*.lib")

0 commit comments

Comments
 (0)