brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.5 KiB · 1f9b7c5 Raw
231 lines · plain
1# This file is licensed under the Apache License v2.0 with LLVM Exceptions.2# See https://llvm.org/LICENSE.txt for license information.3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception4 5###############################################################################6# Common flags that apply to all configurations.7# Use sparingly for things common to all compilers and platforms.8###############################################################################9 10common --enable_bzlmod --noenable_workspace11 12# TODO: Remove lit test reliance on this13common --legacy_external_runfiles14 15# Prevent invalid caching if input files are modified during a build.16build --guard_against_concurrent_changes17 18# Automatically enable --config=(linux|macos|windows) based on the host19build --enable_platform_specific_config20 21# In opt mode, bazel by default builds both PIC and non-PIC object files for22# tests vs binaries. We don't need this feature and it slows down opt builds23# considerably.24# TODO: Remove platform specifics we're on bazel 7.x https://github.com/bazelbuild/bazel/issues/1243925# Apple platforms always enable pic so this flag is unnecessary anyways26build:linux --force_pic27build:windows --force_pic28 29# Shared objects take up more space. With fast linkers and binaries that aren't30# super large, the benefits of shared objects are minimal.31build --dynamic_mode=off32 33# Rely on compiler flags to compile with debug info/strip rather than stripping34# based on compilation_mode.35build --strip=never36 37# Add layering check to all projects.38build --features=layering_check39 40# Opt out of legacy lax behavior implicitly exporting files that are rule inputs41# with default visibility.42# See: https://bazel.build/reference/be/functions#exports_files43build --incompatible_no_implicit_file_export44 45# Enable so downstream users can flip this flag globally, this should46# eventually become the default47common --incompatible_disallow_empty_glob48 49# Disabling runfiles links drastically increases performance in slow disk IO50# situations Do not build runfile trees by default. If an execution strategy51# relies on runfile symlink tree, the tree is created on-demand. See:52# https://github.com/bazelbuild/bazel/issues/6627 and53# https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df54build --build_runfile_links=false55 56# Enable header processing to verify that header-only libraries are57# self-contained (for sub-projects that enable "parse_headers" feature).58# See https://bazel.build/docs/bazel-and-cpp#toolchain-features59build --process_headers_in_dependencies60 61###############################################################################62# Options to select different strategies for linking potential dependent63# libraries. The default leaves it disabled.64###############################################################################65 66build:zlib_external --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=external67build:zlib_system --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=system68 69###############################################################################70# Options for "generic_clang" builds: these options should generally apply to71# builds using a Clang-based compiler, and default to the `clang` executable on72# the `PATH`. While these are provided for convenience and may serve as a73# reference, it would be preferable for users to configure an explicit C++74# toolchain instead of relying on `.bazelrc` files.75###############################################################################76 77# Set the default compiler to the `clang` binary on the `PATH`.78build:generic_clang --repo_env=CC=clang79 80# C++17 standard version is required.81build:generic_clang --cxxopt=-std=c++17 --host_cxxopt=-std=c++1782 83# Use `-Wall` for Clang.84build:generic_clang --copt=-Wall --host_copt=-Wall85 86# The Clang available on MacOS has a warning that isn't clean on MLIR code. The87# warning doesn't show up with more recent Clangs, so just disable for now.88build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis89 90# Build errors are not a helpful way to enforce deprecation in-repo and it is91# not the point of the Bazel build to catch usage of deprecated APIs.92build:generic_clang --copt=-Wno-deprecated --host_copt=-Wno-deprecated93 94# lld links faster than other linkers. Assume that anybody using clang also has95# lld available.96build:generic_clang --linkopt=-fuse-ld=lld --host_linkopt=-fuse-ld=lld97 98###############################################################################99# Options for "generic_gcc" builds: these options should generally apply to100# builds using a GCC-based compiler, and default to the `gcc` executable on101# the `PATH`. While these are provided for convenience and may serve as a102# reference, it would be preferable for users to configure an explicit C++103# toolchain instead of relying on `.bazelrc` files.104###############################################################################105 106# Set the default compiler to the `gcc` binary on the `PATH`.107build:generic_gcc --repo_env=CC=gcc108 109# C++17 standard version is required.110build:generic_gcc --cxxopt=-std=c++17 --host_cxxopt=-std=c++17111 112# Build errors are not a helpful way to enforce deprecation in-repo and it is113# not the point of the Bazel build to catch usage of deprecated APIs.114build:generic_gcc --copt=-Wno-deprecated --host_copt=-Wno-deprecated115 116# Disable GCC warnings that are noisy and/or false positives on LLVM code.117# These need to be global as some code triggering these is in header files.118build:generic_gcc --copt=-Wno-unused-parameter --host_copt=-Wno-unused-parameter119build:generic_gcc --copt=-Wno-comment --host_copt=-Wno-comment120build:generic_gcc --cxxopt=-Wno-class-memaccess --host_cxxopt=-Wno-class-memaccess121build:generic_gcc --copt=-Wno-maybe-uninitialized --host_copt=-Wno-maybe-uninitialized122build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading-indentation123 124###############################################################################125# Generic Windows flags common to both MSVC and Clang.126###############################################################################127 128# C++17 standard version is required.129build:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17130 131# Other generic dialect flags.132build:windows --copt=/Zc:strictStrings --host_copt=/Zc:strictStrings133build:windows --copt=/Oi --host_copt=/Oi134build:windows --cxxopt=/Zc:rvalueCast --host_cxxopt=/Zc:rvalueCast135 136# Use the more flexible bigobj format for C++ files that have lots of symbols.137build:windows --cxxopt=/bigobj --host_cxxopt=/bigobj138 139###############################################################################140# Windows specific flags for building with MSVC.141###############################################################################142 143build:msvc --config=windows144 145build:msvc --copt=/WX --host_copt=/WX    # Treat warnings as errors...146# ...but disable the ones that are violated147build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once148build:msvc --copt=/wd4244 --host_copt=/wd4244 # conversion type -> type149build:msvc --copt=/wd4267 --host_copt=/wd4267 # conversion size_t -> type150build:msvc --copt=/wd4273 --host_copt=/wd4273 # multiple definitions with different dllimport151build:msvc --copt=/wd4319 --host_copt=/wd4319 # zero-extending after complement152build:msvc --copt=/wd4624 --host_copt=/wd4624 # destructor was implicitly defined as deleted153build:msvc --copt=/wd4804 --host_copt=/wd4804 # comparisons between bool and int154build:msvc --copt=/wd4805 --host_copt=/wd4805 # comparisons between bool and int155 156build:msvc --linkopt=/WX --host_linkopt=/WX # Treat warnings as errors...157# ...but disable the ones that are violated.158build:msvc --linkopt=/IGNORE:4001 --host_linkopt=/IGNORE:4001 # no object files159 160###############################################################################161# Options for Windows `clang-cl` builds.162###############################################################################163 164# We just start with the baseline Windows config as `clang-cl` doesn't accept165# some of the generic Clang flags.166build:clang-cl --config=windows167 168# Switch from MSVC to the `clang-cl` compiler.169build:clang-cl --compiler=clang-cl170 171# Use Clang's internal warning flags instead of the ones that sometimes map172# through to MSVC's flags.173build:clang-cl --copt=/clang:-Wall --host_copt=/clang:-Wall174build:clang-cl --copt=/clang:-Werror --host_copt=/clang:-Werror175 176# This doesn't appear to be enforced by any upstream bot.177build:clang-cl --copt=/clang:-Wno-unused --host_copt=/clang:-Wno-unused178 179# There appears to be an unused constant in GoogleTest on Windows.180build:clang-cl --copt=/clang:-Wno-unused-const-variable --host_copt=/clang:-Wno-unused-const-variable181 182# Disable some warnings hit even with `clang-cl` in Clang's own code.183build:clang-cl --copt=/clang:-Wno-inconsistent-dllimport --host_copt=/clang:-Wno-inconsistent-dllimport184build:clang-cl --cxxopt=/clang:-Wno-c++11-narrowing --host_cxxopt=/clang:-Wno-c++11-narrowing185 186###############################################################################187# Options for continuous integration.188###############################################################################189 190# -O1 tries to provide a reasonable tradeoff between compile times and runtime191# performance. However, if we start running more tests (e.g. all of192# check-clang) we may want more optimizations.193# Note for anybody considering using --compilation_mode=opt in CI, it builds194# most files twice, one PIC version for shared libraries in tests, and one195# non-PIC version for binaries.196build:ci --copt=-O1197 198# Use clang.199build:ci --config=generic_clang200 201# Speedup bazel using a ramdisk.202build:ci --sandbox_base=/dev/shm203 204# Use system's mpfr and pfm instead of building it from source.205# This is non hermetic but helps with compile time.206build:ci --@llvm-project//libc:mpfr=system207build:ci --@llvm-project//llvm:pfm=system208 209# Don't build/test targets tagged with "nobuildkite".210build:ci --build_tag_filters=-nobuildkite211build:ci --test_tag_filters=-nobuildkite212 213# Show as many errors as possible.214build:ci --keep_going215 216# Show test errors.217build:ci --test_output=errors218 219# Only show failing tests to reduce output220build:ci --test_summary=terse221 222# Attempt to work around intermittent issue while trying to fetch remote blob.223# See e.g. https://github.com/bazelbuild/bazel/issues/18694.224build:ci --remote_default_exec_properties=cache-silo-key=CleverPeafowl225 226###############################################################################227 228# The user.bazelrc file is not checked in but available for local mods.229# Always keep this at the end of the file so that user flags override.230try-import %workspace%/user.bazelrc231