-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Polly in Gentoo LLVM Stack #345
Comments
As far as I know the labels
Yup, that's pretty much all this profile does. The only difference is I have a "slimmer" |
All right then, I should be good to go with it as-is. Thanks for the info! Also, many thanks for continuing to package Polly for Gentoo!!! Edit
That explains things. |
Oh another user of my hacky Polly solution :P But jokes aside it's nice to see see people using it. I'm currently testing loading polly via I feel like the cleanest, "most intended" solution would be to just have users add What do you as a user think? |
@xarblu I can't speak for others or for what is the best/ideal solution, but I personally prefer the current method compared to having to handle that in the compiler flags, since the double emerge, however annoying, only occurs once when emerging a new version of the toolchain, so it's a personally acceptable compromise. That said, the following bug ticket might be of more worth as reference on outside opinion and approach to this problem: https://bugs.gentoo.org/715612. Interestingly enough, it also ends up having to use compiler flags to pull Polly in, but using an arguably less elegant flag. |
Yea the patched LLVM will probably stay for now (even if it's not the prettiest solution). Any other way I tried causes seemingly random issues (e.g. with The |
For the record, |
@xarblu Looks like your work has reached at least one more person: gentoo/gentoo#36158
|
And let's hope they finally accept this and we all have polly! |
@StormBytePP Since I don't yet know the etiquette for commenting on Gentoo pull requests, I imagine that this is a safer place to talk. I have a question about the new non-automatically-linked approach: How will this work with rustc? As can be seen a few comments above, I've been able to use Polly with rustc (or at least rustc hasn't complained about it in any way that I could ascertain), but that has been without any |
Current aproach modifies clang-common to include -Xclang... into Note that this is my third try to get this accepted:
|
@StormBytePP Oh, so they outright don't want Polly to just be unconditionally linked. Well, that slightly sucks. I haven't looked into it much before because it was never a concern before, but I'm worried about there possibly being no flags for rustc specifically to pull in the Polly library. I'm not talking about calls to Clang during the building of a primarily Rust project with some C/C++ in it, or when linking — Clang is sort of treated like a linker for some reason — I'm talking about when invoking Polly straight from rustc with no Clang in sight. |
I don't know much about rust, sorry so I can't help. But thanks to this thread I have just force-pushed a change to load it with -fplugin=LLVMPolly.so as @xarblu said above. |
Me too, but I've been silent a lot of time until I decided to improve it and try to get accepted by gentoo ;) With my PR this polly/llvm version mismatches are gone as it is a direct dependency of clang-common See more info at gentoo/gentoo#36158 |
Oh, looks like that's supported: rust-lang/rust#86267 It requires a nightly build of Rust (unless something has changed in the meantime and I haven't been able to find that change in my short time looking into this), but, since I already build the Rust package as nightly so as to have DWARF 5 debugging information as opposed to DWARF 4, looks like I'm all set. |
Yeah, unfortunatelly rust is still lacking for important things like Intel CET which is only available on nightly and it breaks stuff across versions |
To be fair, I also see this as a hack and very much understand why the Gentoo devs don't want this in the main repo.
If there's no rustc native way to load plugins (yet) rustc (or rather the LLVM backend) won't be able to use polly. Clang really is just called for linking as a sort of "wrapper" to pull in some required runtimes.
I also tried playing around with clang-common but as already said above (and in your PR) this somehow caused build issues with LLVM. Another thing to note is that (if I remember correctly) I still think this is the most likely to be accepted by the Gentoo devs though even when considering the downsides unless we figure out a way to build in polly with the official build tools (which is a lot harder than it sounds). (Also I'll be reopening this under a different name since it turned into a mostly polly related discussion) |
I already tried that aproach as I said above, and that was also rejected because using So, yes, I think we can forget to build polly with the official tools because of this hard limitation. To give more details: Not only Polly.a and PollyISL.a are needed, target Polly requires LLVMCore, LLVMAggressive.... and a lot of things that are already present in libLLVM.so but in static flavor. Furthermore, clang with polly linked into tools requires LLVMExtensions.a which in turn requires quite a lot other things. To sum up: |
Could this entire thing be as simple as just following exactly what https://polly.llvm.org/get_started.html says and pass I'm currently trying this and it actually looks somewhat promising (at least If everything works and it doesn't change the default llvm ebuild behaviour (besides adding polly) I'll clean up QA warnings/src_test/etc, push it to this repo for some more testing and then later open a PR to ::gentoo (And if it really is that simple this might also be the way to build llvm with |
I've already followed that path previously and found that it is not so simple, mainly because in polly webpage they don't seem to care about static/dynamic linkage like Gentoo does, their target is it "just works" and if you are not using My advise is, when you finish building llvm, be sure to rebuild clang also because with some configurations, cmake file changes its dependencies towards polly. Keep me informed please ;) Edit: If you are successful I can give you write access to the current PR so we don't make identical PRs if you want to take this option. |
AFAIK that is the default when building polly in-tree according to AddLLVM.cmake If I understand LLVM's cmake logic correctly passing
LLVM is implied as this is an in-tree build. You're basically telling cmake to build LLVM and the specified subprojects |
Yes, just run I might did something wrong and maybe it is not your case but just to be sure and double check |
Initial build finished just now and it's looking good. The libLLVM*.a files installed are the same as the regular llvm ebuild. A quick
Did you edit |
Hmmm... that might be my mistake, yes. Does clang now pass configure stage? I tried your aproach without modifying
when configuring clang. I hope it is only that file and not the other lots of *.a files but... If polly is statically linked to libLLVM.so, is libPollyISL.a really needed now for clang? isn't it a bit dup? |
Sadly, again the LLVMPolly.so requirement to install for clang and other stuff even if it is statically linked to libLLVM.so, that makes no sense. |
Yup was about to send the same error...
This is also what's bothering me. I don't understand why we'd want to link a separate static library if it's already included in libLLVM.so. |
I tried commenting that out just to test and gave me another cmake error elsewhere... this is an indication that is not the correct path. |
It seems it is there for a good reason, just testing manual edit to fix cmake errors I got:
|
The thing is all of these are in libLLVM.so so I still don't get why clang wants any of these explicitly |
Because they are exported as TARGETs, leading to what I said in the beginning as this is what I tried in my previous attempts. It seems that they want to install the archive files for (???) reason, but that seems to be the logic. Hmmm.. this is my guess: By "tools" in "LINK_INTO_TOOLS" I understand it is But I already tried to add |
Does it build if we remove this line from clang's |
Just pushed 132bdff with empty No extraneous Let me know if you encounter any issues I might've missed but so far this looks pretty promising to me. EDIT: Even if this is still somewhat hacky in some places it's a lot better than the previous |
Will test when I find a bit of time as currently I need to repair something on my system (and that takes time). In the meanwhile, I invited you to the PR repository write access to show respect for your original work and if you can help to get this into gentoo in the way they want ;) |
No worries, I'd just still prefer a linked-in approach over a plugin approach because the latter seems to have a lot a caveats.
Thank you, I'll be happy to help where I can. And if I'm not entirely happy with the end result I can still always maintain my own version here :P EDIT: I'll also keep trying to optimise the statically linked approach to remove all the small issues it still has |
Just opened a PR for upstream LLVM to maybe get the patch that makes my new ebuild possible: llvm/llvm-project#88660 Maybe this or something similar can get upstreamed because it really doesn't make sense why you'd need to statically link polly when all other LLVM libraries are in |
Keyworded the new in-tree polly ebuilds and they are now available for 16, 17, 18 (15 was too different and needs a different patch). |
If you allow me, I'd like to recommend you a little (but big) shell script I did for managing Gentoo stage files (and chroots) that might be very useful to test things like this without hosing your system, in case you are interested I have ebuild for it in my overlay: This script is what I use currently to maintain stage3,4,5 and 6 as a backup for a quick Gentoo-system restore on failure but I also use it to test things like this one without dirtying my system (because I had to do a emerge -e world on the weekend as I was having strange compile errors that are gone now). Hope you find it useful, specially for this (if you have a good amount of RAM you can even do the whole process without touching the HDD except for reading the compressed system) |
Sounds interesting but so far |
In my case I have BTRFS subvolumes, being root one of them so to restore it is enough by deleting that subvolume, recreate it and just uncompress the stage6 file to it on a liveCD. But the real benefit is to be able to do any change you want on a chroot without doing so manually and it even has the possibility to not save changes. Also, if you use ccache it can be shared so main system can also benefit from it. Anyway tomorrow I will test your proposed changes for Polly. Edit: I am excited on this because we are already contributing by uncovering hidden bugs that LLVM/clang has, let's hope they are accepted/fixed soon :) |
The clang bug got a PR, did you know what is mentioned about the new pass plugin mechanism with -fpass-plugin=xxxx and the new polly option passing via -fplugin-polly-xxxx (instead the old -mllvm -polly-xxx) ? Can you please test this way with currently working polly and possibly test if polly is being enabled with this new way? |
(Sorry for the wait, I was busy the last couple days) So this seems to work:
(Tested very scientifically with And I'll be honest we probably really should move all this to the plugin... turns out including polly in EDIT: The dirty |
Yes, I've already tried this clang broken with my previous tests, thanks for testing as that new plugin option pass seems much better than the old one. Is there any code example where we can test if polly was enabled in practice by comparing asm? I have the fear that somehow those options might just be ignored |
There is https://github.com/llvm/llvm-project/blob/main/polly/docs/HowToManuallyUseTheIndividualPiecesOfPolly.rst but that's more geared towards |
I'll switch my systems over to use |
So I think this assumption was right, and "tools" means "clang" in this context, and they don't seem to care (as of the buildsystem) to build polly with LLVM without all the static libraries (this is also why the build example found on polly webpage is not valid as it just does not care about LLVM dylib standalone) This leads that the only acceptable solution is to build polly standalone and try to solve the clang bug. |
@xarblu So, after the treeclean of LLVM made me start loading Polly manually, I encountered a somewhat strange issue: Polly does not seem to load when Clang is compiling assembly files ( I'll provide more information once my laptop is done building the packages it's currently building, but I thought it would be a good thing to mention this as soon as possible, especially on the off chance you already know about this and have a workaround for it (aside from disabling Polly for the offending packages). EditLLVM build log: llvm-18.1.8-r4:20240903-000249.txt Test in work/build directory
Side note: Edit twoI should've just scrolled up a bit, but I was stupid and on my phone at 4 in the morning; sorry for the noise 😅 Side note: I wonder if this means that those rustc equivalents of Edit threeRunning that test from above again, but this time with Side note: Between rust-lang/rust#88243 and rust-lang/rust#101997, it doesn't look like there is any remaining support for the legacy pass manager, and rustc doesn't complain about |
I've reported upstreame his bug some time ago and it was supposed to be fixed... can you place a note into it llvm/llvm-project#88173 (comment) ? |
Sorry, I was being dumb and didn't scroll up a bit 😅. As you can see from my third edit, it seems to work fine with the new syntax. |
My only question is: how can we test if the new syntax actually enable polly correctly? Don't ask me why but since this new syntax is not documented (and polly doc is very outdated) I suspect that polly is not enabled silently... |
Speaking of which, the new syntax seems to behave like the old syntax, minus the failure on assembly files. What I'm referring to specifically is how the Polly arguments aren't reported as unused (
Given that I've seen some mention online of Polly not yet being ready to function as a part of LTO, I'm willing to lean towards the former personally, but I too would like something to validate that with. Maybe I'll manage to make or find something in the near future. |
Just as a note: The EDIT: You can check by yourself trying to compile something with |
@StormBytePP The pull request description says that they won't be reported when assembling and linking, but it doesn't mention LTO, so I'm guessing that it's reported by the LLVM recompilation(?) step that happens before the actual linking step. Here's a build log for BASH as an example: bash-5.2_p32-r1:20240903-092314.txt |
Here's a weird thing: |
I've also notice that. It seems that despite polly is a pass plugin it is registered (under the new syntax) as a normal plugin. It also might indicate that -fpass-plugin could be a deprecated option to support old mode |
@StormBytePP I've been looking around online, trying to find a test case for Polly to definitively verify its presence, but the news hasn't been good thus far. Long story short, after metaphorically ramming my head into the wall for a day or two, I discovered https://github.com/llvm/llvm-project/tree/main/polly/docs/experiments/matmul. The script is super outdated and not fully compatible with the new pass manager, so I can't get all of the results and files that are present in that directory, but what I do get is crashes in a Polly pass due to malformed JSCOP files at step nine, which means that Polly does work, at least when invoked with opt instead of Clang, which is good news, I guess. The bad news is that, when compiling that C file with Clang through to the end (but not linking), and using For reference, the Polly arguments that I've used are I'll revisit this later, but probably not for a good while, because it's been a pain trying to navigate through LLVM's (as far as I can tell) outdated documentation and then, on top of that, trying to read LLVM's source code with my beginner-level C++ proficiency. Oh, and it doesn't help that |
Pardon using an issue ticket like a discussion post, but, as Discussions doesn't seem to be enabled for this repository…
As of yesterday, specifically gentoo/gentoo@75d67b1, AMD64 23.0 profiles have been stabilised. Do you have any plans to stabilise your 23.0 Plasma LLVM systemd profile, or does it not matter in practice?
Also, is there anything that I should be aware of coming from the LLVM systemd merged-usr profile present in the main Gentoo repository? Since I'm on a time crunch and your profile seems to just pull in the relevant building blocks from the main Gentoo repository, I'll switch to your profile right away, but I get the feeling that it would still be good to double-check with you, the author, especially since I'm not well-versed in exactly how Gentoo profiles are structured — I've only figured out enough to copy the Plasma desktop bits into
/etc/portage/profile
last summer.The text was updated successfully, but these errors were encountered: