Bug 1690934 - Adjust clang for use with sysroots. r=firefox-build-system-reviewers,sheehan,mhentges

When using the --sysroot argument to clang, clang changes where it
searches for libraries in its own directory, and excludes the lib and
lib32 subdirectories. So we need to move the gcc files to a place where
it does look (and that it also looks without --sysroot).

We however still keep a copy of libstdc++ in the lib directory for
runtime purposes.

Differential Revision: https://phabricator.services.mozilla.com/D104123
This commit is contained in:
Mike Hommey
2021-02-08 20:06:40 +00:00
parent 6f6da796d0
commit f4e30777ce
2 changed files with 8 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ import sys
import tarfile import tarfile
from contextlib import contextmanager from contextlib import contextmanager
from distutils.dir_util import copy_tree from distutils.dir_util import copy_tree
from distutils.file_util import copy_file
from shutil import which from shutil import which
@@ -196,10 +197,13 @@ def install_libgcc(gcc_dir, clang_dir, is_final_stage):
mkdir_p(clang_lib_dir) mkdir_p(clang_lib_dir)
copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True) copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True)
libgcc_dir = os.path.join(gcc_dir, "lib64") libgcc_dir = os.path.join(gcc_dir, "lib64")
clang_lib_dir = os.path.join(clang_dir, "lib") # This is necessary as long as CI runs on debian8 docker images.
copy_file(
os.path.join(libgcc_dir, "libstdc++.so.6"), os.path.join(clang_dir, "lib")
)
copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True) copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True)
libgcc_dir = os.path.join(gcc_dir, "lib32") libgcc_dir = os.path.join(gcc_dir, "lib32")
clang_lib_dir = os.path.join(clang_dir, "lib32") clang_lib_dir = os.path.join(clang_lib_dir, "32")
copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True) copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True)
include_dir = os.path.join(gcc_dir, "include") include_dir = os.path.join(gcc_dir, "include")
clang_include_dir = os.path.join(clang_dir, "include") clang_include_dir = os.path.join(clang_dir, "include")

View File

@@ -4,13 +4,13 @@ export MOZ_STDCXX_COMPAT=1
# Depending whether GCC was built on a RedHat-based or a Debian-based system, # Depending whether GCC was built on a RedHat-based or a Debian-based system,
# the directory containing 32-bits libraries can be either (respectively) # the directory containing 32-bits libraries can be either (respectively)
# lib or lib32. The directory for 64-bits libraries is always lib64. # lib or lib32. The directory for 64-bits libraries is always lib64.
if [ -f "$MOZ_FETCHES_DIR/gcc/lib64/libstdc++.so" ]; then if [ -f "$MOZ_FETCHES_DIR/gcc/lib64/libstdc++.so.6" ]; then
# We put both 32-bits and 64-bits library path in LD_LIBRARY_PATH: ld.so # We put both 32-bits and 64-bits library path in LD_LIBRARY_PATH: ld.so
# will prefer the files in the 32-bits path when loading 32-bits executables, # will prefer the files in the 32-bits path when loading 32-bits executables,
# and the files in the 64-bits path when loading 64-bits executables. # and the files in the 64-bits path when loading 64-bits executables.
# We also put both possible 32-bits library paths. # We also put both possible 32-bits library paths.
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/gcc/lib64:$MOZ_FETCHES_DIR/gcc/lib32:$MOZ_FETCHES_DIR/gcc/lib LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/gcc/lib64:$MOZ_FETCHES_DIR/gcc/lib32:$MOZ_FETCHES_DIR/gcc/lib
elif [ -f "$MOZ_FETCHES_DIR/clang/lib/libstdc++.so" ]; then elif [ -f "$MOZ_FETCHES_DIR/clang/lib/libstdc++.so.6" ]; then
LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/clang/lib:$MOZ_FETCHES_DIR/clang/lib32 LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$MOZ_FETCHES_DIR/clang/lib:$MOZ_FETCHES_DIR/clang/lib32
fi fi