Skip to content

Commit 63d2e2b

Browse files
committed
[clang][Driver] Support passing arbitrary args to -cc1as with -Xclangas.
Closes #97517.
1 parent 70a9535 commit 63d2e2b

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

clang/docs/UsersManual.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4876,6 +4876,7 @@ Execute ``clang-cl /?`` to see a list of supported options:
48764876
-v Show commands to run and use verbose output
48774877
-W<warning> Enable the specified warning
48784878
-Xclang <arg> Pass <arg> to the clang compiler
4879+
-Xclangas <arg> Pass <arg> to the clang assembler
48794880

48804881
The /clang: Option
48814882
^^^^^^^^^^^^^^^^^^

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,18 @@ def Xclang : Separate<["-"], "Xclang">,
10281028
HelpText<"Pass <arg> to clang -cc1">, MetaVarName<"<arg>">,
10291029
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
10301030
Group<CompileOnly_Group>;
1031+
def Xclangas : Separate<["-"], "Xclangas">,
1032+
HelpText<"Pass <arg> to clang -cc1as">, MetaVarName<"<arg>">,
1033+
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
1034+
Group<CompileOnly_Group>;
10311035
def : Joined<["-"], "Xclang=">, Group<CompileOnly_Group>,
10321036
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
10331037
Alias<Xclang>,
10341038
HelpText<"Alias for -Xclang">, MetaVarName<"<arg>">;
1039+
def : Joined<["-"], "Xclangas=">, Group<CompileOnly_Group>,
1040+
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>,
1041+
Alias<Xclangas>,
1042+
HelpText<"Alias for -Xclangas">, MetaVarName<"<arg>">;
10351043
def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
10361044
HelpText<"Pass <arg> to fatbinary invocation">, MetaVarName<"<arg>">;
10371045
def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8711,6 +8711,12 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
87118711
CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
87128712
getToolChain().getDriver());
87138713

8714+
// Forward -Xclangas arguments to -cc1as
8715+
for (auto Arg : Args.filtered(options::OPT_Xclangas)) {
8716+
Arg->claim();
8717+
CmdArgs.push_back(Arg->getValue());
8718+
}
8719+
87148720
Args.AddAllArgs(CmdArgs, options::OPT_mllvm);
87158721

87168722
if (DebugInfoKind > llvm::codegenoptions::NoDebugInfo && Output.isFilename())

clang/test/Driver/Xclangas.s

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Check that -Xclangas passes args to -cc1as.
2+
// RUN: %clang -### -Xclangas -target-feature -Xclangas +v5t %s 2>&1 | \
3+
// RUN: FileCheck -check-prefix=ARGS %s
4+
// ARGS: -cc1as
5+
// ARGS: -target-feature
6+
// ARGS: +v5t

0 commit comments

Comments
 (0)