@@ -295,6 +295,30 @@ void tools::hlsl::MetalConverter::ConstructJob(
295295 Exec, CmdArgs, Inputs, Input));
296296}
297297
298+ void tools::hlsl::LLVMObjcopy::ConstructJob (Compilation &C, const JobAction &JA,
299+ const InputInfo &Output,
300+ const InputInfoList &Inputs,
301+ const ArgList &Args,
302+ const char *LinkingOutput) const {
303+
304+ std::string ObjcopyPath = getToolChain ().GetProgramPath (" llvm-objcopy" );
305+ const char *Exec = Args.MakeArgString (ObjcopyPath);
306+
307+ ArgStringList CmdArgs;
308+ assert (Inputs.size () == 1 && " Unable to handle multiple inputs." );
309+ const InputInfo &Input = Inputs[0 ];
310+ CmdArgs.push_back (Input.getFilename ());
311+ CmdArgs.push_back (Output.getFilename ());
312+
313+ if (Args.hasArg (options::OPT_dxc_strip_rootsignature)) {
314+ const char *Frs = Args.MakeArgString (" --remove-section=RTS0" );
315+ CmdArgs.push_back (Frs);
316+ }
317+
318+ C.addCommand (std::make_unique<Command>(JA, *this , ResponseFileSupport::None (),
319+ Exec, CmdArgs, Inputs, Input));
320+ }
321+
298322// / DirectX Toolchain
299323HLSLToolChain::HLSLToolChain (const Driver &D, const llvm::Triple &Triple,
300324 const ArgList &Args)
@@ -315,6 +339,10 @@ Tool *clang::driver::toolchains::HLSLToolChain::getTool(
315339 if (!MetalConverter)
316340 MetalConverter.reset (new tools::hlsl::MetalConverter (*this ));
317341 return MetalConverter.get ();
342+ case Action::BinaryModifyJobClass:
343+ if (!LLVMObjcopy)
344+ LLVMObjcopy.reset (new tools::hlsl::LLVMObjcopy (*this ));
345+ return LLVMObjcopy.get ();
318346 default :
319347 return ToolChain::getTool (AC);
320348 }
@@ -452,16 +480,25 @@ bool HLSLToolChain::requiresBinaryTranslation(DerivedArgList &Args) const {
452480 return Args.hasArg (options::OPT_metal) && Args.hasArg (options::OPT_dxc_Fo);
453481}
454482
483+ bool HLSLToolChain::requiresObjcopy (DerivedArgList &Args) const {
484+ return Args.hasArg (options::OPT_dxc_Fo) &&
485+ Args.hasArg (options::OPT_dxc_strip_rootsignature);
486+ }
487+
455488bool HLSLToolChain::isLastJob (DerivedArgList &Args,
456489 Action::ActionClass AC) const {
457490 bool HasTranslation = requiresBinaryTranslation (Args);
458491 bool HasValidation = requiresValidation (Args);
492+ bool HasObjcopy = requiresObjcopy (Args);
459493 // If translation and validation are not required, we should only have one
460494 // action.
461- if (!HasTranslation && !HasValidation)
495+ if (!HasTranslation && !HasValidation && !HasObjcopy )
462496 return true ;
463497 if ((HasTranslation && AC == Action::BinaryTranslatorJobClass) ||
464- (!HasTranslation && HasValidation && AC == Action::BinaryAnalyzeJobClass))
498+ (!HasTranslation && HasValidation &&
499+ AC == Action::BinaryAnalyzeJobClass) ||
500+ (!HasTranslation && !HasValidation && HasObjcopy &&
501+ AC == Action::BinaryModifyJobClass))
465502 return true ;
466503 return false ;
467504}
0 commit comments