[clang] [Clang] Distro: Recognize newer Debian/Ubuntu releases and LinuxMint (PR #126183)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 01:39:12 PST 2025
yumeyao wrote:
I agree with the point _we should not add every new codename to clang::driver::Distro..._, and actually only ancient ubuntu releases `Lucid` `Jaunty` and `Karmic` uses `--hash-style=both` which is the special case here, in other/common cases, we just need to know it it debian/ubuntu (so that we know the debian/ubuntu path convention and maybe not only `cuda` but also other plugins are interested in this).
`-z relro` is the default hardening option used by ubuntu, and we'd better honor it as long as it doesn't cause other troubles or difficulties in the driver code.
It seems the existence of `/etc/debian_version` itself is enough to tell it's a debian or debian-derivative. `-z relro` is the reason we want to tell ubuntu apart from debian further.
LMDE is a special case that is based on debian that comes with a `/etc/lsb-release` and maybe other derivatives do, so we can't use the existence `/etc/lsb-release` to tell it's Ubuntu. The reason I'm listing it here is I don't think LinuxMint/LMDE is maintaining their own toolchain packages so gcc and clang on LMDE behave like on Debian whereas those on LinuxMint behave like on Ubuntu. Deepin is another distro I had investigated into, it has `/etc/lsb-release` as well but in my this patch it's just treated as `DebianUnknown` which happens to be the correct result so I didn't mention it in the code or in this pr.
So my overall suggestion is:
1. Remove redundant codenames, keeping only `Lucid` `Jaunty` and `Karmic` for special case.
2. Use `/etc/lsb-release` `DISTRIB_ID=` to tell if it's Ubuntu.
3. Otherwise use `/etc/debian_version` to tell if it's Debian/Debian-derivative.
4. LinuxMint/LMDE is the only derivative that I had investigated into and found it needing special handles.
and maybe 5. , in the future, as @MaskRay suggested, using a more maintainable way to do so.
https://github.com/llvm/llvm-project/pull/126183
More information about the cfe-commits
mailing list