Index: docs/CommandGuide/llvm-ld.pod =================================================================== --- docs/CommandGuide/llvm-ld.pod (revision 76421) +++ docs/CommandGuide/llvm-ld.pod (working copy) @@ -104,6 +104,10 @@ F for compatibility with B. The output will be written to F. +=item B<-b> F + +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 This option specifies the F of a library to search when resolving symbols Index: tools/llvm-ld/llvm-ld.cpp =================================================================== --- tools/llvm-ld/llvm-ld.cpp (revision 76421) +++ tools/llvm-ld/llvm-ld.cpp (working copy) @@ -49,6 +49,10 @@ cl::desc("Override output filename"), cl::value_desc("filename")); +static cl::opt BitcodeOutputFilename("b", cl::init(""), + cl::desc("Override bitcode output filename"), + cl::value_desc("filename")); + static cl::opt 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,9 +577,16 @@ #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. + std::string RealBitcodeOutput; + if (BitcodeOutputFilename.empty()) { + RealBitcodeOutput = OutputFilename; + if (!LinkAsLibrary) RealBitcodeOutput += ".bc"; + } else { + RealBitcodeOutput = BitcodeOutputFilename; + } - if (!LinkAsLibrary) RealBitcodeOutput += ".bc"; GenerateBitcode(Composite.get(), RealBitcodeOutput); // If we are not linking a library, generate either a native executable