From 1185783f6e8c1d65bf1207028dfe6f5163e188b5 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 31 Dec 2018 18:35:49 +0100 Subject: ortho/llvm4-nodebug: normalize the default target on llvm 7.0+ For #724 --- src/ortho/llvm4-nodebug/llvm-cbindings.cpp | 21 +++++++++++++++++++++ src/ortho/llvm4-nodebug/llvm-core.ads | 2 +- src/ortho/llvm4-nodebug/ortho_code_main.adb | 6 +++++- 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src/ortho') diff --git a/src/ortho/llvm4-nodebug/llvm-cbindings.cpp b/src/ortho/llvm4-nodebug/llvm-cbindings.cpp index 4a61ad552..e0ae23198 100644 --- a/src/ortho/llvm4-nodebug/llvm-cbindings.cpp +++ b/src/ortho/llvm4-nodebug/llvm-cbindings.cpp @@ -18,6 +18,9 @@ #include "llvm-c/Target.h" #include "llvm/IR/Type.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/Config/llvm-config.h" +#include "llvm-c/TargetMachine.h" +#include "llvm-c/Core.h" using namespace llvm; @@ -35,4 +38,22 @@ LLVMInitializeNativeAsmPrinter_noinline (void) LLVMInitializeNativeAsmPrinter(); } +char * +LLVMGetDefaultNormalizedTargetTriple(void) +{ + char *triple; + triple = LLVMGetDefaultTargetTriple(); + +#if LLVM_VERSION_MAJOR >= 7 + { + char *res; + res = LLVMNormalizeTargetTriple(triple); + LLVMDisposeMessage(triple); + return res; + } +#else + return triple; +#endif +} + } diff --git a/src/ortho/llvm4-nodebug/llvm-core.ads b/src/ortho/llvm4-nodebug/llvm-core.ads index 29dc157e9..2c46a10b7 100644 --- a/src/ortho/llvm4-nodebug/llvm-core.ads +++ b/src/ortho/llvm4-nodebug/llvm-core.ads @@ -127,7 +127,7 @@ package LLVM.Core is FastCallConv : constant CallConv := 8; ColdCallConv : constant CallConv := 9; X86StdcallCallConv : constant CallConv := 64; - X86FastcallCallConv : constant CallConv := 6; + X86FastcallCallConv : constant CallConv := 65; type IntPredicate is new unsigned; IntEQ : constant IntPredicate := 32; -- equal diff --git a/src/ortho/llvm4-nodebug/ortho_code_main.adb b/src/ortho/llvm4-nodebug/ortho_code_main.adb index 4b36294d4..8e0563407 100644 --- a/src/ortho/llvm4-nodebug/ortho_code_main.adb +++ b/src/ortho/llvm4-nodebug/ortho_code_main.adb @@ -33,6 +33,10 @@ with Interfaces; with Interfaces.C; use Interfaces.C; procedure Ortho_Code_Main is + function GetDefaultNormalizedTargetTriple return Cstring; + pragma Import (C, GetDefaultNormalizedTargetTriple, + "LLVMGetDefaultNormalizedTargetTriple"); + -- Name of the output filename (given by option '-o'). Output : String_Acc := null; @@ -192,7 +196,7 @@ begin Module := ModuleCreateWithName (Module_Name'Address); -- Extract target triple - Triple := GetDefaultTargetTriple; + Triple := GetDefaultNormalizedTargetTriple; SetTarget (Module, Triple); -- Get Target -- cgit v1.2.3