Skip to content

Commit

Permalink
Bug 1704766 - Remove libstdc++ from clang toolchains. r=firefox-build…
Browse files Browse the repository at this point in the history
…-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D119140
  • Loading branch information
glandium committed Jul 16, 2021
1 parent 2b34d65 commit 1c3750f
Show file tree
Hide file tree
Showing 18 changed files with 5 additions and 63 deletions.
1 change: 0 additions & 1 deletion build/build-clang/README
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ build-clang.py accepts a JSON config format with the following fields:

* stages: Use 1, 2, 3 or 4 to select different compiler stages. The default is 3.
* python_path: Path to the Python 2.7 installation on the machine building clang.
* 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.
Expand Down
51 changes: 4 additions & 47 deletions build/build-clang/build-clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import tarfile
from contextlib import contextmanager
from distutils.dir_util import copy_tree
from distutils.file_util import copy_file

from shutil import which

Expand Down Expand Up @@ -167,37 +166,6 @@ def delete(path):
pass


def install_libgcc(gcc_dir, clang_dir, is_final_stage):
gcc_bin_dir = os.path.join(gcc_dir, "bin")

out = subprocess.check_output(
[os.path.join(gcc_bin_dir, "gcc"), "-print-libgcc-file-name"]
)

libgcc_dir = os.path.dirname(out.decode().rstrip())
clang_lib_dir = os.path.join(
clang_dir,
"lib",
"gcc",
"x86_64-unknown-linux-gnu",
os.path.basename(libgcc_dir),
)
mkdir_p(clang_lib_dir)
copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True)
libgcc_dir = os.path.join(gcc_dir, "lib64")
# 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)
libgcc_dir = os.path.join(gcc_dir, "lib32")
clang_lib_dir = os.path.join(clang_lib_dir, "32")
copy_tree(libgcc_dir, clang_lib_dir, preserve_symlinks=True)
include_dir = os.path.join(gcc_dir, "include")
clang_include_dir = os.path.join(clang_dir, "include")
copy_tree(include_dir, clang_include_dir, preserve_symlinks=True)


def install_import_library(build_dir, clang_dir):
shutil.copy2(
os.path.join(build_dir, "lib", "clang.lib"), os.path.join(clang_dir, "lib")
Expand Down Expand Up @@ -248,7 +216,6 @@ def build_one_stage(
build_type,
assertions,
python_path,
gcc_dir,
libcxx_include_dir,
build_wasm,
compiler_rt_source_dir=None,
Expand Down Expand Up @@ -314,6 +281,10 @@ def cmake_base_args(cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir):
sysroot = os.path.join(os.environ.get("MOZ_FETCHES_DIR", ""), "sysroot")
if os.path.exists(sysroot):
cmake_args += ["-DCMAKE_SYSROOT=%s" % sysroot]
# Work around the LLVM build system not building the i386 compiler-rt
# because it doesn't allow to use a sysroot for that during the cmake
# checks.
cmake_args += ["-DCAN_TARGET_i386=1"]
if is_windows():
cmake_args.insert(-1, "-DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON")
cmake_args.insert(-1, "-DLLVM_USE_CRT_RELEASE=MT")
Expand Down Expand Up @@ -439,8 +410,6 @@ def cmake_base_args(cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir):
cmake_args += [src_dir]
build_package(build_dir, cmake_args)

if is_linux():
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():
Expand Down Expand Up @@ -746,11 +715,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
if "python_path" not in config:
raise ValueError("Config file needs to set python_path")
python_path = config["python_path"]
gcc_dir = None
if "gcc_dir" in config:
gcc_dir = config["gcc_dir"].format(**os.environ)
if not os.path.exists(gcc_dir):
raise ValueError("gcc_dir must point to an existing path")
ndk_dir = None
android_targets = None
if "android_targets" in config:
Expand All @@ -770,9 +734,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
if not all(isinstance(t, str) for t in extra_targets):
raise ValueError("members of extra_targets should be strings")

if is_linux() and gcc_dir is None:
raise ValueError("Config file needs to set gcc_dir")

if is_darwin() or osx_cross_compile:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = (
"11.0" if os.environ.get("OSX_ARCH") == "arm64" else "10.12"
Expand Down Expand Up @@ -924,7 +885,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
build_type,
assertions,
python_path,
gcc_dir,
libcxx_include_dir,
build_wasm,
is_final_stage=(stages == 1),
Expand Down Expand Up @@ -954,7 +914,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
build_type,
assertions,
python_path,
gcc_dir,
libcxx_include_dir,
build_wasm,
compiler_rt_source_dir,
Expand Down Expand Up @@ -987,7 +946,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
build_type,
assertions,
python_path,
gcc_dir,
libcxx_include_dir,
build_wasm,
compiler_rt_source_dir,
Expand Down Expand Up @@ -1029,7 +987,6 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
build_type,
assertions,
python_path,
gcc_dir,
libcxx_include_dir,
build_wasm,
compiler_rt_source_dir,
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-10-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-11-android.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-11-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-11-macosx64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"assertions": false,
"osx_cross_compile": true,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/clang/bin/clang",
"cxx": "{MOZ_FETCHES_DIR}/clang/bin/clang++",
"as": "{MOZ_FETCHES_DIR}/clang/bin/clang",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-12-android.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-12-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-12-macosx64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"assertions": false,
"osx_cross_compile": true,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/clang/bin/clang",
"cxx": "{MOZ_FETCHES_DIR}/clang/bin/clang++",
"as": "{MOZ_FETCHES_DIR}/clang/bin/clang",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-12-mingw.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-5.0-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-7-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-tidy-external-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"assertions": false,
"build_clang_tidy": true,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-tidy-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"assertions": false,
"build_clang_tidy": true,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-tidy-macosx64.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"build_clang_tidy": true,
"osx_cross_compile": true,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/clang/bin/clang",
"cxx": "{MOZ_FETCHES_DIR}/clang/bin/clang++",
"as": "{MOZ_FETCHES_DIR}/clang/bin/clang",
Expand Down
1 change: 0 additions & 1 deletion build/build-clang/clang-trunk-linux64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"build_type": "Release",
"assertions": false,
"python_path": "/usr/bin/python2.7",
"gcc_dir": "{MOZ_FETCHES_DIR}/gcc",
"cc": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
"cxx": "{MOZ_FETCHES_DIR}/gcc/bin/g++",
"as": "{MOZ_FETCHES_DIR}/gcc/bin/gcc",
Expand Down
1 change: 1 addition & 0 deletions taskcluster/ci/toolchain/sysroot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ linux64-toolchain-sysroot:
# For clang
- binutils-dev
- gcc-multilib
- lib32stdc++-7-dev
- libxml2-dev
# For minidump-stackwalk
- libcurl4-openssl-dev
Expand Down

0 comments on commit 1c3750f

Please sign in to comment.