[bazel] Fix build with GCC and older versions of Clang.

Clang 12 doesn't support -Wno-bitwise-instead-of-logical,
so silence it with -Wno-unknown-warning-option.

GCC requires using GNU dialect of the C++ standard, using
optimizations (otherwise "always_inline" fails to inline),
and produces a lot of warnings that had to be silenced.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Change-Id: I9ddd4f39dca2167b5b208dc2d0ba8e60030eddfc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3333635
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78499}
This commit is contained in:
Piotr Sikora 2022-01-04 15:22:07 -08:00 committed by V8 LUCI CQ
parent 04952cd2f1
commit ba55c31ca8
4 changed files with 115 additions and 13 deletions

View File

@ -2,12 +2,16 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# V8 bazel port only supports clang
build --action_env=BAZEL_COMPILER=clang
build --action_env=CC=clang
build --action_env=CXX=clang++
# Pass CC, CXX and PATH from the environment
build --action_env=CC
build --action_env=CXX
build --action_env=PATH
# Use Clang compiler
build:clang --action_env=BAZEL_COMPILER=clang
build:clang --action_env=CC=clang
build:clang --action_env=CXX=clang++
# V8 debug config
build:debug --compilation_mode=dbg
build:debug --config=v8_enable_debugging_features

View File

@ -18,13 +18,6 @@ load(
)
load(":bazel/v8-non-pointer-compression.bzl", "v8_binary_non_pointer_compression")
config_setting(
name = "is_debug",
values = {
"compilation_mode": "dbg",
},
)
# =================================================
# Flags
# =================================================
@ -290,7 +283,7 @@ v8_config(
"V8_ADVANCED_BIGINT_ALGORITHMS",
"V8_CONCURRENT_MARKING",
] + select({
":is_debug": [
"@v8//bazel/config:is_debug": [
"DEBUG",
"V8_ENABLE_CHECKS",
],

View File

@ -15,6 +15,20 @@ package(
],
)
config_setting(
name = "is_fastbuild",
values = {
"compilation_mode": "fastbuild",
},
)
config_setting(
name = "is_debug",
values = {
"compilation_mode": "dbg",
},
)
config_setting(
name = "platform_cpu_x64",
constraint_values = ["@platforms//cpu:x86_64"],
@ -172,3 +186,64 @@ selects.config_setting_group(
name = "is_msvc_asm_arm64",
match_all = [":is_windows", ":is_arm64"],
)
config_setting(
name = "is_compiler_default",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "compiler",
},
)
selects.config_setting_group(
name = "is_compiler_default_on_linux",
match_all = [
":is_compiler_default",
":is_linux",
],
)
selects.config_setting_group(
name = "is_compiler_default_on_macos",
match_all = [
":is_compiler_default",
":is_macos",
],
)
config_setting(
name = "is_compiler_clang",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "clang",
},
)
selects.config_setting_group(
name = "is_clang",
match_any = [
":is_compiler_default_on_macos",
":is_compiler_clang",
],
)
config_setting(
name = "is_compiler_gcc",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "gcc",
},
)
selects.config_setting_group(
name = "is_gcc",
match_any = [
":is_compiler_default_on_linux",
":is_compiler_gcc",
],
)
selects.config_setting_group(
name = "is_gcc_fastbuild",
match_all = [
":is_gcc",
":is_fastbuild",
],
)

View File

@ -100,18 +100,48 @@ def _default_args():
copts = select({
"@v8//bazel/config:is_posix": [
"-fPIC",
"-fno-strict-aliasing",
"-Werror",
"-Wextra",
"-Wno-unknown-warning-option",
"-Wno-bitwise-instead-of-logical",
"-Wno-builtin-assume-aligned-alignment",
"-Wno-unused-parameter",
"-Wno-implicit-int-float-conversion",
"-Wno-deprecated-copy",
"-Wno-non-virtual-dtor",
"-std=c++17",
"-isystem .",
],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_clang": [
"-Wno-invalid-offsetof",
"-std=c++17",
],
"@v8//bazel/config:is_gcc": [
"-Wno-extra",
"-Wno-comments",
"-Wno-deprecated-declarations",
"-Wno-implicit-fallthrough",
"-Wno-maybe-uninitialized",
"-Wno-mismatched-new-delete",
"-Wno-redundant-move",
"-Wno-return-type",
# Use GNU dialect, because GCC doesn't allow using
# ##__VA_ARGS__ when in standards-conforming mode.
"-std=gnu++17",
],
"@v8//bazel/config:is_windows": [
"/std:c++17",
],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_gcc_fastbuild": [
# Non-debug builds without optimizations fail because
# of recursive inlining of "always_inline" functions.
"-O1",
],
"//conditions:default": [],
}),
includes = ["include"],
linkopts = select({