Skip to content

Commit 5910e5c

Browse files
authored
Use --target to pass a triple in wamrc (#4199)
Provide a triple string in the format of <arch>-<vendor>-<os>-<abi> via --target.
1 parent 5bdbba0 commit 5910e5c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

core/iwasm/compilation/aot_llvm.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,10 +2742,23 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27422742
}
27432743
else {
27442744
/* Create LLVM target machine */
2745-
arch = option->target_arch;
2746-
abi = option->target_abi;
2747-
cpu = option->target_cpu;
2748-
features = option->cpu_features;
2745+
if (!option->target_arch || !strstr(option->target_arch, "-")) {
2746+
/* Retrieve the target triple based on user input */
2747+
triple = NULL;
2748+
arch = option->target_arch;
2749+
abi = option->target_abi;
2750+
cpu = option->target_cpu;
2751+
features = option->cpu_features;
2752+
}
2753+
else {
2754+
/* Form a target triple */
2755+
triple = option->target_arch;
2756+
arch = NULL;
2757+
abi = NULL;
2758+
cpu = NULL;
2759+
features = NULL;
2760+
}
2761+
27492762
opt_level = option->opt_level;
27502763
size_level = option->size_level;
27512764

@@ -2986,6 +2999,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
29862999
aot_set_last_error(buf);
29873000
goto fail;
29883001
}
3002+
LOG_VERBOSE("triple: %s => normailized: %s", triple, triple_norm);
29893003
if (!cpu)
29903004
cpu = "";
29913005
}

wamr-compiler/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ print_help()
116116
printf(" Default is host arch, e.g. x86_64\n");
117117
printf(" <sub> = for ex. on arm or thumb: v5, v6m, v7a, v7m, etc.\n");
118118
printf(" Use --target=help to list supported targets\n");
119+
printf(" Or, provide a triple in the format of <arch>-<vendor>-<os>-<abi>.\n");
120+
printf(" By doing this, --target-abi, --cpu, and --cpu-features will be ignored.\n");
121+
printf(" The triple will only be normalized without any further verification.\n");
119122
printf(" --target-abi=<abi> Set the target ABI, e.g. gnu, eabi, gnueabihf, msvc, etc.\n");
120123
printf(" Default is gnu if target isn't riscv64 or riscv32\n");
121124
printf(" For target riscv64 and riscv32, default is lp64d and ilp32d\n");

0 commit comments

Comments
 (0)