summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2018-04-06 05:28:54 +0000
committerDean Michael Berris <dberris@google.com>2018-04-06 05:28:54 +0000
commit248148db0032b2f9061449b3dac0a5436ca16a3e (patch)
tree17e5c0be268f9867c5065186d995ba521940916c
parent1b25a3994e8c6be41b9ec8041a9c61ad2ae01f69 (diff)
downloadbcm5719-llvm-248148db0032b2f9061449b3dac0a5436ca16a3e.tar.gz
bcm5719-llvm-248148db0032b2f9061449b3dac0a5436ca16a3e.zip
[XRay][clang] Add a flag to enable/disable linking XRay deps explicitly
Summary: This change introduces `-fxray-link-deps` and `-fnoxray-link-deps`. The `-fnoxray-link-deps` allows for directly controlling which specific XRay runtime to link. The default is for clang to link the XRay runtime that is shipped with the compiler (if there are any), but users may want to explicitly add the XRay dependencies from other locations or other means. Reviewers: eizan, echristo, chandlerc Reviewed By: eizan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45354 llvm-svn: 329376
-rw-r--r--clang/include/clang/Driver/Options.td6
-rw-r--r--clang/include/clang/Driver/XRayArgs.h3
-rw-r--r--clang/lib/Driver/XRayArgs.cpp4
-rw-r--r--clang/test/Driver/XRay/xray-nolinkdeps.cpp6
4 files changed, 18 insertions, 1 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c72bb39ec5c..9367634d8af 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1107,6 +1107,12 @@ def fxray_always_emit_customevents : Flag<["-"], "fxray-always-emit-customevents
def fnoxray_always_emit_customevents : Flag<["-"], "fno-xray-always-emit-customevents">, Group<f_Group>,
Flags<[CC1Option]>;
+def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>,
+ Flags<[CC1Option]>,
+ HelpText<"Tells clang to add the link dependencies for XRay.">;
+def fnoxray_link_deps : Flag<["-"], "fnoxray-link-deps">, Group<f_Group>,
+ Flags<[CC1Option]>;
+
def ffine_grained_bitfield_accesses : Flag<["-"],
"ffine-grained-bitfield-accesses">, Group<f_clang_Group>, Flags<[CC1Option]>,
HelpText<"Use separate accesses for bitfields with legal widths and alignments.">;
diff --git a/clang/include/clang/Driver/XRayArgs.h b/clang/include/clang/Driver/XRayArgs.h
index b709ee4e87b..8eedd1dba1d 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -25,6 +25,7 @@ class XRayArgs {
bool XRayInstrument = false;
int InstructionThreshold = 200;
bool XRayAlwaysEmitCustomEvents = false;
+ bool XRayRT = true;
public:
/// Parses the XRay arguments from an argument list.
@@ -32,7 +33,7 @@ public:
void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
- bool needsXRayRt() const { return XRayInstrument; }
+ bool needsXRayRt() const { return XRayInstrument && XRayRT; }
};
} // namespace driver
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 19bf9b7d22c..e151cb907cd 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -76,6 +76,10 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
options::OPT_fnoxray_always_emit_customevents, false))
XRayAlwaysEmitCustomEvents = true;
+ if (!Args.hasFlag(options::OPT_fxray_link_deps,
+ options::OPT_fnoxray_link_deps, true))
+ XRayRT = false;
+
// Validate the always/never attribute files. We also make sure that they
// are treated as actual dependencies.
for (const auto &Filename :
diff --git a/clang/test/Driver/XRay/xray-nolinkdeps.cpp b/clang/test/Driver/XRay/xray-nolinkdeps.cpp
new file mode 100644
index 00000000000..7f17c939a43
--- /dev/null
+++ b/clang/test/Driver/XRay/xray-nolinkdeps.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -v -o /dev/null -fxray-instrument -fnoxray-link-deps %s -### \
+// RUN: 2>&1 | FileCheck --check-prefix DISABLE %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-link-deps %s -### \
+// RUN: 2>&1 | FileCheck --check-prefix ENABLE %s
+// ENABLE: clang_rt.xray
+// DISABLE-NOT: clang_rt.xray
OpenPOWER on IntegriCloud