Skip to content

Commit

Permalink
[Driver] Correct -fnoxray-link-deps to -fno-xray-link-deps
Browse files Browse the repository at this point in the history
and removed unused CC1Option.
Also change -whole-archive to the canonical spelling and improve tests.
  • Loading branch information
MaskRay committed Jun 19, 2023
1 parent 2e6bb8c commit 407dcaf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2266,10 +2266,8 @@ defm xray_function_index : BoolFOption<"xray-function-index",
" expense of single-function patching performance">>;

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]>;
HelpText<"Link XRay runtime library when -fxray-instrument is specified (default)">;
def fno_xray_link_deps : Flag<["-"], "fno-xray-link-deps">, Group<f_Group>;

def fxray_instrumentation_bundle :
Joined<["-"], "fxray-instrumentation-bundle=">,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,11 +1236,11 @@ bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringLis
return false;

if (TC.getXRayArgs().needsXRayRt()) {
CmdArgs.push_back("-whole-archive");
CmdArgs.push_back("--whole-archive");
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
for (const auto &Mode : TC.getXRayArgs().modeList())
CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode));
CmdArgs.push_back("-no-whole-archive");
CmdArgs.push_back("--no-whole-archive");
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/XRayArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
<< XRayInstrument->getSpelling() << A->getSpelling();

if (!Args.hasFlag(options::OPT_fxray_link_deps,
options::OPT_fnoxray_link_deps, true))
options::OPT_fno_xray_link_deps, true))
XRayRT = false;

auto Bundles =
Expand Down
8 changes: 3 additions & 5 deletions clang/test/Driver/XRay/xray-nolinkdeps.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %clang -v -o /dev/null -fxray-instrument -fnoxray-link-deps %s -### \
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument -fxray-link-deps -fno-xray-link-deps %s \
// RUN: 2>&1 | FileCheck --check-prefix DISABLE %s
// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-link-deps %s -### \
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument %s \
// RUN: 2>&1 | FileCheck --check-prefix ENABLE %s
// ENABLE: clang_rt.xray
// ENABLE: "--whole-archive" "{{.*}}clang_rt.xray{{.*}}"--no-whole-archive"
// DISABLE-NOT: clang_rt.xray
// REQUIRES: linux || freebsd
// REQUIRES: amd64 || x86_64 || x86_64h || arm || aarch64 || arm64

0 comments on commit 407dcaf

Please sign in to comment.