Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#73025 - [compiler-rt] misplaced include files

Attached to Project: Arch Linux
Opened by Algunenano (Algunenano) - Tuesday, 14 December 2021, 16:47 GMT
Last edited by Evangelos Foutras (foutrelis) - Wednesday, 15 December 2021, 13:45 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

compiler-rt is installing the include files for it's clang version under /usr/include but they are expected to be under /usr/lib/clang/${version}/include.


Currently:
```
$ pacman -Ql compiler-rt | grep include | grep .*/$
compiler-rt /usr/include/
compiler-rt /usr/include/fuzzer/
compiler-rt /usr/include/profile/
compiler-rt /usr/include/sanitizer/
compiler-rt /usr/include/xray/
```

But clang is installing them under `/usr/lib/clang/13.0.0/include/`.


This isn't a big issue since most of the time clang will automatically include /usr/include in the include search path, but it becomes an issue if you use the `--sysroot` option:


$ touch a.cpp
$ clang++ -### a.cpp -o a.o --sysroot=/tmp

```
clang version 13.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang-13" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "a.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/tmp" "-resource-dir" "/usr/lib/clang/13.0.0" "-isysroot" "/tmp" "-internal-isystem" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0" "-internal-isystem" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu" "-internal-isystem" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward" "-internal-isystem" "/usr/lib/clang/13.0.0/include" "-internal-isystem" "/tmp/usr/local/include" "-internal-isystem" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include" "-internal-externc-isystem" "/tmp/include" "-internal-externc-isystem" "/tmp/usr/include" "-fdeprecated-macro" "-fdebug-compilation-dir=/tmp" "-ferror-limit" "19" "-stack-protector" "2" "-fgnuc-version=4.2.1" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/a-ceb9cc.o" "-x" "c++" "a.cpp"
"/usr/bin/ld" "--sysroot=/tmp" "-pie" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "a.o" "Scrt1.o" "crti.o" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/crtbeginS.o" "-L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0" "/tmp/a-ceb9cc.o" "-lstdc++" "-lm" "-lgcc_s" "-lgcc" "-lc" "-lgcc_s" "-lgcc" "/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/crtendS.o" "crtn.o"
```

Note that since we've requested a different sysroot "/tmp/include" is added instead of /usr/include and since clang expects things to be installed under it's directory it's including "-internal-isystem" "/usr/lib/clang/13.0.0/include" which is where it expects things to be installed.

A super hacky (and not recommended) way to fix this is to add a symbolic links manually but the proper fix would be to edit the PKGBUILD to do something like:

```
package() {
cd "$srcdir/$pkgname-$pkgver.src/build"

DESTDIR="$pkgdir" ninja install
install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

mkdir -p "$pkgdir"/usr/lib/clang/$pkgver/{lib,share,include}
mv "$pkgdir"/usr/lib/{linux,clang/$pkgver/lib/}
mv "$pkgdir"/usr/{share/*.txt,lib/clang/$pkgver/share/}
mv "$pkgdir"/usr/{include/*,lib/clang/$pkgver/include/}
}
```
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Wednesday, 15 December 2021, 13:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  compiler-rt 13.0.0-2
Comment by Evangelos Foutras (foutrelis) - Wednesday, 15 December 2021, 01:23 GMT
Setting COMPILER_RT_INSTALL_PATH seems to handle both the headers and the libraries that were being moved in package().

Does compiler-rt 13.0.0-2 work with your --sysroot use case?
Comment by Algunenano (Algunenano) - Wednesday, 15 December 2021, 09:27 GMT
> Does compiler-rt 13.0.0-2 work with your --sysroot use case?

Yes it does. Thanks a lot!

Loading...