@@ -603,45 +603,46 @@ static LogicalResult generateCoreElfFiles(
603
603
chessArgs.emplace_back (" -o" );
604
604
chessArgs.emplace_back (elfFile.string ());
605
605
std::vector<std::string> env = makeChessEnv (*vitisDir, npuVersion);
606
- return runTool (xChessCCExe, chessArgs, verbose, env);
607
- }
606
+ if (failed (runTool (xChessCCExe, chessArgs, verbose, env))) {
607
+ return deviceOp.emitOpError () << " failed to generate elf for core: ("
608
+ << col << " , " << row << " )" ;
609
+ }
610
+ } else {
611
+ Path ldscriptPath = tempDir / (elfFileName + " .ld" );
612
+ {
613
+ auto ldscriptOutput =
614
+ openOutputFile (ldscriptPath.string (), &errorMessage);
615
+ if (!ldscriptOutput) {
616
+ llvm::errs () << " Failed to open ldscript file because: "
617
+ << errorMessage;
618
+ return failure ();
619
+ }
620
+ if (failed (mlir::iree_compiler::AMDAIE::AIETranslateToLdScript (
621
+ deviceOp, ldscriptOutput->os (), col, row))) {
622
+ return failure ();
623
+ }
624
+ ldscriptOutput->keep ();
625
+ }
608
626
609
- Path ldscriptPath = tempDir / (elfFileName + " .ld" );
610
- {
611
- auto ldscriptOutput =
612
- openOutputFile (ldscriptPath.string (), &errorMessage);
613
- if (!ldscriptOutput) {
614
- llvm::errs () << " Failed to open ldscript file because: "
615
- << errorMessage;
616
- return failure ();
627
+ std::string targetLower = StringRef (targetArch).lower ();
628
+ std::vector<std::string> flags;
629
+ flags.emplace_back (objFile);
630
+ if (ukernel && (ukernel == " mm" || ukernel == " all" )) {
631
+ flags.emplace_back (mmObjectFilePath->string ());
617
632
}
618
- if (failed (mlir::iree_compiler::AMDAIE::AIETranslateToLdScript (
619
- deviceOp, ldscriptOutput->os (), col, row))) {
620
- llvm::errs () << " failed to generate ld script for core (" << col << " ,"
621
- << row << " )\n " ;
633
+ flags.emplace_back (" --target=" + targetLower + " -none-unknown-elf" );
634
+ flags.emplace_back (" -Wl,--gc-sections" );
635
+ flags.emplace_back (" -Wl,--orphan-handling=error" );
636
+ flags.emplace_back (" -Wl,-T," + ldscriptPath.string ());
637
+ flags.emplace_back (" -o" );
638
+ flags.emplace_back (elfFile.string ());
639
+ if (verbose) flags.emplace_back (" -v" );
640
+ // we run clang (ie cc) so that libc, libm, crt0/1 paths are injected
641
+ // automatically into the ld.lld invocation
642
+ if (failed (
643
+ runTool ((peanoDir / " bin" / " clang" ).string (), flags, verbose))) {
622
644
return failure ();
623
645
}
624
- ldscriptOutput->keep ();
625
- }
626
-
627
- std::string targetLower = StringRef (targetArch).lower ();
628
- std::vector<std::string> flags;
629
- flags.emplace_back (objFile);
630
- if (ukernel && (ukernel == " mm" || ukernel == " all" )) {
631
- flags.emplace_back (mmObjectFilePath->string ());
632
- }
633
- flags.emplace_back (" --target=" + targetLower + " -none-unknown-elf" );
634
- flags.emplace_back (" -Wl,--gc-sections" );
635
- flags.emplace_back (" -Wl,--orphan-handling=error" );
636
- flags.emplace_back (" -Wl,-T," + ldscriptPath.string ());
637
- flags.emplace_back (" -o" );
638
- flags.emplace_back (elfFile.string ());
639
- if (verbose) flags.emplace_back (" -v" );
640
- // we run clang (ie cc) so that libc, libm, crt0/1 paths are injected
641
- // automatically into the ld.lld invocation
642
- if (failed (
643
- runTool ((peanoDir / " bin" / " clang" ).string (), flags, verbose))) {
644
- return failure ();
645
646
}
646
647
}
647
648
return success ();
@@ -1149,7 +1150,6 @@ LogicalResult aie2xclbin(
1149
1150
const std::string &xclBinInstanceName, const std::string &amdAIEInstallDir,
1150
1151
const std::optional<std::string> &InputXCLBin,
1151
1152
const std::optional<std::string> &ukernel) {
1152
-
1153
1153
FailureOr<ArrayRef<uint32_t >> maybeNpuInstructions =
1154
1154
getNpuInstructions (deviceOp);
1155
1155
if (failed (maybeNpuInstructions)) {
0 commit comments