Commit 29d545f
committed
[ROCm] Fix CUDA build: guard cub include for C translation units
The ROCm support commit routed all CUDA/HIP includes through
internal/cuda_to_hip.h and pulled it into utils.h and internal_types.h,
which are included by the C translation units (cli.c, cupdlpx.c,
mps_parser.c, presolve.c). On the CUDA path that header included
<cub/device/device_reduce.cuh> unconditionally; cub is C++ only, so the C
compiler failed with "unknown type name 'namespace'", breaking every
CUDA build job (all Linux and Windows toolchains, CUDA 12.4 through 13.1).
The HIP path was unaffected because its hipcub include was already guarded
with #ifdef __cplusplus.
The fix mirrors that guard on the CUDA branch: the cub header is only
included for C++ translation units (the .cu device sources that actually
use cub::DeviceReduce). The change is entirely within the #else CUDA
branch, so the HIP/ROCm device code is unchanged.
Authored with assistance from Claude.
Test Plan: reproduced and verified the CUDA path locally with the CUDA
12.8 toolkit (gcc 13, ninja), matching the upstream CI configure:
```
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCUPDLPX_BUILD_TESTS=OFF -DCMAKE_CUDA_ARCHITECTURES=80
cmake --build build --clean-first
```
Before: cc -std=gnu99 -c src/cupdlpx.c fails on cub/device/device_reduce.cuh.
After: clean build, links cupdlpx and libcupdlpx.so with 0 errors.1 parent 9d73c35 commit 29d545f
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | 175 | | |
177 | 176 | | |
178 | 177 | | |
179 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
180 | 185 | | |
0 commit comments