[PATCH] D134454: [Driver][Distro] Fix ArchLinux triplet and sysroot detection
Adrian Ratiu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 02:46:41 PDT 2022
10ne1 added inline comments.
================
Comment at: clang/lib/Driver/Distro.cpp:213
+ // that the Linux OS and distro are properly detected in this cases.
+ llvm::Triple NormTargetOrHost = llvm::Triple(Twine(TargetOrHost.normalize()));
+
----------------
nickdesaulniers wrote:
> Twine has an intentionally non-explicit constructor that accepts a StringRef, which also has an intentionally non-explicit constructor that accepts a std::string, which is what Triple::normalize() returns.
>
> Let's be consistent in the explicit construction of these temporary objects by removing the explicit call to the Twine constructor.
>
> Also, why is it necessary to normalize the Triple? Can you give an example of the "bad" input and how this "fixes" it?
I do not claim to fully understand the LLVM toolchain & triplet auto-detection code, so maybe this normalization is more of a workaround than a real fix. Maybe we need to do the normalization earlier? I do not know, any suggestions are welcome.
The behavior I'm seeing is:
If TargetOrHost triplet is "aarch64-linux-gnu" then TargetOrHost.isOSLinux() == false and GetDistro returns Distro::UnknownDistro which causes failures like the following when building the kernel tools:
```
make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- bpf
DESCEND bpf
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ OFF ]
DESCEND bpftool
Auto-detecting system features:
... libbfd: [ on ]
... disassembler-four-args: [ on ]
... zlib: [ OFF ]
... libcap: [ OFF ]
... clang-bpf-co-re: [ on ]
make[2]: *** No rule to make target '/home/adi/workspace/cola/GOO0021/chromiumos/src/third_party/kernel/v5.15/tools/include/linux/math.h', needed by 'btf.o'. Stop.
make[1]: *** [Makefile:110: bpftool] Error 2
make: *** [Makefile:69: bpf] Error 2
```
If we do the triple normalization step before detecting the distro, the triplet becomes `aarch64-unknown-linux-gnu` which results in TargetOrHost.isOSLinux() == true, the distro is properly detected, then the system features are ON and the build works.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134454/new/
https://reviews.llvm.org/D134454
More information about the cfe-commits
mailing list