Rollback of commit cc3d79cca775cad9e9193d38bedf4df51a5c8a50.
*** Reason for rollback ***
Breaks bazel: http://ci.bazel.build/job/bazel-tests/329/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/console
*** Original change description ***
Support gold linker
--
MOS_MIGRATED_REVID=139810019
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 4296b44..329eb05 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -186,7 +186,7 @@
return [repository_ctx.path(_cxx_inc_convert(p))
for p in inc_dirs.split("\n")]
-def _is_option_supported(repository_ctx, cc, option):
+def _add_option_if_supported(repository_ctx, cc, option):
"""Checks that `option` is supported by the C compiler."""
result = repository_ctx.execute([
cc,
@@ -196,18 +196,11 @@
"-c",
str(repository_ctx.path("tools/cpp/empty.cc"))
])
- return result.stderr.find(option) == -1
+ return [option] if result.stderr.find(option) == -1 else []
-def _add_option_if_supported(repository_ctx, cc, option):
- """Checks that `option` is supported by the C compiler."""
- if _is_option_supported(repository_ctx, cc, option) == -1:
- return [option]
- else:
- return []
def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
"""Return the content for the CROSSTOOL file, in a dictionary."""
- supports_gold_linker = _is_option_supported(repository_ctx, cc, "-fuse-ld=gold")
return {
"abi_version": "local",
"abi_libc_version": "local",
@@ -215,12 +208,12 @@
"compiler": "compiler",
"host_system_name": "local",
"needsPic": True,
- "supports_gold_linker": supports_gold_linker,
+ "supports_gold_linker": False,
"supports_incremental_linker": False,
"supports_fission": False,
"supports_interface_shared_objects": False,
"supports_normalizing_ar": False,
- "supports_start_end_lib": supports_gold_linker,
+ "supports_start_end_lib": False,
"target_libc": "macosx" if darwin else "local",
"target_cpu": cpu_value,
"target_system_name": "local",
@@ -231,9 +224,7 @@
"-lstdc++",
"-lm", # Some systems expect -lm in addition to -lstdc++
# Anticipated future default.
- ] + (
- ["-fuse-ld=gold"] if supports_gold_linker else []
- ) + _add_option_if_supported(repository_ctx, cc, "-Wl,-no-as-needed") + (
+ ] + _add_option_if_supported(repository_ctx, cc, "-Wl,-no-as-needed") + (
[
"-undefined",
"dynamic_lookup",