[dcompute] output kernels in object directory (#2215)

* Output kernels in same dir as object files
This commit is contained in:
Nicholas Wilson 2017-07-21 08:05:19 +08:00 committed by GitHub
parent ed19ec601f
commit eb5b17371d

View file

@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "ddmd/dsymbol.h" #include "ddmd/dsymbol.h"
#include "ddmd/module.h"
#include "ddmd/mars.h" #include "ddmd/mars.h"
#include "ddmd/module.h" #include "ddmd/module.h"
#include "ddmd/scope.h" #include "ddmd/scope.h"
@ -44,13 +43,15 @@ void DComputeTarget::emit(Module *m) {
void DComputeTarget::writeModule() { void DComputeTarget::writeModule() {
addMetadata(); addMetadata();
char tmp[32]; std::string filename;
const char *fmt = "kernels_%s%d_%d.%s"; llvm::raw_string_ostream os(filename);
int len = sprintf(tmp, fmt, short_name, tversion, os << "kernels_" << short_name << tversion << '_'
global.params.is64bit ? 64 : 32, binSuffix); << (global.params.is64bit ? 64 : 32) << '.' << binSuffix;
tmp[len] = '\0';
const char *path = FileName::combine(global.params.objdir, os.str().c_str());
setGTargetMachine(); setGTargetMachine();
::writeModule(&_ir->module, tmp); ::writeModule(&_ir->module, path);
delete _ir; delete _ir;
_ir = nullptr; _ir = nullptr;