Skip to content

Commit

Permalink
Automated rollback of commit 48881f1.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Broke a test

*** Original change description ***

The auto-configured toolchains provided by Bazel itself have diverged heavily from the version maintained in this repo. There is no need to maintain this duplication until Starlarkification has progressed succiciently for rules_cc to be the source of truth for them.

This is particularly relevant for Bzlmod, which currently uses the toolchains defined in rules_cc. As a result, Bazel C++ builds will use subtly different toolchains depending on whether --enable_bzlmod is used or not. This is fixed...

***

PiperOrigin-RevId: 501228335
Change-Id: I858dc3ea44df7ae70b5603f6dc2e082b4540c42a
  • Loading branch information
oquenchil authored and copybara-github committed Jan 11, 2023
1 parent 48881f1 commit bc665f9
Show file tree
Hide file tree
Showing 32 changed files with 7,737 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ x_defaults:
- "//:all"
- "//cc:all"
- "//cc/private/rules_impl:all"
- "//cc/private/toolchain:all"
- "//cc/runfiles:all"
- "//examples:all"
- "//examples/my_c_archive:all"
- "//examples/my_c_compile:all"
Expand All @@ -21,6 +23,7 @@ x_defaults:
- "//:all"
- "//cc:all"
- "//cc/private/rules_impl:all"
- "//cc/private/toolchain:all"
- "//examples:all"
- "//examples/my_c_archive:all"
- "//examples/my_c_compile:all"
Expand Down
3 changes: 3 additions & 0 deletions cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ filegroup(
name = "all_files_for_testing",
srcs = glob(["**"]) + [
"//cc/private/rules_impl:srcs",
"//cc/private/toolchain:srcs",
],
)

Expand Down Expand Up @@ -51,6 +52,7 @@ filegroup(
"**/*.bzl",
]) + [
"//cc/private/rules_impl:bzl_srcs",
"//cc/private/toolchain:bzl_srcs",
],
visibility = ["//visibility:public"],
)
Expand All @@ -62,6 +64,7 @@ filegroup(
"**/BUILD",
]) + [
"//cc/private/rules_impl:srcs",
"//cc/private/toolchain:srcs",
],
visibility = ["//visibility:public"],
)
Expand Down
2 changes: 1 addition & 1 deletion cc/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
"""Module extension for cc auto configuration."""

load("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_autoconf", "cc_autoconf_toolchains")
load("@bazel_tools//tools/osx:xcode_configure.bzl", "xcode_configure")
load("//cc/private/toolchain:cc_configure.bzl", "cc_autoconf", "cc_autoconf_toolchains")

def _cc_configure_impl(_):
cc_autoconf_toolchains(name = "local_config_cc_toolchains")
Expand Down
100 changes: 100 additions & 0 deletions cc/private/toolchain/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
load("//cc:defs.bzl", "cc_flags_supplier", "cc_library", "compiler_flag")

# Copyright 2018 The Bazel Authors. All rights reserved.
#
# 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.
#
package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

# It is frequently necessary to constrain platforms based on the cc compiler type.
constraint_setting(name = "cc_compiler")

constraint_value(
name = "clang",
constraint_setting = ":cc_compiler",
)

constraint_value(
name = "gcc",
constraint_setting = ":cc_compiler",
)

constraint_value(
name = "msvc",
constraint_setting = ":cc_compiler",
)

constraint_value(
name = "clang-cl",
constraint_setting = ":cc_compiler",
)

constraint_value(
name = "mingw",
constraint_setting = ":cc_compiler",
)

constraint_value(
name = "msys",
constraint_setting = ":cc_compiler",
)

cc_library(
name = "malloc",
)

filegroup(
name = "grep-includes",
srcs = ["grep-includes.sh"],
)

filegroup(
name = "empty",
srcs = [],
)

filegroup(
name = "bzl_srcs",
srcs = glob(["**/*.bzl"]),
)

filegroup(
name = "srcs",
srcs = glob(["**"]),
)

