Repository navigation
Conversation
…base_for_arch arch_triple_and_datalayout moves to arch::base_for_arch and gains the base feature and ABI columns the run and object paths need (vx-lang#4308). The x86_64 and aarch64 data layout strings are stale copies of LLVM's defaults (missing i128:128 and the p270/p271/p272 + Fn32 entries respectively); both are corrected against LLVM 22.1.8 and pinned by tests.
…riscv64 arm TargetSpec carries the triple, data layout, CPU, features and ABI of the host a --host file declares, and the run and object paths take the target from it instead of llvm-config --host-target and -mcpu=native (vx-lang#4308, vx-lang#4305 P0.1). -mcpu=native stays the native path's alone (vx-lang#4305 decision 3): a declared build, even on the machine running vxc, names no CPU, so it is reproducible. riscv64 answers its arm: the triple riscv64-unknown-linux-gnu, the lp64d data layout, the base features +m,+a,+f,+d,+c always, and -target-abi=lp64d -- without them a weak feature set gives soft-float code that does not link with glibc. emit-llvm writes the triple, the layout and target-features as module attributes; the object path runs llc with the same facts. A declared arch the machine running vxc cannot run is refused with a message naming vx-lang#4309 (cross linking) and vx-lang#4310 (running under an emulator), rather than linking and running as the wrong machine, which is what emit-obj and --run did before this change.
host_arch_of prefers a host the program itself declares over the synthesised native one, and it exists for the triple emit-llvm stamps (vx-lang#342), not for machine code. Building the run and object target from it made --emit-mlir refuse a program that declares a spirv64 device topology, and the backend corpus, which passes no --host, stopped producing its objects (the spirv64 local-device test failed on CI). The run and object paths now take the declaration from --host alone: a file naming a host builds for it, --host default and no --host build for the machine vxc runs on, as they always have. emit-llvm keeps answering host_arch_of, where the derivation belongs.
|
The two CI failures are fixed in ce3880f, and the cause is worth recording.
The fix: the run and object paths build for a declared host only when Re-verified in the LLVM 22 container: the spirv64 test's |
|
working on the integration tests and topology parsing. Will update it soon |
Part of #4308 (P0.1 of #4305), on top of #4430. That PR moved the target-fact table to
arch::base_for_arch; this one makes the run and object paths use it.Because both branches share #4430's commit, the diff against main shows both PRs until #4430 merges. Only the commit
driver: build for a declared host in emit-obj and --run, and add the riscv64 armis new here.What
TargetSpec(src/arch.rs) carries the codegen facts of a declared host: triple, data layout, CPU, features, ABI. The run and object paths take anOption<&TargetSpec>:Someis the machine a--hostfile declares,Noneis--host default.--host defaultkeeps today's path exactly:llvm-config --host-targetand-mcpu=native(decision 3 in [Tracking] riscv64 Linux: a RISC-V host target, and RISC-V cores as a device #4305). This preserves macOS behavior, where the native triple is a darwin one and no table in the compiler should hardcode it.-mcpu=native, even when it names the arch of the machine running vxc -- a declared build names no CPU, so it is reproducible.riscv64-unknown-linux-gnu, the lp64d data layout, base features+m,+a,+f,+d,+calways, and-target-abi=lp64d-- without them a weak feature set gives soft-float code that does not link with glibc.emit-llvmwrites the triple, the layout andtarget-featuresas module attributes;emit-objrunsllcwith the same facts. Anisa:/features:field of the host file has no grammar yet -- its constructor parameter exists (from_declared), the parsing arrives in a follow-up ([Tracking] riscv64 Linux: a RISC-V host target, and RISC-V cores as a device #4305 decision 1).--targetand--sysroot#4309 and driver: run a program built for another machine through an emulator such as QEMU #4310. Before this change,emit-objand--runwith a declaredarch: riscv64exited 0 and produced x86-64 artifacts -- the silent wrong answer observed on #4308.Verification
In the repo's Linux LLVM 22 container (x86_64):
arch: riscv64host gives an object whose ELF header readsMachine: EM_RISCV (0xF3),Flags: 0x5(RVC + double-float ABI, thelp64dthe ABI column asks for), and anemit-llvmmodule carryingllvm.target_triple = "riscv64-unknown-linux-gnu", the lp64d data layout, and"target-features" = "+m,+a,+f,+d,+c";Machine: EM_X86_64-- no regression;cargo check --workspace --all-targets,cargo test -p vxc --lib(1075 tests),cargo clippy --workspace --all-targets --all-features -- -D warnings, andcargo fmt --checkare clean. Unit tests inarch.rscover the riscv64 facts, theisa:/features:merge, and the refusal word for word.Not here yet
isa:/features:grammar of the host file (decision 1's field) and the per-archemit-llvm/emit-objtests oftests/integration_testfollow in this PR.--sysroot, andVX_RUN_WITH-- is driver: link a program for another machine with--targetand--sysroot#4309 and driver: run a program built for another machine through an emulator such as QEMU #4310.