Bug 2277782 - Package older clang-formats on newer Fedoras
Summary: Package older clang-formats on newer Fedoras
Keywords:
Status: MODIFIED
Alias: None
Product: Fedora
Classification: Fedora
Component: clang16
Version: 39
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Tulio Magno Quites Machado Filho
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-04-29 14:40 UTC by Alyssa Rosenzweig
Modified: 2024-05-18 01:05 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Alyssa Rosenzweig 2024-04-29 14:40:03 UTC
Fedora packages clang-format, an automatic C/C++ code reformatting tool used by various FOSS projects, including the kernel and Mesa. Some project's CI systems enforce developer use of clang-format to produce a consistent style across the code base.

However, clang-format's output is not stable from version to version, as upstream clang-format tweaks affect the results. Projects therefore pin a single "blessed" version of clang-format that all contributors use.

Other distributions like Debian package simultaneously multiple versions of LLVM (and hence multiple version suffixed clang-formats), so contributors can install whatever the agreed upon version is without needing the whole team to use the same distro. Unfortunately, Fedora only packages a single latest clang version... and as soon as the Fedora LLVM is newer than what the project was using, boom! formatting changes randomly and the developer can no longer contribute.

Therefore, this is a request to package older clang-formats even on newer Fedoras. For my own use case, I need clang-format-16 on F39 (soon F40), since that's the version FEX-Emu pins. But F39 only has clang-format-17, which is incompatible.

Is it reasonable to include the older binaries in the newer Fedoras? If not, what is a reasonable workaround (that doesn't require switching from Fedora to another distro)?

Reproducible: Always

Comment 1 Tulio Magno Quites Machado Filho 2024-04-29 19:16:41 UTC
> Therefore, this is a request to package older clang-formats even on newer Fedoras.

Notice this is already available on Fedora 40, where clang17-tools-extra provides /usr/bin/clang-format-17 and clang-tools-extra provides /usr/bin/clang-format from LLVM 18.1.

> For my own use case, I need clang-format-16 on F39 (soon F40), since that's the version FEX-Emu pins. But F39 only has clang-format-17, which is incompatible.

Could you provide more information on how this version is pinned, please? e.g. are you trying to install an RPM that requires on clang-format-16?

Comment 2 Alyssa Rosenzweig 2024-04-29 20:29:16 UTC
> Notice this is already available on Fedora 40, where clang17-tools-extra provides /usr/bin/clang-format-17 and clang-tools-extra provides /usr/bin/clang-format from LLVM 18.1.

Great to know, thanks!

> Could you provide more information on how this version is pinned, please? e.g. are you trying to install an RPM that requires on clang-format-16?

Due to the unstable nature of clang-format output, an upstream project has to pin a particular version that all its developers use. The RPM doesn't involve clang-format in any way, this is just for upstream devs.

I think projects pick the latest version they can get away with (say, packaged in a suitably old version of Debian), and then stay there as long as they can get away with. It looks like Mesa uses LLVM 15 and FEX uses LLVM 16. Bumping the version requires a flag day "reformat everything" commit which isn't too pleasant, so even if the whole team uses the latest Fedora, it would be inconvenient to have to track upstream LLVM.

Tangential observation, but clang-format output seems to be much more stable for C code (like Mesa) than C++ code (like FEX). I guess that shouldn't be too surprising.

---

In context of clang-format adoption for a third project, I saw someone suggest pulling binaries from https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.4 and skipping the package management. This works as a stopgap but having packaged 'properly' would certainly be nicer! Especially since those bins are 800 MB compressed shipping the entire LLVM toolchain (-:

---

Maybe enforcing clang-format use in CI wasn't such a great idea after all...

Comment 3 Michel Lind 2024-05-01 22:22:27 UTC
(In reply to Tulio Magno Quites Machado Filho from comment #1)
> > Therefore, this is a request to package older clang-formats even on newer Fedoras.
> 
> Notice this is already available on Fedora 40, where clang17-tools-extra
> provides /usr/bin/clang-format-17 and clang-tools-extra provides
> /usr/bin/clang-format from LLVM 18.1.
> 
Tulio, would you accept a PR that rework the clang16 packaging to be more like clang17 (and thus clang16-tools-extra is shipped?

I also have colleagues who need clang16 binaries that are currently unshipped


(In reply to Alyssa Rosenzweig from comment #2)
> Maybe enforcing clang-format use in CI wasn't such a great idea after all...

Having dealth with this on Python projects, yeah, formatting and linting checks are ... very flaky

Comment 4 Tulio Magno Quites Machado Filho 2024-05-02 12:46:54 UTC
(In reply to Michel Lind from comment #3)
> Tulio, would you accept a PR that rework the clang16 packaging to be more
> like clang17 (and thus clang16-tools-extra is shipped?

I believe I can do this. Thanks!
Let me start changing llvm16 first.

> I also have colleagues who need clang16 binaries that are currently unshipped

Interesting.
Michel, could you share which projects are depending on clang16 binaries, please?

Alyssa and Michel, if we distribute the new clang16 binaries on Fedora 40, would it work for you?
Or do you really need it in older versions?
I'd like to avoid changing stable versions.

Comment 5 Tulio Magno Quites Machado Filho 2024-05-07 13:55:02 UTC
I proposed 2 PRs that implement this:
https://src.fedoraproject.org/rpms/llvm16/pull-request/2
https://src.fedoraproject.org/rpms/clang16/pull-request/2

Builds are available in the following copr:
https://copr.fedorainfracloud.org/coprs/tuliom/clang16-tools/

Feedback is welcome.

Comment 6 Fedora Update System 2024-05-18 00:57:08 UTC
FEDORA-2024-9b524890ce (clang16-16.0.6-7.fc41 and llvm16-16.0.6-9.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-9b524890ce

Comment 7 Fedora Update System 2024-05-18 01:05:11 UTC
FEDORA-2024-9b524890ce (clang16-16.0.6-7.fc41 and llvm16-16.0.6-9.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.