Use PathV1 for creating temporary files on pre-3.4 LLVM.

GitHub: Fixes #471.
This commit is contained in:
David Nadlinger 2013-09-15 16:47:16 +02:00
parent dd2a2a6cf9
commit 50f145640f

View file

@ -20,6 +20,9 @@
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Program.h" #include "llvm/Support/Program.h"
#if LDC_LLVM_VER < 304
#include "llvm/Support/PathV1.h"
#endif
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#if LDC_LLVM_VER >= 303 #if LDC_LLVM_VER >= 303
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
@ -155,21 +158,19 @@ void writeModule(llvm::Module* m, std::string filename)
// write native assembly // write native assembly
if (global.params.output_s || assembleExternally) { if (global.params.output_s || assembleExternally) {
#if LDC_LLVM_VER >= 304
LLPath spath = LLPath(filename); LLPath spath = LLPath(filename);
llvm::sys::path::replace_extension(spath, global.s_ext); llvm::sys::path::replace_extension(spath, global.s_ext);
if (!global.params.output_s) if (!global.params.output_s)
{
#if LDC_LLVM_VER >= 304
llvm::sys::fs::createUniqueFile("ldc-%%%%%%%.s", spath); llvm::sys::fs::createUniqueFile("ldc-%%%%%%%.s", spath);
#else #else
int Dummy; // Pre-3.4 versions don't have a createUniqueFile overload that does
llvm::sys::fs::unique_file("ldc-%%%%%%%.s", Dummy, spath, true // not open the file.
#if LDC_LLVM_VER >= 302 llvm::sys::Path spath(filename);
, 0 spath.eraseSuffix();
spath.appendSuffix(std::string(global.s_ext));
spath.createTemporaryFileOnDisk();
#endif #endif
);
#endif
}
Logger::println("Writing native asm to: %s\n", spath.c_str()); Logger::println("Writing native asm to: %s\n", spath.c_str());
std::string err; std::string err;