Skip to content

Commit 77eadc0

Browse files
committed
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.
2 parents d09835d + d6f455e commit 77eadc0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/rustllvm/RustWrapper.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ using namespace llvm::sys;
6262

6363
static const char *LLVMRustError;
6464

65+
extern cl::opt<bool> EnableARMEHABI;
66+
6567
extern "C" LLVMMemoryBufferRef
6668
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
6769
LLVMMemoryBufferRef MemBuf = NULL;
@@ -429,10 +431,16 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
429431

430432
LLVMRustInitializeTargets();
431433

432-
int argc = 3;
433-
const char* argv[] = {"rustc", "-arm-enable-ehabi",
434-
"-arm-enable-ehabi-descriptors"};
435-
cl::ParseCommandLineOptions(argc, argv);
434+
// Initializing the command-line options more than once is not
435+
// allowed. So, check if they've already been initialized.
436+
// (This could happen if we're being called from rustpkg, for
437+
// example.)
438+
if (!EnableARMEHABI) {
439+
int argc = 3;
440+
const char* argv[] = {"rustc", "-arm-enable-ehabi",
441+
"-arm-enable-ehabi-descriptors"};
442+
cl::ParseCommandLineOptions(argc, argv);
443+
}
436444

437445
TargetOptions Options;
438446
Options.NoFramePointerElim = true;

0 commit comments

Comments
 (0)