With CET flags, Clang fails to compile hip code cd /tmp && wget https://raw.githubusercontent.com/ROCm-Developer-Tools/HIP-CPU/master/examples/vadd_hip/vadd_hip.cpp # -fcf-protection=full is added by sys-devel/clang-common /usr/lib/llvm/18/bin/clang++ --offload-arch=native -x hip vadd_hip.cpp -o vadd_hip -fno-stack-protector --hip-link -nogpulib error: option 'cf-protection=return' cannot be specified on this target Reported to LLVM here - https://github.com/llvm/llvm-project/issues/86450. However after report I immediately remembered another solution. /etc/clang/gentoo-hardened.cfg can contain: -Xarch_device -fstack-clash-protection -Xarch_device -fstack-protector-strong -Xarch_device -fPIE -include "/usr/include/gentoo/fortify.h" -Xarch_device -fcf-protection=full This might look messy for those who view "clang -v" output, but it makes compilation transparent, so we won't patch every HIP project like this: https://github.com/gentoo/gentoo/pull/34869#issuecomment-2016833430 And maybe in some distant future, when Gentoo drops Clang 18, if Clang would be smart enough to differentiate between GPU and CPU flags, then Gentoo can drop -Xarch_device.
Ouch, copy&paste error my previous comment. Please use -Xarch_host ...
Could you make a PR please?
*** Bug 927738 has been marked as a duplicate of this bug. ***
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a026c9c2fc47f40331bad89a40d2e953a8a90a79 commit a026c9c2fc47f40331bad89a40d2e953a8a90a79 Author: Sv. Lockal <lockalsash@gmail.com> AuthorDate: 2024-03-26 10:54:31 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2024-03-26 13:36:40 +0000 sys-devel/clang-common: add -Xarch_host to fix GPU compilation Add -Xarch_host to CPU-specific flags, so that it does not affects heterogenous code (e. g. HIP). For stack-protector flags: fixes compiler crashes like https://github.com/llvm/llvm-project/issues/83777. Clang 18.1.0 does not try to apply these flags to GPU code, but current ROCm libraries use Clang 17, so add "-Xarch_host" there too. This will allow to drop "-fno-stack-protector" patches from rocm-comgr, hip and hipcc eventually. For -fcf-protection: fixes error: option 'cf-protection=return' cannot be specified on this target. For -fPIE: do not touch, as at least since Clang 15 it only affects host relocation model. See also: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/clang/test/Driver/hip-fpie-option.hip Bug: https://github.com/llvm/llvm-project/issues/86450 Closes: https://bugs.gentoo.org/927752 Signed-off-by: Sv. Lockal <lockalsash@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/35926 Signed-off-by: Michał Górny <mgorny@gentoo.org> .../clang-common/clang-common-15.0.7-r8.ebuild | 185 ++++++++++++++++++++ .../clang-common/clang-common-16.0.6-r3.ebuild | 191 +++++++++++++++++++++ ...0.6-r2.ebuild => clang-common-17.0.6-r3.ebuild} | 6 +- ...1.2-r1.ebuild => clang-common-18.1.2-r2.ebuild} | 6 +- .../clang-common/clang-common-19.0.0.9999.ebuild | 6 +- ...d => clang-common-19.0.0_pre20240322-r1.ebuild} | 6 +- 6 files changed, 388 insertions(+), 12 deletions(-)
*** Bug 927908 has been marked as a duplicate of this bug. ***
*** Bug 927763 has been marked as a duplicate of this bug. ***
Sorry, it's not fix dev-libs/libclc and break mesa rusticl OpenCL implementation as well.
(In reply to Yury Zhuravlev from comment #7) > Sorry, it's not fix dev-libs/libclc and break mesa rusticl OpenCL > implementation as well. Please file a new bug for that.