Skip to content

rustllvm: Only initialize command-line arguments once #5755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down