This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Driver] Handle LoongArch multiarch tuples
ClosedPublic

Authored by xen0n on Jan 26 2023, 10:39 PM.

Details

Summary

This follows v1.00 of the LoongArch Toolchain Conventions,
but notably with this patch
applied (a proper version bump to v2.00 was not done, so it is
indistinguishable from the "original" but now incompatible v1.00
otherwise).

Only loongarch64 is implemented in Linux::getMultiarchTriple
because support for LA32 and ILP32* ABIs are incomplete right now.

The Debian sysroot layout is based on Han Gao's recent porting effort,
specifically the ghcr.io/rabenda/beige:loong64-v23-preview-20230330
container image.

Diff Detail

Event Timeline

xen0n created this revision.Jan 26 2023, 10:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 10:39 PM
xen0n requested review of this revision.Jan 26 2023, 10:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 10:39 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
SixWeining added inline comments.Jan 28 2023, 6:12 PM
clang/lib/Driver/ToolChains/Linux.cpp
41

Missing test. Perhaps add some in clang/test/Driver/linux-ld.c and clang/test/Driver/linux-header-search.cpp? Or postpone this change until loongarch is upstreamed to Debian?

93

Should only check {GNU|GNUF32|GNUF64}?

95

Should only check Triple::Musl?

MaskRay added inline comments.Jan 28 2023, 9:34 PM
clang/lib/Driver/ToolChains/Linux.cpp
116

return (... + ...).str(); if an operand of + is a Twine

xen0n added inline comments.Jan 31 2023, 8:17 PM
clang/lib/Driver/ToolChains/Linux.cpp
41

Thanks, I'll try adding the tests in the next revision.

But given the recent reversal of upstream dpkg support (apparently due to miscommunication) it may be prudent to wait until a consensus is reached Debian-side.

93

While technically only gnu{,sf,f32,f64} are permitted by the LoongArch Toolchain Conventions (with the bare -gnu being somewhat de-facto standard but not officially so), I believe the user's intent to specify a GNU environment still holds even in cases of "errors" like applying "gnuabi64" or "gnueabi" to LoongArch. Same applies for the musl case.

95

Explained above in the GNU case.

116

Thanks, will change in next revision.

SixWeining added inline comments.Mar 16 2023, 1:01 AM
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
66

Better to be f? (Probably most 32-bit hardwares do not support double-float? But I'm not sure about this.)

clang/lib/Driver/ToolChains/Linux.cpp
41

The multiarch tuples have been upstreamed to dpkg. I think we can amend the change and move on now.

xry111 added inline comments.Mar 16 2023, 1:08 AM
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
66

The ISA manual says 64-bit float support is not limited by 32-bit basic ISA support (except the moving instructions accessing 64-bit GPR).

xen0n updated this revision to Diff 510320.Apr 2 2023, 1:37 AM

Rebase and reflect the Toolchain Conventions change.

xen0n marked 5 inline comments as done.Apr 2 2023, 1:45 AM
xen0n added inline comments.
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
66

AFAIK the consensus (even inside Loongson) is that even LA32's unmarked/default ABI is going to have hard F64 available. And yes the ISA manual is consistent with this view too. (IMO LA32 should instead default to soft-float, but if Loongson's commercial roadmap can guarantee hardware FPU availability on all meaningful LA32 models then that would backfire, who knows...)

clang/lib/Driver/ToolChains/Linux.cpp
41

Sorry for the delay in processing this, I've updated the code to reflect the latest spec change. I'll still have to check the unit-test part though.

xen0n updated this revision to Diff 510333.Apr 2 2023, 3:49 AM
xen0n marked an inline comment as done.

Rebase and add tests, also use Twine for concatenating strings

xen0n marked 2 inline comments as done.Apr 2 2023, 3:50 AM
xen0n added inline comments.
clang/lib/Driver/ToolChains/Linux.cpp
41

I've now added tests for the Debian sysroot layout, based on Revy's latest work.

xen0n edited the summary of this revision. (Show Details)Apr 2 2023, 3:52 AM
SixWeining added inline comments.Apr 19 2023, 4:56 AM
clang/test/Driver/linux-header-search.cpp
247

Better to use “loongarch64” when talking about debian? Refer https://wiki.debian.org/Multiarch/Tuples

252

Use LA64 instead of LOONG64?

xen0n added inline comments.Apr 19 2023, 5:14 AM
clang/test/Driver/linux-header-search.cpp
247

It's the dpkg arch identifier and actually the port's official name. I chose it because it's shorter. Do we still want to emphasize the target tuple instead of the distro identity in this case?

252

Similarly I meant to refer to the Debian port name here.

SixWeining accepted this revision.Apr 19 2023, 5:32 AM
SixWeining added inline comments.
clang/test/Driver/linux-header-search.cpp
247

Sorry I didn’t noticed this before. Now it LGTM. Thanks.

This revision is now accepted and ready to land.Apr 19 2023, 5:32 AM
This revision was automatically updated to reflect the committed changes.