Add eabihf ABI support and set vendor-sys of bare-metal targets (#2745)

Set the vendor-sys of bare-metal targets to "-unknown-none-",
and currently only add "thumbxxx" to the bare-metal target list.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2023-11-13 18:01:15 +08:00 committed by GitHub
parent 625c95816d
commit e4353b4e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1915,6 +1915,7 @@ static ArchItem valid_archs[] = {
static const char *valid_abis[] = { static const char *valid_abis[] = {
"gnu", "gnu",
"eabi", "eabi",
"eabihf",
"gnueabihf", "gnueabihf",
"msvc", "msvc",
"ilp32", "ilp32",
@ -1992,6 +1993,18 @@ get_target_arch_from_triple(const char *triple, char *arch_buf, uint32 buf_size)
bh_assert(*triple == '-' || *triple == '\0'); bh_assert(*triple == '-' || *triple == '\0');
} }
static bool
is_baremetal_target(const char *target, const char *cpu, const char *abi)
{
/* TODO: support more baremetal targets */
if (target) {
/* If target is thumbxxx, then it is baremetal target */
if (!strncmp(target, "thumb", strlen("thumb")))
return true;
}
return false;
}
void void
aot_handle_llvm_errmsg(const char *string, LLVMErrorRef err) aot_handle_llvm_errmsg(const char *string, LLVMErrorRef err)
{ {
@ -2214,7 +2227,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
char *triple_norm_new = NULL, *cpu_new = NULL; char *triple_norm_new = NULL, *cpu_new = NULL;
char *err = NULL, *fp_round = "round.tonearest", char *err = NULL, *fp_round = "round.tonearest",
*fp_exce = "fpexcept.strict"; *fp_exce = "fpexcept.strict";
char triple_buf[32] = { 0 }, features_buf[128] = { 0 }; char triple_buf[128] = { 0 }, features_buf[128] = { 0 };
uint32 opt_level, size_level, i; uint32 opt_level, size_level, i;
LLVMCodeModel code_model; LLVMCodeModel code_model;
LLVMTargetDataRef target_data_ref; LLVMTargetDataRef target_data_ref;
@ -2510,6 +2523,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
* for Windows/MacOS under Linux host, or generating AOT file for * for Windows/MacOS under Linux host, or generating AOT file for
* Linux/MacOS under Windows host. * Linux/MacOS under Windows host.
*/ */
if (!strcmp(abi, "msvc")) { if (!strcmp(abi, "msvc")) {
if (!strcmp(arch1, "i386")) if (!strcmp(arch1, "i386"))
vendor_sys = "-pc-win32-"; vendor_sys = "-pc-win32-";
@ -2517,7 +2531,10 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
vendor_sys = "-pc-windows-"; vendor_sys = "-pc-windows-";
} }
else { else {
vendor_sys = "-pc-linux-"; if (is_baremetal_target(arch, cpu, abi))
vendor_sys = "-unknown-none-";
else
vendor_sys = "-pc-linux-";
} }
bh_assert(strlen(arch1) + strlen(vendor_sys) + strlen(abi) bh_assert(strlen(arch1) + strlen(vendor_sys) + strlen(abi)
@ -2553,6 +2570,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (!abi) if (!abi)
abi = "msvc"; abi = "msvc";
} }
else if (is_baremetal_target(arch, cpu, abi)) {
vendor_sys = "-unknown-none-";
}
else { else {
vendor_sys = "-pc-linux-"; vendor_sys = "-pc-linux-";
if (!abi) if (!abi)