initialize all llvm features befbore emitting

This commit is contained in:
Luna 2019-09-22 18:40:15 -03:00
parent 469625d32a
commit 05c480c364

View file

@ -94,11 +94,11 @@ pub const Codegen = struct {
return CompileError.LLVMError;
}
//llvm.InitializeAllTargetInfos();
//llvm.InitializeAllTargets();
//llvm.InitializeAllTargetMCs();
//llvm.InitializeAllAsmParsers();
//llvm.InitializeAllAsmPrinters();
llvm.LLVMInitializeAllTargetInfos();
llvm.LLVMInitializeAllTargets();
llvm.LLVMInitializeAllTargetMCs();
llvm.LLVMInitializeAllAsmParsers();
llvm.LLVMInitializeAllAsmPrinters();
var engine: llvm.LLVMExecutionEngineRef = undefined;
if (llvm.LLVMCreateExecutionEngineForModule(&engine, mod, &err) != 0) {
@ -117,6 +117,9 @@ pub const Codegen = struct {
var outpath = try std.mem.dupe(self.allocator, u8, "output.o");
var outpath_cstr = try std.cstr.addNullByte(self.allocator, outpath);
//var asmpath = try std.mem.dupe(self.allocator, u8, "output.S");
//var asmpath_cstr = try std.cstr.addNullByte(self.allocator, asmpath);
var desc = llvm.LLVMGetTargetDescription(target);
var features = llvm.LLVMGetTargetMachineFeatureString(machine);
var triple = llvm.LLVMGetTargetMachineTriple(machine);
@ -125,6 +128,17 @@ pub const Codegen = struct {
std.debug.warn("triple: {}\n", sliceify(triple));
std.debug.warn("features: {}\n", sliceify(features));
//if (llvm.LLVMTargetMachineEmitToFile(
// machine,
// mod,
// asmpath_cstr.ptr,
// llvm.LLVMCodeGenFileType.LLVMAssemblyFile,
// &err,
//) != 0) {
// std.debug.warn("failed to emit to assembly file: {}\n", sliceify(err));
// return CompileError.LLVMError;
//}
if (llvm.LLVMTargetMachineEmitToFile(
machine,
mod,