Is there a way to represent arm64e in cfg(...)?

I found that arm64e-apple-* triplet is NOT representable for cfg(...) in config.toml. For example, to config apple platform but NOT arm64e abi/env/arch using

[target.`cfg(all(target_vendor="apple",not(target_arch="arm64e")))`] 

is invalid.
No matter target_{arch,env,abi}="arm64e" is used.

arm64e is an arch/env/abi?

arm64e-apple-darwin means arch arm64e, vendor apple, os darwin; but searching for arm64e definition which saying it's NOT arch but an apple-specific arm64 abi specification with some extension. So it should be treated like gnu/musl abi/env?

How to represent arm64e accurately in cfg(...) target?

the output of rustc --print target-spec-json indicates the arch is aarch64.

arm64e definitely is not an arch in the sense that it does NOT define an ISA, but I think it's ok call it "arch", e.g. in the context of something like "micro-architecture". but anyways, the naming scheme is inconsistent, and LLVM is to blame.

the only accurate specifier is the full target triple. what's the reason you want specifically exclude arm64e-apple-* targets, but not other arm based targets? maybe it's an "xy-problem" after all?

Because arm64e can't be built with rust internal lld linker, I need something like [target.'cfg(all(target_vendor="apple",not(target_arch="arm64e"))] to conditionally select different linker for apple platforms.

you can use the full target triple to set target specific linker config:

# .cargo/config.toml
[target.'cfg(target_vendor="apple")']
linker = "apple-common-linker"

[target.arm64e-apple-darwin]
linker = "arm64e-special-linker"

when both a <triple> and a cfg() expression match a target, the <triple> config has higher priority. this also applies to the target specific configs runner, not just the linker. (note, rustflags is different, all matching rustflags are joined together, instead of replacing one another). see:

1 Like