aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2017-05-22 20:08:23 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-05-23 12:46:20 +0200
commit286428ad91270cfb67096f25212dbbd84c1f8fc8 (patch)
tree2a1f89ba1eeddf1f101cf8d5da010397a4c3a182 /tools
parent27ec410a4b818eb28e720a51246b805d2f00c00f (diff)
Wrap ar invocations for osx bazel crosstool.
This: 1. Forces ar invocations to go through xcrunwrapper (thus having the environment variables set correctly so that the appropriate xcode is used) 2. Institutes a fix for non-hermeticism around object file timestamps. RELNOTES: None. PiperOrigin-RevId: 156759530
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/cc_configure.bzl3
-rw-r--r--tools/osx/crosstool/CROSSTOOL.tpl80
-rw-r--r--tools/osx/crosstool/wrapped_ar.tpl21
3 files changed, 64 insertions, 40 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index d82e3f7889..cba009032d 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -815,6 +815,9 @@ def _impl(repository_ctx):
Label("@bazel_tools//tools/objc:make_hashed_objlist.py"),
"make_hashed_objlist.py")
repository_ctx.symlink(
+ Label("@bazel_tools//tools/osx/crosstool:wrapped_ar.tpl"),
+ "wrapped_ar")
+ repository_ctx.symlink(
Label("@bazel_tools//tools/osx/crosstool:wrapped_clang.tpl"),
"wrapped_clang")
repository_ctx.symlink(
diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl
index 5b1c286b37..307da21cd2 100644
--- a/tools/osx/crosstool/CROSSTOOL.tpl
+++ b/tools/osx/crosstool/CROSSTOOL.tpl
@@ -1217,7 +1217,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -1230,7 +1230,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -1243,7 +1243,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -1256,7 +1256,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -2478,7 +2478,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -2491,7 +2491,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -2504,7 +2504,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -2517,7 +2517,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -3741,7 +3741,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -3754,7 +3754,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -3767,7 +3767,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -3780,7 +3780,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -5041,7 +5041,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -5054,7 +5054,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -5067,7 +5067,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -5080,7 +5080,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -6302,7 +6302,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -6315,7 +6315,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -6328,7 +6328,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -6341,7 +6341,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -7548,7 +7548,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -7561,7 +7561,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -7574,7 +7574,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -7587,7 +7587,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -8796,7 +8796,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -8809,7 +8809,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -8822,7 +8822,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -8835,7 +8835,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -10081,7 +10081,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -10094,7 +10094,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -10107,7 +10107,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -10120,7 +10120,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -11327,7 +11327,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -11340,7 +11340,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -11353,7 +11353,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -11366,7 +11366,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -12579,7 +12579,7 @@ toolchain {
config_name: "c++-link-static-library"
action_name: "c++-link-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -12592,7 +12592,7 @@ toolchain {
config_name: "c++-link-alwayslink-static-library"
action_name: "c++-link-alwayslink-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -12605,7 +12605,7 @@ toolchain {
config_name: "c++-link-pic-static-library"
action_name: "c++-link-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
@@ -12618,7 +12618,7 @@ toolchain {
config_name: "c++-link-alwayslink-pic-static-library"
action_name: "c++-link-alwayslink-pic-static-library"
tool {
- tool_path: "/usr/bin/ar"
+ tool_path: "wrapped_ar"
}
implies: "global_whole_archive_open"
implies: "runtime_root_flags"
diff --git a/tools/osx/crosstool/wrapped_ar.tpl b/tools/osx/crosstool/wrapped_ar.tpl
new file mode 100644
index 0000000000..274be4c9f6
--- /dev/null
+++ b/tools/osx/crosstool/wrapped_ar.tpl
@@ -0,0 +1,21 @@
+# A trick to allow invoking this script in multiple contexts.
+if [ -z ${MY_LOCATION+x} ]; then
+ if [ -d "$0.runfiles/" ]; then
+ MY_LOCATION="$0.runfiles/bazel_tools/tools/objc"
+ else
+ MY_LOCATION="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ fi
+fi
+
+ARCHIVE_NAME=""
+for arg in "$@"; do
+ [[ "$ARCHIVE_NAME" = "" ]] && [[ "$arg" = *.* ]] && ARCHIVE_NAME="$arg"
+done
+
+# Prevents timestamp metadata being present in the archive contents.
+export ZERO_AR_DATE=1
+
+"${MY_LOCATION}"/xcrunwrapper.sh ar "$@"
+# Setting ZERO_AR_DATE for the above invocation means the output will have
+# zero timestamp, which, as an input, would break ld. Thus, update timestamp.
+touch "$ARCHIVE_NAME"