Browse Source

Added support for specifying build target architecture when building LLVM.

Fixes https://github.com/mono/CppSharp/issues/694.
pull/809/head
Joao Matos 8 years ago
parent
commit
d6049dc49e
  1. 29
      build/scripts/LLVM.lua
  2. 4
      docs/BuildingLLVM.md

29
build/scripts/LLVM.lua

@ -2,6 +2,16 @@ require "Build"
require "Utils" require "Utils"
require "../Helpers" require "../Helpers"
newoption {
trigger = "arch",
value = "x86",
description = "Choose a particular architecture / bitness",
allowed = {
{ "x86", "x86 32-bits" },
{ "x64", "x64 64-bits" },
}
}
local llvm = path.getabsolute(basedir .. "/../deps/llvm") local llvm = path.getabsolute(basedir .. "/../deps/llvm")
-- If we are inside vagrant then clone and build LLVM outside the shared folder, -- If we are inside vagrant then clone and build LLVM outside the shared folder,
@ -63,9 +73,10 @@ function get_vs_version()
end end
function get_toolset_configuration_name() function get_toolset_configuration_name()
local arch = _OPTIONS["arch"]
if os.is("windows") then if os.is("windows") then
local vsver = _ACTION local vsver = _ACTION
local arch = "x86"
if not string.starts(vsver, "vs") then if not string.starts(vsver, "vs") then
vsver = get_vs_version() vsver = get_vs_version()
@ -74,7 +85,7 @@ function get_toolset_configuration_name()
return table.concat({vsver, arch}, "-") return table.concat({vsver, arch}, "-")
end end
-- FIXME: Implement for non-Windows platforms -- FIXME: Implement for non-Windows platforms
return nil return table.concat({arch}, "-")
end end
-- Returns a string describing the package configuration. -- Returns a string describing the package configuration.
@ -85,10 +96,6 @@ function get_llvm_package_name(rev, conf, toolset)
end end
rev = string.sub(rev, 0, 6) rev = string.sub(rev, 0, 6)
if not conf then
conf = get_llvm_configuration_name()
end
if not toolset then if not toolset then
toolset = get_toolset_configuration_name() toolset = get_toolset_configuration_name()
end end
@ -99,6 +106,10 @@ function get_llvm_package_name(rev, conf, toolset)
table.insert(components, toolset) table.insert(components, toolset)
end end
if not conf then
conf = get_llvm_configuration_name()
end
table.insert(components, conf) table.insert(components, conf)
return table.concat(components, "-") return table.concat(components, "-")
@ -277,7 +288,11 @@ function build_llvm(llvm_build)
msbuild(llvm_sln, conf) msbuild(llvm_sln, conf)
else else
local options = os.is("macosx") and local options = os.is("macosx") and
"-DLLVM_ENABLE_LIBCXX=true -DLLVM_BUILD_32_BITS=true" or "" "-DLLVM_ENABLE_LIBCXX=true" or ""
local is32bits = _OPTIONS["arch"] == "x86"
if is32bits then
options = options .. is32bits and " -DLLVM_BUILD_32_BITS=true" or ""
end
cmake("Ninja", conf, llvm_build, options) cmake("Ninja", conf, llvm_build, options)
ninja(llvm_build) ninja(llvm_build)
ninja(llvm_build, "clang-headers") ninja(llvm_build, "clang-headers")

4
docs/BuildingLLVM.md

@ -66,9 +66,9 @@ Before building, ensure cmake is installed under Applications/Cmake.app and Ninj
../premake5-osx --file=LLVM.lua package_llvm ../premake5-osx --file=LLVM.lua package_llvm
``` ```
If the clone_llvm step fails, you can try to manually clone LLVM and Clang as explained above. You should still run clone_llvm to ensure that you are on the correct revision. You can specify an `--arch=x86` or `--arch=x64` flag to the invocations above to specify an explicit build architecture.
The compile flags for cmake can be edited in `build/scripts/LLVM.lua`, e.g. if you need to build a 64-bit version. If the clone_llvm step fails, you can try to manually clone LLVM and Clang as explained above. You should still run clone_llvm to ensure that you are on the correct revision.
## Compiling on Linux ## Compiling on Linux

Loading…
Cancel
Save