[llvm] 573ff0f - [AIX][LTO] Teaching lto-aix-system-assembler Relative Path and Tilde Resolution

Qiongsi Wu via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 12:35:33 PST 2022


Author: Qiongsi Wu
Date: 2022-11-25T15:34:25-05:00
New Revision: 573ff0f7d2b092b08aafb749efa6f9b90fea3e1b

URL: https://github.com/llvm/llvm-project/commit/573ff0f7d2b092b08aafb749efa6f9b90fea3e1b
DIFF: https://github.com/llvm/llvm-project/commit/573ff0f7d2b092b08aafb749efa6f9b90fea3e1b.diff

LOG: [AIX][LTO] Teaching lto-aix-system-assembler Relative Path and Tilde Resolution

The `lto-aix-system-assembler` currently only understands absolute path. This patch teaches the option so that it can resolve relative paths and tilde.

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D138729

Added: 
    

Modified: 
    llvm/lib/LTO/LTOCodeGenerator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 3abfef1fd69f2..c9ecc6df036c2 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -118,7 +118,7 @@ cl::opt<std::string> LTOStatsFile(
 
 cl::opt<std::string> AIXSystemAssemblerPath(
     "lto-aix-system-assembler",
-    cl::desc("Absolute path to the system assembler, picked up on AIX only"),
+    cl::desc("Path to a system assembler, picked up on AIX only"),
     cl::value_desc("path"));
 }
 
@@ -253,9 +253,15 @@ bool LTOCodeGenerator::runAIXSystemAssembler(SmallString<128> &AssemblyFile) {
          "Runing AIX system assembler when integrated assembler is available!");
 
   // Set the system assembler path.
-  std::string AssemblerPath(llvm::AIXSystemAssemblerPath.empty()
-                                ? "/usr/bin/as"
-                                : llvm::AIXSystemAssemblerPath.c_str());
+  SmallString<256> AssemblerPath("/usr/bin/as");
+  if (!llvm::AIXSystemAssemblerPath.empty()) {
+    if (llvm::sys::fs::real_path(llvm::AIXSystemAssemblerPath, AssemblerPath,
+                                 /* expand_tilde */ true)) {
+      emitError(
+          "Cannot find the assembler specified by lto-aix-system-assembler");
+      return false;
+    }
+  }
 
   // Prepare inputs for the assember.
   const auto &Triple = TargetMach->getTargetTriple();


        


More information about the llvm-commits mailing list