You are not logged in.

#1 2026-06-22 03:26:21

KassieTeller
Member
Registered: 2023-07-29
Posts: 4

polly + clang unusable in arch?

(I had no idea what was an appropriate topic for this to go under, this seemed like the best option) just today I tried using polly with clang to compile something. I tried testing it first on a basic C file with only a main function and print, trying to compile it via

clang -O3 -mllvm -polly file.c

only returned an error saying llvm option parser couldn't recognize -polly. the llvm wiki says llvm and its tools have to all be built in the same revision in order for clang and polly to work together, I'd assume this was the case since llvm and its tools all come from one PKGBUILD in arch repos. am I doing something wrong or is this a known issue?

Offline

#2 2026-06-22 10:18:27

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 674

Re: polly + clang unusable in arch?

https://polly.llvm.org/docs/UsingPollyWithClang.html:

Polly is available through clang, opt, and bugpoint, if Polly was checked out into tools/polly before compilation.

For Arch's llvm or clang packages compilation it wasn't. At least I didn't find any mention of polly in llvm's or clang's PKGBUILDs.

Offline

#3 2026-06-22 16:16:27

KassieTeller
Member
Registered: 2023-07-29
Posts: 4

Re: polly + clang unusable in arch?

is there a reason why Polly is even packaged in the arch repos if it's not even compiled with clang and llvm? this seems very counterintuitive

Offline

#4 2026-06-22 16:40:19

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 674

Re: polly + clang unusable in arch?

https://bugs.archlinux.org/task/66226#comments

Since it's packaged separately, clang needs "-Xclang -load -Xclang LLVMPolly.so" in addition to "-mllvm -polly"

Disclaimer: I don't know if it really works.

Offline

#5 2026-06-23 01:00:00

ninetailedtori
Member
Registered: 2025-01-28
Posts: 4

Re: polly + clang unusable in arch?

dimich wrote:

https://polly.llvm.org/docs/UsingPollyWithClang.html:

Polly is available through clang, opt, and bugpoint, if Polly was checked out into tools/polly before compilation.

For Arch's llvm or clang packages compilation it wasn't. At least I didn't find any mention of polly in llvm's or clang's PKGBUILDs.

This is incorrect - llvm upstream, includes all projects within their source code, within one monorepo, and the source-tarballs are ALSO, since automatically generated from the entire repo, by this same rule, and contain polly already. But why they don't BUILD polly, is because they package it separately, and not under the same pkgbase (which is a little weird imo, but idk what the reason really is? prolly a very intelligent one i just can't think of rn xD), but it *should* still build WITH polly (being a should, not that I know for sure!).

but clang works fine for me with polly, and I'm running rather harsh settings too. only things it doesn't work well with are:

