ldc
ldc copied to clipboard
Linking two modules of different data layouts for android aarch64 lto
ndk28 is 'e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128' , ldc v1.40.0 is 'e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32'
try ldc2 --float-abi=soft, --float-abi=hard, --float-abi=softfp, still same problem.
Fn32 seems stand for float32 hard data layouts, generate from ldc2, is there a way to change it?
Fn32seems stand for float32 hard data layouts, generate from ldc2, is there a way to change it?
It stands for function-pointer alignments: https://llvm.org/docs/LangRef.html#data-layout
The data layout string comes from LLVM; not sure if an advanced LLVM cmdline option (see -help-hidden), or playing with -mcpu/-mattr can be used to manipulate this one.
Thanks for tips.
I am build with ldc -mtriple=aarch64-unknown-linux-android, will try -mcpu/-mattr options.
hi @kinke
The clang use --march=armv8-a+crypto as default arguments for arm64.
ldmd2/ldc2 can not support this: Error: invalid target architecture 'armv8-a+crypto', see -version for a list of supported targets.
Maybe this arguments cause the problem?
hi @kinke
The clang use
--march=armv8-a+cryptoas default arguments for arm64.
For LDC, I think this should be --march=aarch64 --mattr=+v8a,+crypto. Use --mcpu=help for more info from the compiler about available options.
This doesn't remove the Fn32 for vanilla clang v19.1.0 on armv8-a: https://cpp.godbolt.org/z/evsP3ac38 (via -Xclang -target-feature -Xclang +v8a -Xclang -target-feature -Xclang +crypto... and neither when adding -target aarch64-linux-android to target Android).
So I guess these 2 attributes don't account for the difference.
Which pre-release NDK 28 are you using? RC2 seems to have been released last week; maybe that is/was just a bug in earlier versions.
Ah - no -Fn32 with clang 18 on godbolt. So looks like it was added in LLVM 19, which prebuilt LDC v1.40 uses, while the upcoming NDK is still based on some pre-19 LLVM. LDC v1.39.0 and v1.40.0-beta4 still use LLVM 18 and should work for you.
It might be worth trying to use an lld 19 linker (not the 'old' NDK one) and see if that still complains about incompatible data layouts.
Thanks for the explain.
I can confirm the v1.40.0-beta4 android aarch64 work with ndk r28-rc2.
--mattr=+v8a,+crypto also pass the compile.