Name the RISC-V ISA alongside the ABI - #33
Merged
Merged
Conversation
clang derives neither the ISA nor the calling convention from riscv64-unknown-linux-gnu: it defaults to -march=rv64gc -mabi=lp64d regardless of what buildroot configured. Only -mabi was passed, so the stdlib was built for rv64gc even where the rest of the system was not - the default BR2_riscv_g is IMAFD with no compressed instructions, and a configuration without F/D would still have had those instructions emitted under a soft-float ABI. Pass -march too, from the GCC_TARGET_ARCH make variable buildroot assembles in arch/arch.mk.riscv (BR2_GCC_TARGET_ARCH is left empty on RISC-V), and emit the same set into both flag lists of the SwiftPM toolchain file, where the C side previously carried none of them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
package/swift/swift.mkpassed-mabiforriscv64but never-march. Clang derives neither from theriscv64-unknown-linux-gnutriple: it defaults to-march=rv64gc -mabi=lp64dwhatever buildroot configured.Buildroot's default
BR2_riscv_gis IMAFD with no compressed instructions, so evenswift_riscv64_defconfigdisagreed with therv64gcclang assumed, and a configuration without F/D would still have had those instructions emitted under a soft-float ABI --mabi=lp64does not narrow the ISA, and clang only diagnoses the reverse pairing (-march=rv64ima -mabi=lp64d).The ISA string has no config symbol on RISC-V: buildroot assembles it in
arch/arch.mk.riscvas the make variableGCC_TARGET_ARCH, leavingBR2_GCC_TARGET_ARCHempty.arch.mkis included beforepackage/*/*.mk, so it is in scope in the package, and clang accepts the value verbatim,_zicsr_zifenceisuffix included.The three flags now live in one
SWIFT_RISCV_ABI_FLAGS, each part guarded against an empty value, feeding the stdlib build and both flag lists of the SwiftPM toolchain file. The C side (extra-cc-flags) previously carried none of them, so C targets in a SwiftPM package were compiledrv64gc/lp64dwith relaxation on however the system was configured.Validation
Checked against the toolchain this package builds (Swift 6.3.3 clang/swiftc), which is what motivated the change:
-Xcc -mabi=reaches swiftc's own code generation, not just the clang importer - swift builds its llvm module through clang'sCodeGenerator, so-Xcc -mabi=lp64lands as!"target-abi", !"lp64"in the module flags and-Xcc -march=/-mno-relaxchange thetarget-featuresof every function swiftc emits.+m,+a,+f,+d,+c/lp64d.BR2_GCC_TARGET_ABIis defined for RISC-V inarch/Config.in.riscvand spellslp64/lp64f/lp64dexactly as clang does; it resolves tolp64dfor the shipped defconfig.MIPS soft-float and the PowerPC
-mcpuasymmetry are left as they are.