filegroup(
name = "interface_library_builder",
srcs = ["build_interface_so"],
)

filegroup(
name = "osx_wrapper",
srcs = ["osx_cc_wrapper.sh"],
)

filegroup(
name = "link_dynamic_library",
srcs = ["link_dynamic_library.sh"],
)

filegroup(
name = "lib_cc_configure",
srcs = ["lib_cc_configure.bzl"],
)

compiler_flag(name = "compiler")

cc_flags_supplier(name = "cc_flags")
52 changes: 52 additions & 0 deletions cc/private/toolchain/BUILD.empty
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2018 The Bazel Authors. All rights reserved.
#
# 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.

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_toolchain", "cc_toolchain_suite")

package(default_visibility = ["//visibility:public"])

load(":cc_toolchain_config.bzl", "cc_toolchain_config")

cc_library(
name = "malloc",
)

filegroup(
name = "empty",
srcs = [],
)

cc_toolchain_suite(
name = "toolchain",
toolchains = {
"local": ":local",
"local|local": ":local",
},
)

cc_toolchain(
name = "local",
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
toolchain_config = ":local_config",
toolchain_identifier = "local",
)

cc_toolchain_config(name = "local_config")
112 changes: 112 additions & 0 deletions cc/private/toolchain/BUILD.static.freebsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright 2018 The Bazel Authors. All rights reserved.
#
# 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.

# This becomes the BUILD file for @local_config_cc// under FreeBSD.

package(default_visibility = ["//visibility:public"])

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_toolchain", "cc_toolchain_suite")
load(":cc_toolchain_config.bzl", "cc_toolchain_config")

cc_library(
name = "malloc",
)

filegroup(
name = "empty",
srcs = [],
)

# Hardcoded toolchain, legacy behaviour.
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"freebsd": ":cc-compiler-freebsd",
"freebsd|compiler": ":cc-compiler-freebsd",
},
)

cc_toolchain(
name = "cc-compiler-freebsd",
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 0,
toolchain_config = ":local_freebsd",
toolchain_identifier = "local_freebsd",
)

cc_toolchain_config(
name = "local_freebsd",
cpu = "freebsd",
)

toolchain(
name = "cc-toolchain-freebsd",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:freebsd",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:freebsd",
],
toolchain = ":cc-compiler-freebsd",
toolchain_type = "@rules_cc//cc:toolchain_type",
)

cc_toolchain(
name = "cc-compiler-armeabi-v7a",
all_files = ":empty",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 0,
toolchain_config = ":stub_armeabi-v7a",
toolchain_identifier = "stub_armeabi-v7a",
)

cc_toolchain_config(
name = "stub_armeabi-v7a",
cpu = "armeabi-v7a",
)

toolchain(
name = "cc-toolchain-armeabi-v7a",
exec_compatible_with = [
"@platforms//cpu:arm",
],
target_compatible_with = [
"@platforms//cpu:arm",
"@platforms//os:android",
],
toolchain = ":cc-compiler-armeabi-v7a",
toolchain_type = "@rules_cc//cc:toolchain_type",
)

filegroup(
name = "link_dynamic_library",
srcs = ["link_dynamic_library.sh"],
)
20 changes: 20 additions & 0 deletions cc/private/toolchain/BUILD.toolchains.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")

toolchain(
name = "cc-toolchain-%{name}",
exec_compatible_with = HOST_CONSTRAINTS,
target_compatible_with = HOST_CONSTRAINTS,
toolchain = "@local_config_cc//:cc-compiler-%{name}",
toolchain_type = "@rules_cc//cc:toolchain_type",
)

toolchain(
name = "cc-toolchain-armeabi-v7a",
exec_compatible_with = HOST_CONSTRAINTS,
target_compatible_with = [
"@platforms//cpu:arm",
"@platforms//os:android",
],
toolchain = "@local_config_cc//:cc-compiler-armeabi-v7a",
toolchain_type = "@rules_cc//cc:toolchain_type",
)
Loading

0 comments on commit bc665f9

Please sign in to comment.