You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nixpkgs packages Mesa (maintained by @vcunat), which has a reasonable operational OpenCL implementation that works at least on AMD GPUs (and whose OpenGL implementation is probably better than AMDs proprietary one). Unfortunately, OpenCL support was explicitly removed from the package in d21b670 by @edolstra, apparently to remove dependency bloat (I guess the reason is that OpenCL needs an entire C compiler frontend at runtime).
I'm a Nix novice, but I've poked around a bit to see how to fix this. First, libclc must be updated to work at all (already made a pull request). Then, reverting (in spirit) d21b670 makes the derivation at least compile the OpenCL bits again, most importantly libMesaOpenCL.so (a whopping 53MiB file!). The mesa package already contains a separate output "drivers" that depends on LLVM, so perhaps the OpenCL bits could be moved there? Alternatively, a new "opencl" output could be made.
There is one more problem. OpenCL specifies a directory /etc/OpenCL/vendors, which should contain text files containing names of ICDs (for example libMesaOpenCL.so). In Nix, this is instead /run/opengl-driver/etc/OpenCL/vendors. I don't understand how to make stuff available there.
It looks like just reverting d21b670 and patching up a few omissions makes something that at least builds libMesaOpenCL.so (in mesa-drivers) and even /run/opengl-driver/etc/OpenCL/vendors/mesa.icd seems to show up correctly. I guess mesa-drivers is already in hardware.opengl.extraPackages. Before I create an opencl output, I'd like to understand whether it's still worthwhile. mesa-drivers already looks pretty large, so is the overhead of carrying libclang all that significant?
Also, I can't yet claim that it actually works. The Mesa OpenCL ICD is picked up just fine, but my device (Vega 64 GPU) is not found. Haven't investigated closely yet. It should be supported, as it works fine in the Mesa that Fedora ships.
In case anyone is curious, these are the changes I made:
On June 10, 2019 11:59:05 PM GMT+03:00, Matthew Bauer ***@***.***> wrote:
Looks good! d21b670 actually predates
multiple outputs, so I suspect it is not a problem anymore?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#62933 (comment)
It does not predate multi-output mesa derivation (I suppose you meant libclang and I understood it wrong); you can have a look at the whole file around the diff. Mesa drivers will be present on any graphical NixOS installation that uses free drivers (basically all except those using binary nvidia), so I can understand this default would better not be too bloated.
This new lib + libclang output might be roughly 100 MB of new stuff in NixOS closures (even though C-like developers will often have some libclang already; *2 with 32-bit included), so from this quick estimate I'd expect it should better be a separate output.
What I'm currently stuck on is libMesaOpenCL.so, which as built contains a reference to /nix/store/i9xsrfn3isrpzdw1xn2rxdfiwg3n230d-mesa-noglu-18.3.4/lib/gallium-pipe.so, but this file has to be located in -drivers (or -opencl) to avoid circular references. The common solution that I find in other packages is to perform a text substitution in the corresponding .la file, but libMesaOpenCL.so is not linked like a normal library, but instead dlopen()ed by the ICD loader (the actual libOpenCL.so, the ocl-icd package in Nix).
I'll see if Mesa has some compilation options I can tweak, but how is this kind of stuff otherwise handled normally?
IIRC we now don't really need to separate .out and .drivers, as package closures should only refer to the libglvnd stubs. We indirect some paths through ${libglvnd.driverLink} as well, and dlopen() cases would be likely suspects for that. (I haven't really thought about these ATM.)
It's fine with me, as it'll certainly simplify my task here (rebuilding now to see whether that's actually the case). I'm too much of a novice to be able to evaluate the impact, however. I assume the split was made for a reason, and as I've been using NixOS for all of two days, I don't really know if those reasons have changed since then.
I managed to move the OpenCL parts into a separate .opencl output, which means the .drivers output size is essentially unchanged compared to without OpenCL. I can make a pull request with my changes to discuss further, but they still depend on first or concurrently bumping libclc (pull request here).
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Activity
abbradar commentedon Jun 10, 2019
We could try making a separate
opencloutput, this sounds good. To add something to/run/opengl-driveradd a package tohardware.opengl.extraPackages.matthewbauer commentedon Jun 10, 2019
Does opencl even need clang to work? This seems surprising if it did. On the other hand, lots of drivers need llvm to work.
athas commentedon Jun 10, 2019
I don't know if it needs the CLI program
clang, but it certainly needs a C frontend, which I assume is built with libclang.athas commentedon Jun 10, 2019
It looks like just reverting d21b670 and patching up a few omissions makes something that at least builds
libMesaOpenCL.so(in mesa-drivers) and even/run/opengl-driver/etc/OpenCL/vendors/mesa.icdseems to show up correctly. I guess mesa-drivers is already inhardware.opengl.extraPackages. Before I create anopencloutput, I'd like to understand whether it's still worthwhile. mesa-drivers already looks pretty large, so is the overhead of carrying libclang all that significant?Also, I can't yet claim that it actually works. The Mesa OpenCL ICD is picked up just fine, but my device (Vega 64 GPU) is not found. Haven't investigated closely yet. It should be supported, as it works fine in the Mesa that Fedora ships.
In case anyone is curious, these are the changes I made:
matthewbauer commentedon Jun 10, 2019
Looks good! d21b670 actually predates multiple outputs, so I suspect it is not a problem anymore?
abbradar commentedon Jun 10, 2019
vcunat commentedon Jun 10, 2019
It does not predate multi-output mesa derivation (I suppose you meant libclang and I understood it wrong); you can have a look at the whole file around the diff. Mesa drivers will be present on any graphical NixOS installation that uses free drivers (basically all except those using binary nvidia), so I can understand this default would better not be too bloated.
This new lib + libclang output might be roughly 100 MB of new stuff in NixOS closures (even though C-like developers will often have some libclang already; *2 with 32-bit included), so from this quick estimate I'd expect it should better be a separate output.
athas commentedon Jun 10, 2019
What I'm currently stuck on is
libMesaOpenCL.so, which as built contains a reference to/nix/store/i9xsrfn3isrpzdw1xn2rxdfiwg3n230d-mesa-noglu-18.3.4/lib/gallium-pipe.so, but this file has to be located in -drivers (or -opencl) to avoid circular references. The common solution that I find in other packages is to perform a text substitution in the corresponding.lafile, butlibMesaOpenCL.sois not linked like a normal library, but insteaddlopen()ed by the ICD loader (the actuallibOpenCL.so, theocl-icdpackage in Nix).I'll see if Mesa has some compilation options I can tweak, but how is this kind of stuff otherwise handled normally?
vcunat commentedon Jun 10, 2019
IIRC we now don't really need to separate
.outand.drivers, as package closures should only refer to the libglvnd stubs. We indirect some paths through${libglvnd.driverLink}as well, anddlopen()cases would be likely suspects for that. (I haven't really thought about these ATM.)athas commentedon Jun 11, 2019
So you're suggesting that we remove
.driversaltogether?vcunat commentedon Jun 11, 2019
I expect it's a possibility, in case it helps dealing with the cycles.
athas commentedon Jun 11, 2019
It's fine with me, as it'll certainly simplify my task here (rebuilding now to see whether that's actually the case). I'm too much of a novice to be able to evaluate the impact, however. I assume the split was made for a reason, and as I've been using NixOS for all of two days, I don't really know if those reasons have changed since then.
9 remaining items
athas commentedon Jul 6, 2019
I managed to move the OpenCL parts into a separate .opencl output, which means the .drivers output size is essentially unchanged compared to without OpenCL. I can make a pull request with my changes to discuss further, but they still depend on first or concurrently bumping libclc (pull request here).
stale commentedon Aug 3, 2020
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.
athas commentedon Aug 3, 2020
Still important to me, but not high priority. I'll look at it again eventually.
stale commentedon Jun 18, 2021
I marked this as stale due to inactivity. → More info
sbruder commentedon Sep 19, 2021
OpenCL support in Mesa was restored in #136402.