Hi! On Mon, 2024-03-04 at 10:59:36 -0700, Cordell Bloor wrote: > Package: dpkg-dev > Version: 1.22.5 > Severity: wishlist > X-Debbugs-Cc: c...@slerp.xyz, debian...@lists.debian.org
> When packaging the AMD ROCm GPU libraries for Debian, we are currently > using CXX=hipcc or CXX=clang++ to build libraries written in HIP as if > they were written in C++. I guess we should also add HIPCXX (defaulting to <host-triplet>-hipcc and HIPCXX_FOR_BUILD (defaulting to <build-triplet>-hipcc when cross compiling, otherwise to hipcc) like with the other toolchains? An apt-file query seems to indicate thee hipcc package provides no triplet-qualified toolchains? Which means automatic cross-compiling is going to be painful given our current infrastructure. If support for this is really missing from the looks of it, we can always postpone adding the compiler tool variables for now until this is implemented (we can still add the HIPFLAGS variables though). I'm CCing the debian-cross list for further insight. > This necessitates filtering out flags that are not supported when > building HIP language code. For example, the rocsparse d/rules include: > > export CXX=hipcc > export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-fortify optimize=-lto > > # filter incompatible options from affecting device code > CXXFLAGS := $(subst -fstack-protector-strong,-Xarch_host > -fstack-protector-strong,$(CXXFLAGS)) > CXXFLAGS := $(subst -fcf-protection,-Xarch_host > -fcf-protection,$(CXXFLAGS)) > > In the lines above, we are prepending `-Xarch_host` to prevent certain > flags from being applied to device code (i.e., GPU code) while still > ensuring that they are applied to host code (i.e., CPU code). > > However, there is HIP language support in CMake. We should use it! > dpkg-buildflags should set HIPFLAGS [1]. The CXXFLAGS make a good > starting place for the HIPFLAGS values, but `-Xarch_host` should be > added to `-fstack-protector-strong` and `-fcf-protection`, like in the > example above. > [1]: https://cmake.org/cmake/help/v3.28/envvar/HIPFLAGS.html It would be helpful if you could verify whether all flags currently added to CXXFLAGS would work for HIPFLAGS. You can check for all such instances by searching for either default_flags, @compiler_flags and CXXFLAGS from: $ perldoc -m Dpkg::Vendor::Debian Once we have the complete list, I'm happy to add the handling for these flags in the code. Thanks, Guillem