[llvm] [Bazel] Make LLVM and Clang config headers configurable (PR #126729)
Aaron Siddhartha Mondal via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 14 05:00:36 PST 2025
================
@@ -0,0 +1,158 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+"""Configurable build attributes for LLVM."""
+
+load("@bazel_skylib//lib:selects.bzl", "selects")
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
+
+# To view the configurable build attributes in this file:
+#
+# bazel query 'kind(".*_flag", @llvm-project//llvm/config:all)'
+
+selects.config_setting_group(
+ name = "aarch64-unknown-linux-gnu",
+ match_all = [
+ "@platforms//cpu:aarch64",
+ "@platforms//os:linux",
+ ],
+)
+
+selects.config_setting_group(
+ name = "arm64-apple-darwin",
+ match_all = [
+ "@platforms//cpu:arm64",
+ "@platforms//os:macos",
+ ],
+)
+
+selects.config_setting_group(
+ name = "powerpc64le-unknown-linux-gnu",
+ match_all = [
+ "@platforms//cpu:ppc64le",
+ "@platforms//os:linux",
+ ],
+)
+
+selects.config_setting_group(
+ name = "systemz-unknown-linux_gnu",
+ match_all = [
+ "@platforms//cpu:s390x",
+ "@platforms//os:linux",
+ ],
+)
+
+selects.config_setting_group(
+ name = "x86_64-pc-win32",
+ match_all = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
+ ],
+)
+
+selects.config_setting_group(
+ name = "x86_64-unknown-darwin",
+ match_all = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:macos",
+ ],
+)
+
+selects.config_setting_group(
+ name = "x86_64-unknown-linux-gnu",
+ match_all = [
+ "@platforms//cpu:x86_64",
+ "@platforms//os:linux",
+ ],
+)
+
+selects.config_setting_group(
+ name = "posix",
+ match_any = [
+ "@platforms//os:linux",
+ "@platforms//os:macos",
+ "@platforms//os:freebsd",
+ ],
+)
+
+# Directly configurable boolean build attributes.
----------------
aaronmondal wrote:
Yeah the benefits vastly outweigh the cons. We get:
- Consistency with the CMake behavior where all the `-DSOMECONFIG` look global to the user.
- An easy way to query all available flags
- Reduced filecount and config_setting_group reuse with fewer imports
- Shorter condition strings in selects
We lose:
- A file-level 1:1 correspondence to the CMake structure. But while we lose the file-level matching, we gain the user-experience of the CMake build (i.e. the "global" feeling of the flag).
https://github.com/llvm/llvm-project/pull/126729
More information about the llvm-commits
mailing list