Bug 1451104 - part 3 - inform stage2/3 clang about gcc binutils; r=glandium

We do this to encourage clang to find an new-enough linker instead of
the system one.

Differential Revision: https://phabricator.services.mozilla.com/D22881

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nathan Froyd 2019-03-15 01:29:04 +00:00
Родитель ce83c42681
Коммит c5ab838f7c
1 изменённых файлов: 25 добавлений и 4 удалений

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

@ -120,8 +120,23 @@ def delete(path):
pass
def install_libgcc(gcc_dir, clang_dir):
out = subprocess.check_output([os.path.join(gcc_dir, "bin", "gcc"),
def install_libgcc(gcc_dir, clang_dir, is_final_stage):
gcc_bin_dir = os.path.join(gcc_dir, 'bin')
# Copy over gcc toolchain bits that clang looks for, to ensure that
# clang is using a consistent version of ld, since the system ld may
# be incompatible with the output clang produces. But copy it to a
# target-specific directory so a cross-compiler to Mac doesn't pick
# up the (Linux-specific) ld with disastrous results.
#
# Only install this for the bootstrap process; we expect any consumers of
# the newly-built toolchain to provide an appropriate ld themselves.
if not is_final_stage:
x64_bin_dir = os.path.join(clang_dir, 'x86_64-unknown-linux-gnu', 'bin')
mkdir_p(x64_bin_dir)
shutil.copy2(os.path.join(gcc_bin_dir, 'ld'), x64_bin_dir)
out = subprocess.check_output([os.path.join(gcc_bin_dir, "gcc"),
'-print-libgcc-file-name'])
libgcc_dir = os.path.dirname(out.rstrip())
@ -309,7 +324,7 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
build_package(build_dir, cmake_args)
if is_linux():
install_libgcc(gcc_dir, inst_dir)
install_libgcc(gcc_dir, inst_dir, is_final_stage)
# For some reasons the import library clang.lib of clang.exe is not
# installed, so we copy it by ourselves.
if is_windows():
@ -405,7 +420,9 @@ def get_tool(config, key):
# run-clang-tidy.py
def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
# Make sure we only have what we expect.
dirs = ("bin", "include", "lib", "lib32", "libexec", "msbuild-bin", "share", "tools")
dirs = ["bin", "include", "lib", "lib32", "libexec", "msbuild-bin", "share", "tools"]
if is_linux():
dirs.append("x86_64-unknown-linux-gnu")
for f in glob.glob("%s/*" % final_dir):
if os.path.basename(f) not in dirs:
raise Exception("Found unknown file %s in the final directory" % f)
@ -422,6 +439,10 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
# Keep include/ intact.
# Remove the target-specific files.
if is_linux():
shutil.rmtree(os.path.join(final_dir, "x86_64-unknown-linux-gnu"))
# In lib/, only keep lib/clang/N.M.O/include and the LLVM shared library.
re_ver_num = re.compile(r"^\d+\.\d+\.\d+$", re.I)
for f in glob.glob("%s/lib/*" % final_dir):