[llvm-commits] [llvm] r76768 - in /llvm/trunk: docs/CommandGuide/llvm-ld.pod tools/llvm-ld/llvm-ld.cpp
Sanjiv Gupta
sanjiv.gupta at microchip.com
Wed Jul 22 11:41:45 PDT 2009
Author: sgupta
Date: Wed Jul 22 13:41:45 2009
New Revision: 76768
URL: http://llvm.org/viewvc/llvm-project?rev=76768&view=rev
Log:
Added -b option to override the default bitcode output file name.
Modified:
llvm/trunk/docs/CommandGuide/llvm-ld.pod
llvm/trunk/tools/llvm-ld/llvm-ld.cpp
Modified: llvm/trunk/docs/CommandGuide/llvm-ld.pod
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-ld.pod?rev=76768&r1=76767&r2=76768&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/llvm-ld.pod (original)
+++ llvm/trunk/docs/CommandGuide/llvm-ld.pod Wed Jul 22 13:41:45 2009
@@ -104,6 +104,12 @@
F<a.out> for compatibility with B<ld>. The output will be written to
F<filename>.
+=item B<-b> F<filename>
+
+This option can be used to override the output bitcode file name. By default,
+the name of the bitcode output file is one more ".bc" suffix added to the name
+specified by B<-o filename> option.
+
=item B<-l>F<name>
This option specifies the F<name> of a library to search when resolving symbols
Modified: llvm/trunk/tools/llvm-ld/llvm-ld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/llvm-ld.cpp?rev=76768&r1=76767&r2=76768&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ld/llvm-ld.cpp (original)
+++ llvm/trunk/tools/llvm-ld/llvm-ld.cpp Wed Jul 22 13:41:45 2009
@@ -49,6 +49,10 @@
cl::desc("Override output filename"),
cl::value_desc("filename"));
+static cl::opt<std::string> BitcodeOutputFilename("b", cl::init(""),
+ cl::desc("Override bitcode output filename"),
+ cl::value_desc("filename"));
+
static cl::opt<bool> Verbose("v",
cl::desc("Print information about actions taken"));
@@ -458,7 +462,7 @@
if (!FullLibraryPath.isEmpty())
Out2 << " -load=" << FullLibraryPath.toString() << " \\\n";
}
- Out2 << " $0.bc ${1+\"$@\"}\n";
+ Out2 << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n";
Out2.close();
}
@@ -573,10 +577,14 @@
#endif
// Generate the bitcode for the optimized module.
- std::string RealBitcodeOutput = OutputFilename;
+ // If -b wasn't specified, use the name specified
+ // with -o to construct BitcodeOutputFilename.
+ if (BitcodeOutputFilename.empty()) {
+ BitcodeOutputFilename = OutputFilename;
+ if (!LinkAsLibrary) BitcodeOutputFilename += ".bc";
+ }
- if (!LinkAsLibrary) RealBitcodeOutput += ".bc";
- GenerateBitcode(Composite.get(), RealBitcodeOutput);
+ GenerateBitcode(Composite.get(), BitcodeOutputFilename);
// If we are not linking a library, generate either a native executable
// or a JIT shell script, depending upon what the user wants.
@@ -601,12 +609,12 @@
const char* args[4];
args[0] = I->c_str();
- args[1] = RealBitcodeOutput.c_str();
+ args[1] = BitcodeOutputFilename.c_str();
args[2] = tmp_output.c_str();
args[3] = 0;
if (0 == sys::Program::ExecuteAndWait(prog, args, 0,0,0,0, &ErrMsg)) {
if (tmp_output.isBitcodeFile() || tmp_output.isBitcodeFile()) {
- sys::Path target(RealBitcodeOutput);
+ sys::Path target(BitcodeOutputFilename);
target.eraseFromDisk();
if (tmp_output.renamePathOnDisk(target, &ErrMsg))
PrintAndExit(ErrMsg, 2);
@@ -642,7 +650,7 @@
// Generate an assembly language file for the bitcode.
std::string ErrMsg;
- if (0 != GenerateAssembly(AssemblyFile.toString(), RealBitcodeOutput,
+ if (0 != GenerateAssembly(AssemblyFile.toString(), BitcodeOutputFilename,
llc, ErrMsg))
PrintAndExit(ErrMsg);
@@ -672,7 +680,7 @@
// Generate an assembly language file for the bitcode.
std::string ErrMsg;
if (0 != GenerateCFile(
- CFile.toString(), RealBitcodeOutput, llc, ErrMsg))
+ CFile.toString(), BitcodeOutputFilename, llc, ErrMsg))
PrintAndExit(ErrMsg);
if (0 != GenerateNative(OutputFilename, CFile.toString(),
@@ -692,10 +700,10 @@
PrintAndExit(ErrMsg);
// Make the bitcode file readable and directly executable in LLEE as well
- if (sys::Path(RealBitcodeOutput).makeExecutableOnDisk(&ErrMsg))
+ if (sys::Path(BitcodeOutputFilename).makeExecutableOnDisk(&ErrMsg))
PrintAndExit(ErrMsg);
- if (sys::Path(RealBitcodeOutput).makeReadableOnDisk(&ErrMsg))
+ if (sys::Path(BitcodeOutputFilename).makeReadableOnDisk(&ErrMsg))
PrintAndExit(ErrMsg);
}
} catch (const std::string& msg) {
More information about the llvm-commits
mailing list