llc编译wasm64文件报warning:'+neon' is not a recognized feature for this target (ignoring feature)
llc.exe -march=wasm64 -filetype=obj patch.ll -o patch.o 报如下warning:
'+neon' is not a recognized feature for this target (ignoring feature) '+neon' is not a recognized feature for this target (ignoring feature)
具体意思是:当前目标wasm64没有 +neon这个特征,忽略这个特征
用文本工具打开patch.ll来查看target triple
; ModuleID = 'H:\svn\MyGame\Intermediate\Build\Android\MyGame\Shipping\link.ll' source_filename = "llvm-link" target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64-none-linux-android21" 。。。 。。。
根本原因
NEON 是 ARM 架构特有的向量指令集(SIMD)扩展,用于加速多媒体和信号处理任务
WebAssembly(WASM) 是一种独立于 CPU 架构的虚拟指令集,其 SIMD 扩展名为 SIMD128,与 NEON 不兼容
WASM 的设计目的是跨平台兼容性,因此它不会直接支持特定 CPU 架构的扩展(如 NEON、AVX 等)
当编译时指定了 -march=wasm64,LLVM 会拒绝任何非 WASM 兼容的特征(如 +neon)
解决方案
方法 1:从IR文件patch.ll中移除 NEON 特征
① 在patch.ll中查找 neon ,搜索到如下内容:
attributes #0 = { nounwind sspstrong uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
"no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind }
attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon"
"unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { noinline nounwind sspstrong uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
"no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neno" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind }
② 注释掉所有与 neon 相关的行
方法2:修正上游编译过程
如果 patch.ll 是通过其他工具(如 clang)生成的,可能是上游编译过程中启用了 NEON
① 使用 clang 生成 IR 时禁用 NEON
clang -S -emit-llvm -mno-neon -O2 input.c -o patch.ll
② 检测所有编译选项,确保没有传递 -mfpu=neon 或类似的 NEON 相关标志
WASM 的 SIMD 替代方案
如果代码需要 SIMD 加速,应改用 WASM 的 simd128 特征
llc.exe -march=wasm64 -mattr=+simd128 -filetype=obj patch.ll -o patch.o

浙公网安备 33010602011771号