aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-03-08 15:59:27 +0000
committerGravatar David Chen <dzc@google.com>2016-03-08 22:59:10 +0000
commit8a9e9ab46ac1c644b5b3ab198d0d352416f33fe5 (patch)
treedeea46c3a0a47ecc907ede035ca32b9030051097 /tools
parentc5a5d9058f11a84dd6c7da88ad2f3c1004686d3f (diff)
cc_configure: fix issues with CentOS 6.7 and custom gcc
This setup was provided on issue #760. -- MOS_MIGRATED_REVID=116656431
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/cc_configure.bzl27
-rw-r--r--tools/cpp/test/Dockerfile.centos6.715
2 files changed, 33 insertions, 9 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 2780bddafa..5ad70a9b66 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -74,7 +74,7 @@ def _ld_library_paths(ctx):
if "LD_LIBRARY_PATH" in ctx.os.environ:
result = []
for p in ctx.os.environ["LD_LIBRARY_PATH"].split(":"):
- p = ctx.path(p) # Normalize the path
+ p = str(ctx.path(p)) # Normalize the path
result.append("-Wl,rpath," + p)
result.append("-L" + p)
return result
@@ -106,7 +106,14 @@ def _get_cxx_inc_directories(ctx, cc):
def _add_option_if_supported(ctx, cc, option):
"""Checks that `option` is supported by the C compiler."""
- result = ctx.execute([cc, option])
+ result = ctx.execute([
+ cc,
+ option,
+ "-o",
+ "/dev/null",
+ "-c",
+ str(ctx.path("tools/cpp/empty.cc"))
+ ])
return [option] if result.stderr.find(option) == -1 else []
@@ -133,9 +140,9 @@ def _crosstool_content(ctx, cc, cpu_value, darwin):
"linker_flag": [
"-lstdc++",
# Anticipated future default.
- "-no-canonical-prefixes"
- ] + (["-undefined", "dynamic_lookup"] if darwin else [
- "-B/usr/bin",
+ ] + _add_option_if_supported(ctx, cc, "-no-canonical-prefixes") + (
+ ["-undefined", "dynamic_lookup"] if darwin else [
+ "-B" + str(ctx.path(cc).dirname),
# Have gcc return the exit code from ld.
"-pass-exit-codes",
# Stamp the binary with a unique identifier.
@@ -148,10 +155,10 @@ def _crosstool_content(ctx, cc, cpu_value, darwin):
"ar_flag": ["-static", "-s", "-o"] if darwin else [],
"cxx_builtin_include_directory": _get_cxx_inc_directories(ctx, cc),
"objcopy_embed_flag": ["-I", "binary"],
- "unfiltered_cxx_flag": [
+ "unfiltered_cxx_flag":
# Anticipated future default.
- "-no-canonical-prefixes",
- ] + ([] if darwin else ["-fno-canonical-system-headers"]) + [
+ _add_option_if_supported(ctx, cc, "-no-canonical-prefixes") +
+ _add_option_if_supported(ctx, cc, "-fno-canonical-system-headers") + [
# Make C++ compilation deterministic. Use linkstamping instead of these
# compiler symbols.
"-Wno-builtin-macro-redefined",
@@ -173,9 +180,10 @@ def _crosstool_content(ctx, cc, cpu_value, darwin):
] + (["-Wthread-safety", "-Wself-assign"] if darwin else [
"-Wunused-but-set-parameter",
# Disable some that are problematic.
- "-Wno-free-nonheap-object", # has false positives
"-Wl,-z,-relro,-z,now"
]) + (
+ # has false positives
+ _add_option_if_supported(ctx, cc, "-Wno-free-nonheap-object") +
# Enable coloring even if there's no attached terminal. Bazel removes the
# escape sequences if --nocolor is specified.
_add_option_if_supported(ctx, cc, "-fcolor-diagnostics")) + [
@@ -236,6 +244,7 @@ def _tpl(ctx, tpl, substitutions={}):
def _impl(ctx):
+ ctx.file("tools/cpp/empty.cc")
cpu_value = _get_cpu_value(ctx)
darwin = cpu_value == "darwin"
cc = _find_cc(ctx)
diff --git a/tools/cpp/test/Dockerfile.centos6.7 b/tools/cpp/test/Dockerfile.centos6.7
new file mode 100644
index 0000000000..9cab385cf0
--- /dev/null
+++ b/tools/cpp/test/Dockerfile.centos6.7
@@ -0,0 +1,15 @@
+FROM centos:centos6.7
+
+RUN yum -y upgrade
+
+RUN yum -y install \
+ java-1.8.0-openjdk-devel \
+ wget which findutils binutils gcc tar gzip \
+ zip unzip java java-devel git clang zlib-devel \
+ gcc-c++
+
+RUN wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
+RUN yum -y install devtoolset-2-gcc devtoolset-2-gcc-c++ devtoolset-2-binutils
+
+ENV JAVA_HOME /usr/lib/jvm/java-1.8.0
+ENV CC /opt/rh/devtoolset-2/root/usr/bin/gcc