Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1107,6 +1107,12 @@ def fnoxray_always_emit_customevents : Flag<["-"], "fno-xray-always-emit-customevents">, Group, Flags<[CC1Option]>; +def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group, + Flags<[CC1Option]>, + HelpText<"Tells clang to add the link dependencies for XRay.">; +def fnoxray_link_deps : Flag<["-"], "fnoxray-link-deps">, Group, + Flags<[CC1Option]>; + def ffine_grained_bitfield_accesses : Flag<["-"], "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>, HelpText<"Use separate accesses for bitfields with legal widths and alignments.">; Index: cfe/trunk/include/clang/Driver/XRayArgs.h =================================================================== --- cfe/trunk/include/clang/Driver/XRayArgs.h +++ cfe/trunk/include/clang/Driver/XRayArgs.h @@ -25,6 +25,7 @@ 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 @@ 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 Index: cfe/trunk/lib/Driver/XRayArgs.cpp =================================================================== --- cfe/trunk/lib/Driver/XRayArgs.cpp +++ cfe/trunk/lib/Driver/XRayArgs.cpp @@ -76,6 +76,10 @@ 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 : Index: cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp =================================================================== --- cfe/trunk/test/Driver/XRay/xray-nolinkdeps.cpp +++ cfe/trunk/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