Merge branch 'master' into merge-2.068

This commit is contained in:
Martin 2015-10-02 15:38:02 +02:00
commit 8ee0e250c7
23 changed files with 246 additions and 172 deletions

View file

@ -23,6 +23,7 @@
#include "driver/cl_options.h"
#include "driver/codegenerator.h"
#include "driver/configfile.h"
#include "driver/exe_path.h"
#include "driver/ldc-version.h"
#include "driver/linker.h"
#include "driver/targetmachine.h"
@ -103,18 +104,6 @@ static cl::opt<bool> linkDebugLib("link-debuglib",
cl::desc("Link with libraries specified in -debuglib, not -defaultlib"),
cl::ZeroOrMore);
#if LDC_LLVM_VER < 304
namespace llvm {
namespace sys {
namespace fs {
static std::string getMainExecutable(const char *argv0, void *MainExecAddr) {
return llvm::sys::Path::GetMainExecutable(argv0, MainExecAddr).str();
}
}
}
}
#endif
void printVersion() {
printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version);
printf(" based on DMD %s and LLVM %s\n", global.version, global.llvm_version);
@ -263,16 +252,7 @@ int main(int argc, char **argv);
///
/// Returns a list of source file names.
static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &helpOnly) {
#if _WIN32
char buf[MAX_PATH];
GetModuleFileName(NULL, buf, MAX_PATH);
const char* argv0 = &buf[0];
// FIXME: We cannot set params.argv0 here, as we would escape a stack
// reference, but it is unused anyway.
global.params.argv0 = NULL;
#else
const char* argv0 = global.params.argv0 = argv[0];
#endif
global.params.argv0 = exe_path::getExePath().data();
// Set some default values.
global.params.useSwitchError = 1;
@ -292,7 +272,7 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
ConfigFile cfg_file;
// just ignore errors for now, they are still printed
cfg_file.read(argv0, (void*)main, "ldc2.conf");
cfg_file.read("ldc2.conf");
final_args.insert(final_args.end(), cfg_file.switches_begin(), cfg_file.switches_end());
final_args.insert(final_args.end(), &argv[1], &argv[argc]);
@ -316,7 +296,7 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
// - version number
// - used config file
if (global.params.verbose) {
fprintf(global.stdmsg, "binary %s\n", llvm::sys::fs::getMainExecutable(argv0, (void*)main).c_str());
fprintf(global.stdmsg, "binary %s\n", exe_path::getExePath().c_str());
fprintf(global.stdmsg, "version %s (DMD %s, LLVM %s)\n", global.ldc_version, global.version, global.llvm_version);
const std::string& path = cfg_file.path();
if (!path.empty())
@ -940,6 +920,8 @@ int main(int argc, char **argv)
// stack trace on signals
llvm::sys::PrintStackTraceOnErrorSignal();
exe_path::initialize(argv[0], reinterpret_cast<void*>(main));
global.init();
global.version = ldc::dmd_version;
global.ldc_version = ldc::ldc_version;