Build wasm master (#401)
* Build wasm upstream * Fix lld build for wasm-ld. Add note about compiler-rt not working. * Address review * Address review * Address review * Address review * If targeting fastcomp Clang, apply EMCC_WASM_BACKEND=0 so that previous leftover environment with EMCC_WASM_BACKEND=1 will not cause a conflict * Add docs about setting up Emscripten
This commit is contained in:
90
emsdk.py
90
emsdk.py
@@ -805,7 +805,7 @@ def decide_cmake_build_type(tool):
|
||||
|
||||
|
||||
# The root directory of the build.
|
||||
def fastcomp_build_dir(tool):
|
||||
def llvm_build_dir(tool):
|
||||
generator_suffix = ''
|
||||
if CMAKE_GENERATOR == 'Visual Studio 10':
|
||||
generator_suffix = '_vs2010'
|
||||
@@ -838,7 +838,7 @@ def exe_suffix(filename):
|
||||
# The directory where the binaries are produced. (relative to the installation
|
||||
# root directory of the tool)
|
||||
def fastcomp_build_bin_dir(tool):
|
||||
build_dir = fastcomp_build_dir(tool)
|
||||
build_dir = llvm_build_dir(tool)
|
||||
if WINDOWS and 'Visual Studio' in CMAKE_GENERATOR:
|
||||
old_llvm_bin_dir = os.path.join(build_dir, 'bin', decide_cmake_build_type(tool))
|
||||
|
||||
@@ -1052,8 +1052,8 @@ def xcode_sdk_version():
|
||||
return subprocess.checkplatform.mac_ver()[0].split('.')
|
||||
|
||||
|
||||
def build_llvm_tool(tool):
|
||||
debug_print('build_llvm_tool(' + str(tool) + ')')
|
||||
def build_llvm_fastcomp(tool):
|
||||
debug_print('build_llvm_fastcomp(' + str(tool) + ')')
|
||||
fastcomp_root = tool.installation_path()
|
||||
fastcomp_src_root = os.path.join(fastcomp_root, 'src')
|
||||
# Does this tool want to be git cloned from github?
|
||||
@@ -1061,10 +1061,11 @@ def build_llvm_tool(tool):
|
||||
success = git_clone_checkout_and_pull(tool.download_url(), fastcomp_src_root, tool.git_branch)
|
||||
if not success:
|
||||
return False
|
||||
clang_root = os.path.join(fastcomp_src_root, 'tools/clang')
|
||||
success = git_clone_checkout_and_pull(tool.clang_url, clang_root, tool.git_branch)
|
||||
if not success:
|
||||
return False
|
||||
if hasattr(tool, 'clang_url'):
|
||||
clang_root = os.path.join(fastcomp_src_root, 'tools/clang')
|
||||
success = git_clone_checkout_and_pull(tool.clang_url, clang_root, tool.git_branch)
|
||||
if not success:
|
||||
return False
|
||||
if hasattr(tool, 'lld_url'):
|
||||
lld_root = os.path.join(fastcomp_src_root, 'tools/lld')
|
||||
success = git_clone_checkout_and_pull(tool.lld_url, lld_root, tool.git_branch)
|
||||
@@ -1083,7 +1084,7 @@ def build_llvm_tool(tool):
|
||||
if 'Visual Studio' in CMAKE_GENERATOR and tool.bitness == 64:
|
||||
cmake_generator += ' Win64'
|
||||
|
||||
build_dir = fastcomp_build_dir(tool)
|
||||
build_dir = llvm_build_dir(tool)
|
||||
build_root = os.path.join(fastcomp_root, build_dir)
|
||||
|
||||
build_type = decide_cmake_build_type(tool)
|
||||
@@ -1129,6 +1130,69 @@ def build_llvm_tool(tool):
|
||||
return success
|
||||
|
||||
|
||||
# LLVM git source tree migrated to a single repository instead of multiple ones, build_llvm_monorepo() builds via that repository structure
|
||||
def build_llvm_monorepo(tool):
|
||||
debug_print('build_llvm_monorepo(' + str(tool) + ')')
|
||||
llvm_root = tool.installation_path()
|
||||
llvm_src_root = os.path.join(llvm_root, 'src')
|
||||
success = git_clone_checkout_and_pull(tool.download_url(), llvm_src_root, tool.git_branch)
|
||||
if not success:
|
||||
return False
|
||||
|
||||
build_dir = llvm_build_dir(tool)
|
||||
build_root = os.path.join(llvm_root, build_dir)
|
||||
|
||||
build_type = decide_cmake_build_type(tool)
|
||||
|
||||
# Configure
|
||||
global BUILD_FOR_TESTING, ENABLE_LLVM_ASSERTIONS
|
||||
tests_arg = 'ON' if BUILD_FOR_TESTING else 'OFF'
|
||||
|
||||
enable_assertions = ENABLE_LLVM_ASSERTIONS.lower() == 'on' or (ENABLE_LLVM_ASSERTIONS == 'auto' and build_type.lower() != 'release' and build_type.lower() != 'minsizerel')
|
||||
|
||||
if ARCH == 'x86' or ARCH == 'x86_64':
|
||||
targets_to_build = 'WebAssembly;X86'
|
||||
elif ARCH == 'arm':
|
||||
targets_to_build = 'WebAssembly;ARM'
|
||||
elif ARCH == 'aarch64':
|
||||
targets_to_build = 'WebAssembly;AArch64'
|
||||
else:
|
||||
targets_to_build = 'WebAssembly'
|
||||
args = ['-DLLVM_TARGETS_TO_BUILD=' + targets_to_build,
|
||||
'-DLLVM_INCLUDE_EXAMPLES=OFF',
|
||||
'-DCLANG_INCLUDE_EXAMPLES=OFF',
|
||||
'-DLLVM_INCLUDE_TESTS=' + tests_arg,
|
||||
'-DCLANG_INCLUDE_TESTS=' + tests_arg,
|
||||
'-DLLVM_ENABLE_ASSERTIONS=' + ('ON' if enable_assertions else 'OFF')]
|
||||
# LLVM build system bug: looks like everything needs to be passed to LLVM_ENABLE_PROJECTS twice. (or every second field is ignored?)
|
||||
|
||||
# LLVM build system bug #2: compiler-rt does not build on Windows. It insists on performing a CMake install step that writes to C:\Program Files. Attempting
|
||||
# to reroute that to build_root directory then fails on an error
|
||||
# file INSTALL cannot find
|
||||
# "C:/code/emsdk/llvm/git/build_master_vs2017_64/$(Configuration)/lib/clang/10.0.0/lib/windows/clang_rt.ubsan_standalone-x86_64.lib".
|
||||
# (there instead of $(Configuration), one would need ${CMAKE_BUILD_TYPE} ?)
|
||||
# It looks like compiler-rt is not compatible to build on Windows?
|
||||
args += ['-DLLVM_ENABLE_PROJECTS="clang;clang;lld;lld"']
|
||||
cmake_generator = CMAKE_GENERATOR
|
||||
if 'Visual Studio' in CMAKE_GENERATOR and tool.bitness == 64:
|
||||
cmake_generator += ' Win64'
|
||||
args += ['-Thost=x64']
|
||||
|
||||
if os.environ.get('LLVM_CMAKE_ARGS'):
|
||||
extra_args = os.environ['LLVM_CMAKE_ARGS'].split(',')
|
||||
print('Passing the following extra arguments to LLVM CMake configuration: ' + str(extra_args))
|
||||
args += extra_args
|
||||
|
||||
cmakelists_dir = os.path.join(llvm_src_root, 'llvm')
|
||||
success = cmake_configure(cmake_generator, build_root, cmakelists_dir, build_type, args)
|
||||
if not success:
|
||||
return False
|
||||
|
||||
# Make
|
||||
success = make_build(build_root, build_type, 'x64' if tool.bitness == 64 else 'Win32')
|
||||
return success
|
||||
|
||||
|
||||
# Emscripten asm.js optimizer build scripts:
|
||||
def optimizer_build_root(tool):
|
||||
build_root = tool.installation_path().strip()
|
||||
@@ -1454,7 +1518,7 @@ class Tool(object):
|
||||
str = str.replace('%generator_prefix%', cmake_generator_prefix())
|
||||
str = str.replace('%.exe%', '.exe' if WINDOWS else '')
|
||||
if '%fastcomp_build_dir%' in str:
|
||||
str = str.replace('%fastcomp_build_dir%', fastcomp_build_dir(self))
|
||||
str = str.replace('%fastcomp_build_dir%', llvm_build_dir(self))
|
||||
if '%fastcomp_build_bin_dir%' in str:
|
||||
str = str.replace('%fastcomp_build_bin_dir%', fastcomp_build_bin_dir(self))
|
||||
return str
|
||||
@@ -1718,7 +1782,9 @@ class Tool(object):
|
||||
url = self.download_url()
|
||||
|
||||
if hasattr(self, 'custom_install_script') and self.custom_install_script == 'build_fastcomp':
|
||||
success = build_llvm_tool(self)
|
||||
success = build_llvm_fastcomp(self)
|
||||
elif hasattr(self, 'custom_install_script') and self.custom_install_script == 'build_llvm_monorepo':
|
||||
success = build_llvm_monorepo(self)
|
||||
elif hasattr(self, 'git_branch'):
|
||||
success = git_clone_checkout_and_pull(url, self.installation_path(), self.git_branch)
|
||||
elif url.endswith(ARCHIVE_SUFFIXES):
|
||||
@@ -1742,7 +1808,7 @@ class Tool(object):
|
||||
if hasattr(self, 'custom_install_script'):
|
||||
if self.custom_install_script == 'build_optimizer':
|
||||
success = build_optimizer_tool(self)
|
||||
elif self.custom_install_script == 'build_fastcomp':
|
||||
elif self.custom_install_script in ('build_fastcomp', 'build_llvm_monorepo'):
|
||||
# 'build_fastcomp' is a special one that does the download on its
|
||||
# own, others do the download manually.
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user