summaryrefslogtreecommitdiff
path: root/tools/llvm-ld
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 05:56:58 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 05:56:58 +0000
commitbb3f3d357fb25a39c9b4ca9a5ace047b5efd518c (patch)
treeb8a55b9dcd2d70c50e14fb07b1cf67aabdac113b /tools/llvm-ld
parenta8653f3522c468348470fbebec846a53b7fe9f82 (diff)
downloadllvm-bb3f3d357fb25a39c9b4ca9a5ace047b5efd518c.tar.gz
llvm-bb3f3d357fb25a39c9b4ca9a5ace047b5efd518c.tar.bz2
llvm-bb3f3d357fb25a39c9b4ca9a5ace047b5efd518c.tar.xz
add bitcode support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-ld')
-rw-r--r--tools/llvm-ld/Makefile2
-rw-r--r--tools/llvm-ld/llvm-ld.cpp15
2 files changed, 12 insertions, 5 deletions
diff --git a/tools/llvm-ld/Makefile b/tools/llvm-ld/Makefile
index dc8bffb742..b22035b931 100644
--- a/tools/llvm-ld/Makefile
+++ b/tools/llvm-ld/Makefile
@@ -10,7 +10,7 @@
LEVEL = ../..
TOOLNAME = llvm-ld
-LINK_COMPONENTS = ipo scalaropts linker archive bcreader bcwriter
+LINK_COMPONENTS = ipo scalaropts linker archive bcwriter bitwriter
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp
index 4be651b65d..2aa6d18350 100644
--- a/tools/llvm-ld/llvm-ld.cpp
+++ b/tools/llvm-ld/llvm-ld.cpp
@@ -25,7 +25,7 @@
#include "llvm/System/Program.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Bytecode/Writer.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
@@ -33,6 +33,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/System/Signals.h"
@@ -40,6 +41,8 @@
#include <memory>
using namespace llvm;
+cl::opt<bool> Bitcode("bitcode");
+
// Input/Output Options
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bytecode files>"));
@@ -224,8 +227,12 @@ void GenerateBytecode(Module* M, const std::string& FileName) {
sys::RemoveFileOnSignal(sys::Path(FileName));
// Write it out
- OStream L(Out);
- WriteBytecodeToFile(M, L, !DisableCompression);
+ if (Bitcode) {
+ WriteBitcodeToFile(M, Out);
+ } else {
+ OStream L(Out);
+ WriteBytecodeToFile(M, L, !DisableCompression);
+ }
// Close the bytecode file.
Out.close();
@@ -547,7 +554,7 @@ int main(int argc, char **argv, char **envp) {
args[2] = tmp_output.c_str();
args[3] = 0;
if (0 == sys::Program::ExecuteAndWait(prog, args, 0,0,0,0, &ErrMsg)) {
- if (tmp_output.isBytecodeFile()) {
+ if (tmp_output.isBytecodeFile() || tmp_output.isBitcodeFile()) {
sys::Path target(RealBytecodeOutput);
target.eraseFromDisk();
if (tmp_output.renamePathOnDisk(target, &ErrMsg))