Arch Linux

Please read this before reporting a bug:

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!

FS#63227 - [gcc] Add offloading support in GCC

Attached to Project: Arch Linux
Opened by Anonymous (reallybmn) - Thursday, 18 July 2019, 23:46 GMT
Last edited by freswa (frederik) - Saturday, 22 February 2020, 21:24 GMT
Task Type Feature Request
Category Packages: Core
Status Assigned
Assigned To Bartłomiej Piotrowski (Barthalion)
freswa (frederik)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No



GCC can offload C, C++, and Fortran code to an accelerator when using OpenACC or OpenMP where the code to offload is controlled by adding #pragma statements.

How to build gcc for offloading is described in

This feature has been implemented in Debian and Ubuntu:
This task depends upon

Comment by Allan McRae (Allan) - Friday, 19 July 2019, 00:25 GMT
Debian provide a separate gcc package for that. You need a separate package for each offload target...
Comment by Anonymous (reallybmn) - Friday, 19 July 2019, 10:06 GMT
I thought that this could be done in a split PKGBUILD. The "main" gcc package (host compiler) will need to be slightly modified so that it is able to find the offload compilers. I think that adding

--enable-offload-targets=nvptx-none --without-cuda-driver

to configure should be enough for the host.

Notice that all offload compilers are optional and no extra dependency is needed for the main gcc package. GCC will work just as before if no offload compilers are installed.
Comment by Eli Schwartz (eschwartz) - Friday, 19 July 2019, 13:59 GMT
Are we expected to provide these offload compilers ourselves, or would they be AUR packages? Which targets do you want gcc to be compiled to support? Just nvptx? What about intelmic?

If --enable-offload-targets simply tells gcc that it's allowed to look and see if an offload compiler exists then it seems like it would be reasonable to add this even if we don't package the offload compilers themselves.
Comment by Anonymous (reallybmn) - Friday, 19 July 2019, 17:08 GMT
My suggestion would be to provide these offload compilers in the main repository (as in Debian/Ubuntu) If developers think that AUR/community is more suitable, then it's fine too.

On my side, I need only Nvidia PTX targets, but Intel MIC could also be provided using a similar recipe.
Comment by Allan McRae (Allan) - Friday, 19 July 2019, 23:19 GMT
> If --enable-offload-targets simply tells gcc that it's allowed to look and see if an offload compiler exists

You need to provide target names. This is a list that will never satisfy everyone. We should not include it.
Comment by Anonymous (reallybmn) - Saturday, 20 July 2019, 19:51 GMT
With all due respect, I think you concluded too quickly. I do not see why enabling the Nvidia PTX target should be more problematic for Arch than for Debian. And it is not a problem at all for Debian.

Even if we wanted to enable all the possible targets, there is only 3 targets available now (Nvidia PTX targets, AMD HSAIL and MIC). In a foreseeable future, the only addition will be AMD GCN. Even then, it is not a very long list that could potentially trigger a lot of requests.

The main use case is by far Nvidia PTX, this is the reason why Debian enabled only this one.
Comment by Anonymous (reallybmn) - Tuesday, 23 July 2019, 10:30 GMT
Please notice that Fedora also has a gcc-offload-nvptx package
Comment by Bartłomiej Piotrowski (Barthalion) - Tuesday, 01 September 2020, 16:16 GMT
I don't mind if someone submits a patch.
Comment by Anonymous (reallybmn) - Sunday, 20 September 2020, 21:41 GMT
Please find attached PKGBUILD adding offloading support for nvptx. I tried to follow as closely as possible the implementations from Fedora and Debian. Hopefully I did not screw everything up :)
There is a new dependency on nvptx-tools, which provide tools equivalent to binutils for the nvptx target.
Instructions for creating the nvptx-newlib tarball are in comments.
Comment by Ralph Corderoy (RalphCorderoy) - Thursday, 10 February 2022, 10:10 GMT points out gcc is installing the man pages for gcov-dump and lto-dump but not the binaries so things like poking around Gimple with lto-dump aren't possible. It's just been closed because it's thought those commands are built if offload-support is enabled, though producing fat LTO objects and wanting to examine Gimple is nothing to do with off-loading. But if correct, adding offload support would also provide non-offload-support commands.
Comment by bart (edubart) - Friday, 11 March 2022, 21:18 GMT
I also wish ArchLinux had a PKGBUILD for compiling GCC with offloading support for NVPTX like some other distros, does anyone have a PKGBUILD for the current gcc-11?