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; return CompileError.LLVMError;
} }
//llvm.InitializeAllTargetInfos(); llvm.LLVMInitializeAllTargetInfos();
//llvm.InitializeAllTargets(); llvm.LLVMInitializeAllTargets();
//llvm.InitializeAllTargetMCs(); llvm.LLVMInitializeAllTargetMCs();
//llvm.InitializeAllAsmParsers(); llvm.LLVMInitializeAllAsmParsers();
//llvm.InitializeAllAsmPrinters(); llvm.LLVMInitializeAllAsmPrinters();
var engine: llvm.LLVMExecutionEngineRef = undefined; var engine: llvm.LLVMExecutionEngineRef = undefined;
if (llvm.LLVMCreateExecutionEngineForModule(&engine, mod, &err) != 0) { 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 = try std.mem.dupe(self.allocator, u8, "output.o");
var outpath_cstr = try std.cstr.addNullByte(self.allocator, outpath); 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 desc = llvm.LLVMGetTargetDescription(target);
var features = llvm.LLVMGetTargetMachineFeatureString(machine); var features = llvm.LLVMGetTargetMachineFeatureString(machine);
var triple = llvm.LLVMGetTargetMachineTriple(machine); var triple = llvm.LLVMGetTargetMachineTriple(machine);
@ -125,6 +128,17 @@ pub const Codegen = struct {
std.debug.warn("triple: {}\n", sliceify(triple)); std.debug.warn("triple: {}\n", sliceify(triple));
std.debug.warn("features: {}\n", sliceify(features)); 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( if (llvm.LLVMTargetMachineEmitToFile(
machine, machine,
mod, mod,