Skip to content

Commit a84d960

Browse files
committed
Use --target to pass a triple in wamrc
Provide a triple string in the format of <arch>-<vendor>-<os>-<abi> via --target.
1 parent ff27687 commit a84d960

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
@@ -2736,10 +2736,23 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27362736
}
27372737
else {
27382738
/* Create LLVM target machine */
2739-
arch = option->target_arch;
2740-
abi = option->target_abi;
2741-
cpu = option->target_cpu;
2742-
features = option->cpu_features;
2739+
if (!strstr(option->target_arch, "-")) {
2740+
/* Get target triple from command line option */
2741+
triple = NULL;
2742+
arch = option->target_arch;
2743+
abi = option->target_abi;
2744+
cpu = option->target_cpu;
2745+
features = option->cpu_features;
2746+
}
2747+
else {
2748+
/* form a target triple */
2749+
triple = option->target_arch;
2750+
arch = NULL;
2751+
abi = NULL;
2752+
cpu = NULL;
2753+
features = NULL;
2754+
}
2755+
27432756
opt_level = option->opt_level;
27442757
size_level = option->size_level;
27452758

@@ -2980,6 +2993,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
29802993
aot_set_last_error(buf);
29812994
goto fail;
29822995
}
2996+
LOG_VERBOSE("triple: %s => normailized: %s", triple, triple_norm);
29832997
if (!cpu)
29842998
cpu = "";
29852999
}

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)