Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking two modules of different data layouts for android aarch64 lto #4806

Open
calvin2021y opened this issue Dec 21, 2024 · 7 comments
Open

Comments

@calvin2021y
Copy link

calvin2021y commented Dec 21, 2024

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?

@calvin2021y calvin2021y changed the title Linking two modules of different data layouts for android arm64 lto Linking two modules of different data layouts for android aarch64 lto Dec 21, 2024
@kinke
Copy link
Member

kinke commented Dec 23, 2024

Fn32 seems 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.

@calvin2021y
Copy link
Author

Thanks for tips.

I am build with ldc -mtriple=aarch64-unknown-linux-android, will try -mcpu/-mattr options.

@calvin2021y
Copy link
Author

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?

@JohanEngelen
Copy link
Member

hi @kinke

The clang use --march=armv8-a+crypto as 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.

@kinke
Copy link
Member

kinke commented Jan 25, 2025

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.

@kinke
Copy link
Member

kinke commented Jan 25, 2025

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.

@calvin2021y
Copy link
Author

calvin2021y commented Jan 26, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants