Skip to content

Commit

Permalink
toolchain: make gcc default compiler for x86 and aarch64
Browse files Browse the repository at this point in the history
GCC is the default compiler as it is simpler to setup for
different architectures, when compared with clang.
  • Loading branch information
danctorres committed Jan 5, 2025
1 parent 519f30b commit b88113e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
10 changes: 2 additions & 8 deletions examples/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ cc_library(
name = "lib",
srcs = ["hello.cpp"],
hdrs = ["hello.hpp"],
features = select({
"//bazel/platforms:aarch64_config": ["warnings_critical_code_gcc"],
"//conditions:default": ["warnings_critical_code_clang"],
}),
features = ["warnings_critical_code_gcc"],
)

cc_binary(
name = "bin",
srcs = ["main.cpp"],
features = select({
"//bazel/platforms:aarch64_config": ["warnings_critical_code_gcc"],
"//conditions:default": ["warnings_critical_code_clang"],
}),
features = ["warnings_critical_code_gcc"],
deps = [
":lib",
],
Expand Down
23 changes: 9 additions & 14 deletions toolchain/x86_64_linux/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ all_compile_actions = [

def _impl(ctx):
tool_paths = [
tool_path(name = "gcc", path = "/usr/bin/clang-18"),
tool_path(name = "ld", path = "/usr/bin/ld"),
tool_path(name = "ar", path = "/usr/bin/ar"),
tool_path(name = "cpp", path = "/usr/bin/clang-cpp18"),
tool_path(name = "gcc", path = "/usr/bin/x86_64-linux-gnu-gcc"),
tool_path(name = "ld", path = "/usr/bin/x86_64-linux-gnu-ld"),
tool_path(name = "ar", path = "/usr/bin/x86_64-linux-gnu-ar"),
tool_path(name = "cpp", path = "/usr/bin/x86_64-linux-gnu-cpp18"),
tool_path(name = "gcov", path = "/usr/bin/gcov"),
tool_path(name = "llvm-cov", path = "/usr/bin/llvm-cov-18"),
tool_path(name = "llvm-profdata", path = "/usr/bin/llvm-profdata-18"),
Expand Down Expand Up @@ -109,7 +109,7 @@ def _impl(ctx):
enabled = True,
flag_sets = [
flag_set(
actions = [ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble],
actions = all_link_actions + all_compile_actions,
flag_groups = [
flag_group(flags = ["-fPIC"]),
],
Expand Down Expand Up @@ -213,8 +213,6 @@ def _impl(ctx):
"-Wformat=2",
"-Wimplicit-fallthrough",
"-Werror",
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
],
),
],
Expand All @@ -232,8 +230,6 @@ def _impl(ctx):
flags = [
"-Wall",
"-Wshadow",
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
],
),
],
Expand All @@ -246,17 +242,16 @@ def _impl(ctx):
ctx = ctx,
features = features,
cxx_builtin_include_directories = [
"/usr/lib/llvm-18/lib/clang/18/include",
"/usr/lib/llvm-18/lib/clang/18/share", # Dir containing `asan_ignorelist.txt`
"/usr/lib/clang/18/include",
"/usr/include",
"/usr/lib/x86_64-linux-gnu",
"/usr/lib/gcc/x86_64-linux-gnu",
],
toolchain_identifier = "linux_aarch64-toolchain",
toolchain_identifier = "linux_x86_64-toolchain",
host_system_name = "local",
target_system_name = "unknown",
target_cpu = "unknown",
target_libc = "unknown",
compiler = "clang",
compiler = "unknown",
abi_version = "unknown",
abi_libc_version = "unknown",
tool_paths = tool_paths,
Expand Down

0 comments on commit b88113e

Please sign in to comment.