-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build/sysroots] Add generic llvm variant handling.
Summary: Instead of explicitly listing select options for the different llvm variants, this diff hides it behind a few starlark macros. This generic handling allows easier additions of new llvm variants, for example, for the variants for the new sysroots that will be added in a future diff. Test Plan: Shouldn't be any functional changes. Relying on existing tests. Reviewers: vihang, zasgar, michelle, #third_party_approvers Reviewed By: vihang, #third_party_approvers Signed-off-by: James Bartlett <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D12854 GitOrigin-RevId: 3aef9d9f5db74d61634fd2d7d340801c646189cd
- Loading branch information
1 parent
ae40d03
commit f5de1c0
Showing
8 changed files
with
105 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2018- The Pixie Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
load("@bazel_skylib//lib:selects.bzl", "selects") | ||
|
||
def _llvm_variants(): | ||
variants = [] | ||
|
||
# TODO(james): add sysroot variants. | ||
# Add variants for our non sysroot config. | ||
variants.append(("x86_64", "glibc_host", True)) | ||
variants.append(("x86_64", "glibc_host", False)) | ||
return variants | ||
|
||
def _llvm_variant_settings(): | ||
for variant in _llvm_variants(): | ||
arch, libc_version, use_libcpp = variant | ||
configs_to_match = [ | ||
":libc_version_" + libc_version, | ||
"@platforms//cpu:" + arch, | ||
] | ||
if use_libcpp: | ||
configs_to_match.append("//bazel:use_libcpp") | ||
else: | ||
configs_to_match.append("//bazel:use_libstdcpp") | ||
selects.config_setting_group( | ||
name = _llvm_variant_setting_name(variant), | ||
match_all = configs_to_match, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
def _llvm_variant_setting_name(variant): | ||
arch, libc_version, use_libcpp = variant | ||
name = "llvm_variant_{arch}_{libc_version}".format( | ||
arch = arch, | ||
libc_version = libc_version, | ||
) | ||
if use_libcpp: | ||
name = name + "_libcpp" | ||
return name | ||
|
||
def _llvm_variant_setting_label(variant): | ||
name = _llvm_variant_setting_name(variant) | ||
return "@px//bazel/cc_toolchains:" + name | ||
|
||
def _llvm_variant_repo_name(variant): | ||
arch, libc_version, use_libcpp = variant | ||
return "com_llvm_lib{libcpp}_{arch}_{libc_version}".format( | ||
arch = arch, | ||
libc_version = libc_version.replace(".", "_"), | ||
libcpp = "_libcpp" if use_libcpp else "", | ||
) | ||
|
||
llvm_variant_settings = _llvm_variant_settings | ||
llvm_variant_setting_label = _llvm_variant_setting_label | ||
llvm_variant_repo_name = _llvm_variant_repo_name | ||
llvm_variants = _llvm_variants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters