mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Bitcode cmd arguments: fix compilation for LLVM < 3.8, and disable for LLVM 3.5.
This commit is contained in:
parent
683d9ecccd
commit
404d483c2a
4 changed files with 33 additions and 11 deletions
|
@ -108,29 +108,41 @@ static std::string getOutputName(bool const sharedLib) {
|
|||
|
||||
namespace {
|
||||
|
||||
#if LDC_LLVM_VER >= 306
|
||||
/// Insert an LLVM bitcode file into the module
|
||||
void insertBitcodeIntoModule(const char *bcFile, llvm::Module &M,
|
||||
llvm::LLVMContext &Context) {
|
||||
Logger::println("*** Linking-in bitcode file %s ***", bcFile);
|
||||
|
||||
llvm::SMDiagnostic Err;
|
||||
std::unique_ptr<llvm::Module> loadedModule =
|
||||
getLazyIRFileModule(bcFile, Err, Context);
|
||||
std::unique_ptr<llvm::Module> loadedModule(
|
||||
getLazyIRFileModule(bcFile, Err, Context));
|
||||
if (!loadedModule) {
|
||||
error(Loc(), "Error when loading LLVM bitcode file: %s", bcFile);
|
||||
return;
|
||||
}
|
||||
|
||||
#if LDC_LLVM_VER >= 308
|
||||
llvm::Linker(M).linkInModule(std::move(loadedModule));
|
||||
#else
|
||||
llvm::Linker(&M).linkInModule(loadedModule.release());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Insert LLVM bitcode files into the module
|
||||
void insertBitcodeFiles(llvm::Module &M, llvm::LLVMContext &Ctx,
|
||||
Array<const char *> &bitcodeFiles) {
|
||||
#if LDC_LLVM_VER >= 306
|
||||
for (const char *fname : bitcodeFiles) {
|
||||
insertBitcodeIntoModule(fname, M, Ctx);
|
||||
}
|
||||
#else
|
||||
if (!bitcodeFiles.empty()) {
|
||||
error(Loc(),
|
||||
"Passing LLVM bitcode files to LDC is not supported for LLVM < 3.6");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -218,9 +230,9 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
|
|||
args.push_back("-Wl,--gc-sections");
|
||||
}
|
||||
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
|
||||
args.push_back("-ldl");
|
||||
args.push_back("-lm");
|
||||
break;
|
||||
args.push_back("-ldl");
|
||||
args.push_back("-lm");
|
||||
break;
|
||||
}
|
||||
args.push_back("-lrt");
|
||||
// fallthrough
|
||||
|
@ -298,8 +310,7 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
|
|||
default:
|
||||
if (global.params.is64bit) {
|
||||
args.push_back("-m64");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
args.push_back("-m32");
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +442,8 @@ int executeMsvcToolAndWait(const std::string &tool,
|
|||
|
||||
auto comspecEnv = getenv("ComSpec");
|
||||
if (!comspecEnv) {
|
||||
warning(Loc(), "'ComSpec' environment variable is not set, assuming 'cmd.exe'.");
|
||||
warning(Loc(),
|
||||
"'ComSpec' environment variable is not set, assuming 'cmd.exe'.");
|
||||
comspecEnv = "cmd.exe";
|
||||
}
|
||||
std::string cmdExecutable = comspecEnv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue