Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][Driver] Support passing arbitrary args to -cc1as with -Xclangas. #100714

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading