Skip to content

Commit

Permalink
[clang][Driver] Support passing arbitrary args to -cc1as with -Xclangas.
Browse files Browse the repository at this point in the history
Closes llvm#97517.
  • Loading branch information
alexrp committed Jul 26, 2024
1 parent 70a9535 commit 63d2e2b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4876,6 +4876,7 @@ Execute ``clang-cl /?`` to see a list of supported options:
-v Show commands to run and use verbose output
-W<warning> Enable the specified warning
-Xclang <arg> Pass <arg> to the clang compiler
-Xclangas <arg> Pass <arg> to the clang assembler

The /clang: Option
^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,18 @@ def Xclang : Separate<["-"], "Xclang">,
HelpText<"Pass <arg> to clang -cc1">, MetaVarName<"<arg>">,
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
Group<CompileOnly_Group>;
def Xclangas : Separate<["-"], "Xclangas">,
HelpText<"Pass <arg> to clang -cc1as">, MetaVarName<"<arg>">,
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
Group<CompileOnly_Group>;
def : Joined<["-"], "Xclang=">, Group<CompileOnly_Group>,
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
Alias<Xclang>,
HelpText<"Alias for -Xclang">, MetaVarName<"<arg>">;
def : Joined<["-"], "Xclangas=">, Group<CompileOnly_Group>,
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
Alias<Xclangas>,
HelpText<"Alias for -Xclangas">, MetaVarName<"<arg>">;
def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
HelpText<"Pass <arg> to fatbinary invocation">, MetaVarName<"<arg>">;
def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8711,6 +8711,12 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
getToolChain().getDriver());

// Forward -Xclangas arguments to -cc1as
for (auto Arg : Args.filtered(options::OPT_Xclangas)) {
Arg->claim();
CmdArgs.push_back(Arg->getValue());
}

Args.AddAllArgs(CmdArgs, options::OPT_mllvm);

if (DebugInfoKind > llvm::codegenoptions::NoDebugInfo && Output.isFilename())
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/Xclangas.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Check that -Xclangas passes args to -cc1as.
// RUN: %clang -### -Xclangas -target-feature -Xclangas +v5t %s 2>&1 | \
// RUN: FileCheck -check-prefix=ARGS %s
// ARGS: -cc1as
// ARGS: -target-feature
// ARGS: +v5t

0 comments on commit 63d2e2b

Please sign in to comment.