Rollback of commit 87a58589d6770a6e9a0f998274bfe69f1feb6014. *** Reason for rollback *** The sandbox fix did not fix. More work is needed. Fixes #1239 *** Original change description *** Automated [] rollback of commit b4549fe8dfb29f87fd37b38bf21a5b4bef818b12. *** Reason for rollback *** Rollforward with fixes: - Quote single-quote in the environment exports - Exclude the following environment variables: _ and dotted names - Add the wrapper to the dependency of the crosstool chain so it gets shipped to the sandbox. Hopefully after that we can cut a new release and have a homebrew package again #1177. *** Original change description *** Automated [] rollback of commit f1f24fc4b5aa83b7a4b872ec8f1c3a369799c081. *** Reason... *** -- MOS_MIGRATED_REVID=121665313
diff --git a/tools/cpp/BUILD.tpl b/tools/cpp/BUILD.tpl index a67d049..036c7ec 100644 --- a/tools/cpp/BUILD.tpl +++ b/tools/cpp/BUILD.tpl
@@ -13,11 +13,6 @@ srcs = [], ) -filegroup( - name = "cc_wrapper", - srcs = ["cc_wrapper.sh"], -) - # This is the entry point for --crosstool_top. Toolchains are found # by lopping off the name of --crosstool_top and searching for # the "${CPU}" entry in the toolchains attribute. @@ -32,11 +27,11 @@ cc_toolchain( name = "cc-compiler-%{name}", all_files = ":empty", - compiler_files = ":cc_wrapper", + compiler_files = ":empty", cpu = "local", dwp_files = ":empty", dynamic_runtime_libs = [":empty"], - linker_files = ":cc_wrapper", + linker_files = ":empty", objcopy_files = ":empty", static_runtime_libs = [":empty"], strip_files = ":empty",
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 18b8130..1250d23 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl
@@ -50,7 +50,7 @@ return default if result == None else str(result) -def _get_tool_paths(repository_ctx, darwin): +def _get_tool_paths(repository_ctx, darwin, cc): """Compute the path to the various tools.""" return {k: _which(repository_ctx, k, "/usr/bin/" + k) for k in [ @@ -63,7 +63,7 @@ "objdump", "strip", ]} + { - "gcc": "cc_wrapper.sh", + "gcc": cc, "ar": "/usr/bin/libtool" if darwin else _which(repository_ctx, "ar", "/usr/bin/ar") } @@ -289,24 +289,13 @@ return cc -def _tpl(repository_ctx, tpl, substitutions={}, out=None): - if not out: - out = tpl +def _tpl(repository_ctx, tpl, substitutions={}): repository_ctx.template( - out, + tpl, Label("@bazel_tools//tools/cpp:%s.tpl" % tpl), substitutions) -def _get_env(repository_ctx): - """Convert the environment in a list of export.""" - env = repository_ctx.os.environ - return "\n".join([ - "export %s='%s'" % (k, env[k].replace("'", "'\\''")) - for k in env - if k != "_" and k.find(".") == -1 - ]) - def _impl(repository_ctx): repository_ctx.file("tools/cpp/empty.cc") cpu_value = _get_cpu_value(repository_ctx) @@ -322,8 +311,9 @@ else: darwin = cpu_value == "darwin" cc = _find_cc(repository_ctx) + crosstool_cc = "osx_cc_wrapper.sh" if darwin else str(cc) darwin = cpu_value == "darwin" - tool_paths = _get_tool_paths(repository_ctx, darwin) + tool_paths = _get_tool_paths(repository_ctx, darwin, crosstool_cc) crosstool_content = _crosstool_content(repository_ctx, cc, cpu_value, darwin) opt_content = _opt_content(darwin) dbg_content = _dbg_content() @@ -331,10 +321,7 @@ "%{name}": cpu_value, "%{supports_param_files}": "0" if darwin else "1" }) - _tpl(repository_ctx, - "osx_cc_wrapper.sh" if darwin else "linux_cc_wrapper.sh", - {"%{cc}": str(cc), "%{env}": _get_env(repository_ctx)}, - "cc_wrapper.sh") + _tpl(repository_ctx, "osx_cc_wrapper.sh", {"%{cc}": str(cc)}) _tpl(repository_ctx, "CROSSTOOL", { "%{cpu}": cpu_value, "%{content}": _build_crosstool(crosstool_content) + "\n" +
diff --git a/tools/cpp/linux_cc_wrapper.sh.tpl b/tools/cpp/linux_cc_wrapper.sh.tpl deleted file mode 100644 index a83be50..0000000 --- a/tools/cpp/linux_cc_wrapper.sh.tpl +++ /dev/null
@@ -1,25 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 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. -# -# Ship the environment to the C++ action -# -set -eu - -# Set-up the environment -%{env} - -# Call the C++ compiler -%{cc} "$@"
diff --git a/tools/cpp/osx_cc_wrapper.sh.tpl b/tools/cpp/osx_cc_wrapper.sh.tpl index 5ea4b52c..5e66680 100644 --- a/tools/cpp/osx_cc_wrapper.sh.tpl +++ b/tools/cpp/osx_cc_wrapper.sh.tpl
@@ -52,9 +52,6 @@ fi done -# Set-up the environment -%{env} - # Call the C++ compiler %{cc} "$@"