Fix llvm target vendor-sys-abi not correctly set issue on windows platform (#606)

This commit is contained in:
Wenyong Huang 2021-04-09 17:24:01 +08:00 committed by GitHub
parent 09eb858a02
commit ee97618bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1107,7 +1107,8 @@ static ArchItem valid_archs[] = {
static const char *valid_abis[] = {
"gnu",
"eabi",
"gnueabihf"
"gnueabihf",
"msvc"
};
static void
@ -1335,9 +1336,32 @@ aot_create_comp_context(AOTCompData *comp_data,
if (arch) {
/* Construct target triple: <arch>-<vendor>-<sys>-<abi> */
const char *vendor_sys = "-pc-linux-";
if (!abi)
abi = "gnu";
const char *vendor_sys;
char *default_triple = LLVMGetDefaultTargetTriple();
if (!default_triple) {
aot_set_last_error("llvm get default target triple failed.");
goto fail;
}
if (strstr(default_triple, "windows")) {
vendor_sys = "-pc-windows-";
if (!abi)
abi = "msvc";
}
else if (strstr(default_triple, "win32")) {
vendor_sys = "-pc-win32-";
if (!abi)
abi = "msvc";
}
else {
vendor_sys = "-pc-linux-";
if (!abi)
abi = "gnu";
}
LLVMDisposeMessage(default_triple);
bh_assert(strlen(arch) + strlen(vendor_sys) + strlen(abi) < sizeof(triple_buf));
memcpy(triple_buf, arch, strlen(arch));
memcpy(triple_buf + strlen(arch), vendor_sys, strlen(vendor_sys));