From 14be14f3374cae9cd5aa734af491afdaa9d66aca Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 1 May 2025 19:45:19 +0900 Subject: [PATCH] aot_create_comp_context: disable small data section I observed errors like the following when trying to upgrade our LLVM from 15 to 19. ``` AOT module load failed: resolve symbol .srodata.cst8 failed ``` The concept itself has been available since LLVM 9. I don't know what exactly happened to trigger the use of it. cf. https://reviews.llvm.org/D57493 --- core/iwasm/compilation/aot_llvm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index c1708e3f9..9fa415a6d 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -2617,6 +2617,15 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) goto fail; } +#if LLVM_VERSION_MAJOR >= 9 + /* Disable small data section as our emitter/loader doesn't support it. + * https://reviews.llvm.org/D57493 */ + LLVMAddModuleFlag( + comp_ctx->module, LLVMModuleFlagBehaviorWarning, "SmallDataLimit", + strlen("SmallDataLimit"), + LLVMValueAsMetadata(LLVMConstInt(LLVMInt32Type(), 0, false))); +#endif + #if WASM_ENABLE_DEBUG_AOT != 0 if (!(comp_ctx->debug_builder = LLVMCreateDIBuilder(comp_ctx->module))) { aot_set_last_error("create LLVM Debug Infor builder failed.");