|
28 | 28 | "get_python_bin", |
29 | 29 | "raw_exec", |
30 | 30 | "realpath", |
| 31 | + "relative_to", |
31 | 32 | "which", |
32 | 33 | ) |
33 | 34 | load( |
@@ -195,45 +196,36 @@ def auto_configure_warning(msg): |
195 | 196 | # END cc_configure common functions (see TODO above). |
196 | 197 |
|
197 | 198 | def _rocm_include_path(repository_ctx, rocm_config, bash_bin): |
198 | | - """Generates the cxx_builtin_include_directory entries for rocm inc dirs. |
| 199 | + """Generates the entries for rocm inc dirs based on rocm_config. |
199 | 200 |
|
200 | 201 | Args: |
201 | 202 | repository_ctx: The repository context. |
202 | 203 | rocm_config: The path to the gcc host compiler. |
| 204 | + bash_bin: path to the bash interpreter. |
203 | 205 |
|
204 | 206 | Returns: |
205 | | - A string containing the Starlark string for each of the gcc |
206 | | - host compiler include directories, which can be added to the CROSSTOOL |
| 207 | + A string containing the Starlark string for each of the hipcc |
| 208 | + compiler include directories, which can be added to the CROSSTOOL |
207 | 209 | file. |
208 | 210 | """ |
209 | 211 | inc_dirs = [] |
210 | 212 |
|
211 | | - # Add full paths |
212 | | - rocm_toolkit_path = str(repository_ctx.path(rocm_config.rocm_toolkit_path)) |
213 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/8.0/include") |
214 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/9.0.0/include") |
215 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/10.0.0/include") |
216 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/11.0.0/include") |
217 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/12.0.0/include") |
218 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/13.0.0/include") |
219 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/14.0.0/include") |
220 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/15.0.0/include") |
221 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/16.0.0/include") |
222 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/17.0.0/include") |
223 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/17/include") |
224 | | - inc_dirs.append(rocm_toolkit_path + "/lib/llvm/lib/clang/17/include") |
225 | | - inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/18/include") |
226 | | - if int(rocm_config.rocm_version_number) >= 60200: |
227 | | - inc_dirs.append(rocm_toolkit_path + "/lib/llvm/lib/clang/18/include") |
228 | | - inc_dirs.append(rocm_toolkit_path + "/lib/llvm/lib/clang/19/include") |
229 | | - inc_dirs.append(rocm_toolkit_path + "/lib/llvm/lib/clang/20/include") |
230 | | - |
231 | | - # Support hcc based off clang 10.0.0 (for ROCm 3.3) |
232 | | - inc_dirs.append(rocm_toolkit_path + "/hcc/compiler/lib/clang/10.0.0/include/") |
233 | | - inc_dirs.append(rocm_toolkit_path + "/hcc/lib/clang/10.0.0/include") |
234 | | - |
235 | | - # Add hcc headers |
236 | | - inc_dirs.append(rocm_toolkit_path + "/hcc/include") |
| 213 | + # Add HIP-Clang headers (relative to rocm root) |
| 214 | + rocm_path = repository_ctx.path(rocm_config.rocm_toolkit_path) |
| 215 | + clang_path = rocm_path.get_child("llvm/bin/clang") |
| 216 | + resource_dir_result = execute(repository_ctx, [str(clang_path), "-print-resource-dir"]) |
| 217 | + |
| 218 | + if resource_dir_result.return_code: |
| 219 | + auto_configure_fail("Failed to run hipcc -print-resource-dir: %s" % err_out(resource_dir_result)) |
| 220 | + |
| 221 | + resource_dir_abs = resource_dir_result.stdout.strip() |
| 222 | + |
| 223 | + resource_dir_rel = relative_to(repository_ctx, str(rocm_path.realpath), resource_dir_abs, bash_bin) |
| 224 | + |
| 225 | + resource_dir = str(rocm_path.get_child(resource_dir_rel)) |
| 226 | + |
| 227 | + inc_dirs.append(resource_dir + "/include") |
| 228 | + inc_dirs.append(resource_dir + "/share") |
237 | 229 |
|
238 | 230 | return inc_dirs |
239 | 231 |
|
|
0 commit comments