diff options
author | 2016-04-01 09:38:55 +0000 | |
---|---|---|
committer | 2016-04-01 12:17:01 +0000 | |
commit | f9276e2442907c7a3d5a1eed64f4a8acc704f560 (patch) | |
tree | cd0fc8b8e4ea9c8449f2e4e6087e8b5f190d870e | |
parent | 97786962419caa1566e49d911b985c400d4367f5 (diff) |
Fix issues with cc_configure
Fixing a few issues with cc_configure that I encountered.
* The argument for rpath should be -Wl,-rpath.
* cc_configure should consider CPLUS_INCLUDE_PATH. I ran into this problem when using
a crosstool gcc which needs -I/usr/include.
* Check if -Wunused-but-set-parameter is available.
--
Change-Id: I73198b5b17674ecbf1b511e23fcc9331ca96c8e0
Reviewed-on: https://bazel-review.googlesource.com/#/c/3210/
MOS_MIGRATED_REVID=118763218
-rw-r--r-- | tools/cpp/cc_configure.bzl | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index d73a388b06..fc8a5d713f 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -75,13 +75,25 @@ def _ld_library_paths(repository_ctx): result = [] for p in repository_ctx.os.environ["LD_LIBRARY_PATH"].split(":"): p = str(repository_ctx.path(p)) # Normalize the path - result.append("-Wl,rpath," + p) + result.append("-Wl,-rpath," + p) result.append("-L" + p) return result else: return [] +def _cplus_include_paths(repository_ctx): + """Use ${CPLUS_INCLUDE_PATH} to compute the list of flags for cxxflag.""" + if "CPLUS_INCLUDE_PATH" in repository_ctx.os.environ: + result = [] + for p in repository_ctx.os.environ["CPLUS_INCLUDE_PATH"].split(":"): + p = str(repository_ctx.path(p)) # Normalize the path + result.append("-I" + p) + return result + else: + return [] + + def _get_cpu_value(repository_ctx): """Compute the cpu_value based on the OS name.""" os_name = repository_ctx.os.name.lower() @@ -143,7 +155,9 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin): "target_libc": "macosx" if darwin else "local", "target_cpu": cpu_value, "target_system_name": "local", - "cxx_flag": "-std=c++0x", + "cxx_flag": [ + "-std=c++0x", + ] + _cplus_include_paths(repository_ctx), "linker_flag": [ "-lstdc++", # Anticipated future default. @@ -185,10 +199,10 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin): "-Wall", # Enable a few more warnings that aren't part of -Wall. ] + (["-Wthread-safety", "-Wself-assign"] if darwin else [ - "-Wunused-but-set-parameter", # Disable some that are problematic. "-Wl,-z,-relro,-z,now" ]) + ( + _add_option_if_supported(repository_ctx, cc, "-Wunused-but-set-parameter") + # has false positives _add_option_if_supported(repository_ctx, cc, "-Wno-free-nonheap-object") + # Enable coloring even if there's no attached terminal. Bazel removes the |