about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-04-06 01:09:48 -0700
committerbors <bors@rust-lang.org>2013-04-06 01:09:48 -0700
commit77eadc0653dac6314ee425ab2502433348c82418 (patch)
tree235c1e1e44fda38e73fe3d9d29974069dad0391e /src/rustllvm/RustWrapper.cpp
parentd09835d2e3c0cb3227baec0ba6f1b23d7c95f474 (diff)
parentd6f455ebca79b6a3d374158a047b1cdd744ebc5e (diff)
downloadrust-77eadc0653dac6314ee425ab2502433348c82418.tar.gz
rust-77eadc0653dac6314ee425ab2502433348c82418.zip
auto merge of #5755 : catamorphism/rust/rustllvm-cmdline, r=brson
r? @brson In my WIP on rustpkg, I was calling driver code that calls
LLVMRustWriteOutputFile more than once. This was making LLVM
unhappy, since that function has code that initializes the
command-line options for LLVM, and I guess you can't do that more
than once. So, check if they've already been initialized.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index c4846c1a62b..bdf13746f3e 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -62,6 +62,8 @@ using namespace llvm::sys;
 
 static const char *LLVMRustError;
 
+extern cl::opt<bool> EnableARMEHABI;
+
 extern "C" LLVMMemoryBufferRef
 LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
   LLVMMemoryBufferRef MemBuf = NULL;
@@ -429,10 +431,16 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
 
   LLVMRustInitializeTargets();
 
-  int argc = 3;
-  const char* argv[] = {"rustc", "-arm-enable-ehabi",
-      "-arm-enable-ehabi-descriptors"};
-  cl::ParseCommandLineOptions(argc, argv);
+  // Initializing the command-line options more than once is not
+  // allowed. So, check if they've already been initialized.
+  // (This could happen if we're being called from rustpkg, for
+  // example.)
+  if (!EnableARMEHABI) {
+    int argc = 3;
+    const char* argv[] = {"rustc", "-arm-enable-ehabi",
+			  "-arm-enable-ehabi-descriptors"};
+    cl::ParseCommandLineOptions(argc, argv);
+  }
 
   TargetOptions Options;
   Options.NoFramePointerElim = true;