You are not logged in.

#1 Yesterday 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 Yesterday 10:18:27

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

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 Yesterday 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 Yesterday 16:40:19

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

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 Today 01:00:00

ninetailedtori
Member
Registered: 2025-01-28
Posts: 3
Website

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 (Today 03:07:35)


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

Offline

#6 Today 03:05:22

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

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 Today 10:41:20

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

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

Offline

Board footer

Powered by FluxBB