- cgo (go's c compiler): because it tries to pass the mllvm polly flags to the assembler, but doesn't understand the nuance of needing to then having to pass the polly lib to the assembler as well
- rust: requires a completely different mechanism, see https://github.com/rust-lang/rust/pull/78566 for more info. Oddly, this method DOESN'T work if you pass the flags to rust through a .cargo/config.toml rustflags config option, BUT it does work if you pass it as a env var! *shrugs in confused defeat*

Here's my flags if you're curious what worked for me though!

PLUGIN_CFLAGS="-fpass-plugin=LLVMPolly.so -fplugin=LLVMPolly.so"
POLLY_CFLAGS="-mllvm -polly \
    -mllvm -polly-parallel \
    -mllvm -polly-num-threads=32 \
    -mllvm -polly-omp-backend=LLVM \
    -mllvm -polly-scheduling=dynamic \
    -mllvm -polly-scheduling-chunksize=1 \
    -mllvm -polly-tiling=true \
    -mllvm -polly-tile-sizes=32,32 \
    -mllvm -polly-vectorizer=stripmine \
    -mllvm -polly-detect-reductions=true \
    -mllvm -polly-position=before-vectorizer \
    -mllvm -polly-process-unprofitable \
    -mllvm -polly-use-llvm-names"

Last edited by ninetailedtori (2026-06-23 03:07:35)


» Like an autumn leaf, her fading golden grace as the tree withered. « — NinetailedTori

Offline

#6 2026-06-23 03:05:22

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 674

Re: polly + clang unusable in arch?

ninetailedtori wrote:

This is incorrect - llvm upstream, includes all projects within their source code, within one monorepo, and the source-tarballs are ALSO, since automatically generated from the entire repo, by this same rule, and contain polly already.

Yes, llvm-project tarball contains llvm, clang, polly etc. But neither clang or llvm package build polly and provide LLVMPolly.so. User has to provide flags to load the shared library provided by polly package explicitly. What's incorrect?

dimich wrote:

Since it's packaged separately, clang needs "-Xclang -load -Xclang LLVMPolly.so" in addition to "-mllvm -polly"

Disclaimer: I don't know if it really works.

@KassieTeller, I just checked,

$ clang -O3 -mllvm -polly -Xclang -load -Xclang LLVMPolly.so file.c

doesn't fail.

Offline

#7 2026-06-23 10:41:20

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,191

Re: polly + clang unusable in arch?

$ pacman -F LLVMPolly.so
extra/polly 22.1.6-1
    usr/lib/LLVMPolly.so
$ 

Clang has its own .so files also in /usr/lib , maybe it expects polly to be somewhere else.

Does LD_PRELOAD=/usr/lib/LLVMPolly.so clang -O3 -mllvm -polly file.c work ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Online

#8 2026-06-24 22:30:50

ninetailedtori
Member
Registered: 2025-01-28
Posts: 4

Re: polly + clang unusable in arch?

dimich wrote:
ninetailedtori wrote:

This is incorrect - llvm upstream, includes all projects within their source code, within one monorepo, and the source-tarballs are ALSO, since automatically generated from the entire repo, by this same rule, and contain polly already.

Yes, llvm-project tarball contains llvm, clang, polly etc. But neither clang or llvm package build polly and provide LLVMPolly.so. User has to provide flags to load the shared library provided by polly package explicitly. What's incorrect?

dimich wrote:

Since it's packaged separately, clang needs "-Xclang -load -Xclang LLVMPolly.so" in addition to "-mllvm -polly"

Disclaimer: I don't know if it really works.

@KassieTeller, I just checked,

$ clang -O3 -mllvm -polly -Xclang -load -Xclang LLVMPolly.so file.c

doesn't fail.

Oh, no I know the flags do work, it's more that I was like, the package was built with polly in the correct location, which means that polly opts should be recognised by clang for that, was my reasoning. manually loading them will work too though, and more explicit just in case :3 Curious what the actual issue is that's causing them to struggle with recognising it on @Lone_Wolf's system though.

And yes, I'm still very curious why they haven't just unified it to be packaged under a single pkgbase, but I dunno, might open a ticket on the gitlab and ask :3

Last edited by ninetailedtori (2026-06-24 22:32:08)


» Like an autumn leaf, her fading golden grace as the tree withered. « — NinetailedTori

Offline

#9 2026-06-25 12:32:12

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 674

Re: polly + clang unusable in arch?

Interesting observation:
In Ubuntu 24.04.4 LTS LLVMPolly.so is installed by separate llvm-18-linker-tools package as /usr/lib/llvm-18/lib/LLVMPolly.so. This package is a depenency for both llvm and clang. It also provides /usr/lib/llvm-18/lib/LLVMgold.so.
In Arch /usr/lib/LLVMgold.so is provided by llvm-libs package together with /usr/lib/bfd-plugins/LLVMgold.so symlink.

In Ubuntu "clang -O3 -mllvm -polly file.c" doesn't fail. But strace with --follow-forks doesn't show it ever access anything related to "polly" (case insensitive).
Edit: linking multiple object files it shows:

$ clang -O3 -mllvm -polly -o hello hello.o liba.o
clang: warning: argument unused during compilation: '-mllvm -polly' [-Wunused-command-line-argument]

Last edited by dimich (2026-06-25 12:39:56)

Offline

Board footer

Powered by FluxBB