Bug 1331957 - Part 4: Allow specifying a custom assembler and pass the right flags to it when cross-compiling; r=froydnj

This commit is contained in:
Ehsan Akhgari 2017-01-19 14:15:56 -05:00
Родитель 2deb4fad8f
Коммит 3faecaeefd
8 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -39,6 +39,7 @@ build-clang.py accepts a JSON config format with the following fields:
* gcc_dir: Path to the gcc toolchain installation, only required on Linux.
* cc: Path to the bootsraping C Compiler.
* cxx: Path to the bootsraping C++ Compiler.
* as: Path to the assembler tool.
* ar: Path to the library archiver tool.
* ranlib: Path to the ranlib tool.
* ld: Path to the linker.

Просмотреть файл

@ -200,7 +200,7 @@ def is_windows():
return platform.system() == "Windows"
def build_one_stage(cc, cxx, ld, ar, ranlib,
def build_one_stage(cc, cxx, asm, ld, ar, ranlib,
src_dir, stage_dir, build_libcxx,
osx_cross_compile, build_type, assertions,
python_path, gcc_dir, libcxx_include_dir):
@ -225,11 +225,12 @@ def build_one_stage(cc, cxx, ld, ar, ranlib,
cmake_args = ["-GNinja",
"-DCMAKE_C_COMPILER=%s" % slashify_path(cc[0]),
"-DCMAKE_CXX_COMPILER=%s" % slashify_path(cxx[0]),
"-DCMAKE_ASM_COMPILER=%s" % slashify_path(cc[0]),
"-DCMAKE_ASM_COMPILER=%s" % slashify_path(asm[0]),
"-DCMAKE_LINKER=%s" % slashify_path(ld[0]),
"-DCMAKE_AR=%s" % slashify_path(ar),
"-DCMAKE_C_FLAGS=%s" % ' '.join(cc[1:]),
"-DCMAKE_CXX_FLAGS=%s" % ' '.join(cxx[1:]),
"-DCMAKE_ASM_FLAGS=%s" % ' '.join(asm[1:]),
"-DCMAKE_EXE_LINKER_FLAGS=%s" % ' '.join(ld[1:]),
"-DCMAKE_SHARED_LINKER_FLAGS=%s" % ' '.join(ld[1:]),
"-DCMAKE_BUILD_TYPE=%s" % build_type,
@ -464,6 +465,7 @@ if __name__ == "__main__":
raise ValueError("Config file needs to set gcc_dir")
cc = get_tool(config, "cc")
cxx = get_tool(config, "cxx")
asm = get_tool(config, "ml" if is_windows() else "as")
ld = get_tool(config, "link" if is_windows() else "ld")
ar = get_tool(config, "lib" if is_windows() else "ar")
ranlib = None if is_windows() else get_tool(config, "ranlib")
@ -525,12 +527,14 @@ if __name__ == "__main__":
extra_cxxflags = ["-stdlib=libc++"]
extra_cflags2 = []
extra_cxxflags2 = ["-stdlib=libc++"]
extra_asmflags = []
extra_ldflags = []
elif is_linux():
extra_cflags = ["-static-libgcc"]
extra_cxxflags = ["-static-libgcc", "-static-libstdc++"]
extra_cflags2 = ["-fPIC"]
extra_cxxflags2 = ["-fPIC", "-static-libstdc++"]
extra_asmflags = []
extra_ldflags = []
if os.environ.has_key('LD_LIBRARY_PATH'):
@ -545,6 +549,7 @@ if __name__ == "__main__":
# Force things on.
extra_cflags2 = []
extra_cxxflags2 = ['-fms-compatibility-version=19.00.24213', '-Xclang', '-std=c++14']
extra_asmflags = []
extra_ldflags = []
if osx_cross_compile:
@ -565,12 +570,14 @@ if __name__ == "__main__":
extra_cxxflags += extra_flags
extra_cflags2 += extra_flags
extra_cxxflags2 += extra_flags
extra_asmflags += extra_flags
extra_ldflags = ["-Wl,-syslibroot,%s" % os.getenv("CROSS_SYSROOT"),
"-Wl,-dead_strip"]
build_one_stage(
[cc] + extra_cflags,
[cxx] + extra_cxxflags,
[asm] + extra_asmflags,
[ld] + extra_ldflags,
ar, ranlib,
llvm_source_dir, stage1_dir, build_libcxx, osx_cross_compile,
@ -585,6 +592,8 @@ if __name__ == "__main__":
(cc_name, exe_ext)] + extra_cflags2,
[stage1_inst_dir + "/bin/%s%s" %
(cxx_name, exe_ext)] + extra_cxxflags2,
[stage1_inst_dir + "/bin/%s%s" %
(cc_name, exe_ext)] + extra_asmflags,
[ld] + extra_ldflags,
ar, ranlib,
llvm_source_dir, stage2_dir, build_libcxx, osx_cross_compile,
@ -598,6 +607,8 @@ if __name__ == "__main__":
(cc_name, exe_ext)] + extra_cflags2,
[stage2_inst_dir + "/bin/%s%s" %
(cxx_name, exe_ext)] + extra_cxxflags2,
[stage2_inst_dir + "/bin/%s%s" %
(cc_name, exe_ext)] + extra_asmflags,
[ld] + extra_ldflags,
ar, ranlib,
llvm_source_dir, stage3_dir, build_libcxx, osx_cross_compile,

Просмотреть файл

@ -13,6 +13,7 @@
"gcc_dir": "/home/worker/workspace/build/src/gcc",
"cc": "/home/worker/workspace/build/src/gcc/bin/gcc",
"cxx": "/home/worker/workspace/build/src/gcc/bin/g++",
"as": "/home/worker/workspace/build/src/gcc/bin/gcc",
"patches": {
"macosx64": [
"llvm-debug-frame.patch"

Просмотреть файл

@ -14,6 +14,7 @@
"gcc_dir": "/home/worker/workspace/build/src/gcc",
"cc": "/home/worker/workspace/build/src/clang/bin/clang",
"cxx": "/home/worker/workspace/build/src/clang/bin/clang++",
"as": "/home/worker/workspace/build/src/clang/bin/clang",
"ar": "/home/worker/workspace/build/src/cctools/bin/x86_64-apple-darwin10-ar",
"ranlib": "/home/worker/workspace/build/src/cctools/bin/x86_64-apple-darwin10-ranlib",
"ld": "/home/worker/workspace/build/src/clang/bin/clang",

Просмотреть файл

@ -11,6 +11,7 @@
"python_path": "c:/mozilla-build/python/python.exe",
"cc": "cl.exe",
"cxx": "cl.exe",
"ml": "ml64.exe",
"patches": {
}
}

Просмотреть файл

@ -14,5 +14,6 @@
"python_path": "/usr/bin/python2.7",
"gcc_dir": "/home/worker/workspace/build/src/gcc",
"cc": "/home/worker/workspace/build/src/gcc/bin/gcc",
"cxx": "/home/worker/workspace/build/src/gcc/bin/g++"
"cxx": "/home/worker/workspace/build/src/gcc/bin/g++",
"as": "/home/worker/workspace/build/src/gcc/bin/gcc"
}

Просмотреть файл

@ -16,6 +16,7 @@
"gcc_dir": "/home/worker/workspace/build/src/gcc",
"cc": "/home/worker/workspace/build/src/clang/bin/clang",
"cxx": "/home/worker/workspace/build/src/clang/bin/clang++",
"as": "/home/worker/workspace/build/src/clang/bin/clang",
"ar": "/home/worker/workspace/build/src/cctools/bin/x86_64-apple-darwin10-ar",
"ranlib": "/home/worker/workspace/build/src/cctools/bin/x86_64-apple-darwin10-ranlib",
"ld": "/home/worker/workspace/build/src/clang/bin/clang"

Просмотреть файл

@ -12,5 +12,6 @@
"libcxx_repo": "https://llvm.org/svn/llvm-project/libcxx/trunk",
"python_path": "c:/mozilla-build/python/python.exe",
"cc": "cl.exe",
"cxx": "cl.exe"
"cxx": "cl.exe",
"ml": "ml64.exe"
}