r329376 - [XRay][clang] Add a flag to enable/disable linking XRay deps explicitly

Dean Michael Berris via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 5 22:28:54 PDT 2018


Author: dberris
Date: Thu Apr  5 22:28:54 2018
New Revision: 329376

URL: http://llvm.org/viewvc/llvm-project?rev=329376&view=rev
Log:
[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

Added:
    cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/include/clang/Driver/XRayArgs.h
    cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329376&r1=329375&r2=329376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 22:28:54 2018
@@ -1107,6 +1107,12 @@ def fxray_always_emit_customevents : Fla
 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.">;

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329376&r1=329375&r2=329376&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Thu Apr  5 22:28:54 2018
@@ -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

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329376&r1=329375&r2=329376&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Apr  5 22:28:54 2018
@@ -76,6 +76,10 @@ XRayArgs::XRayArgs(const ToolChain &TC,
                      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 :

Added: cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp?rev=329376&view=auto
==============================================================================
--- cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp Thu Apr  5 22:28:54 2018
@@ -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




More information about the cfe-commits mailing list