Skip to content

Commit a3a2b68

Browse files
get9facebook-github-bot
authored andcommitted
rocm: hip_toolchain_override rule to compile rocm-related projects
Summary: Sometimes we want to compile C/C++ sources that _aren't_ .hip files. The cxx toolchains today only use the rocm toolchain if you give it a .hip file. So what do we do? We can either: 1. Rename all the .cpp files as .hip so cxx rules pick the right toolchain. This is kinda meh, and unclear if this would work for header files either. 2. We can construct our own toolchain override and use the `hip_compiler_info` instead of `cxx_compiler_info` (2) is what this diff is. `hip_toolchain_override` borrows from `cxx_toolchain_override` and overrides enough of the toolchain info struct to s/cxx/hip/ for things that matter. This also overrides some linking behavior so we can maybe get to the point to where we can replace the `hip_link` rccl action with a real `cxx_library`. Reviewed By: blackm00n Differential Revision: D69506114 fbshipit-source-id: 018f28c9141155c9cf5d8f04211595f95ef62b43
1 parent 7bb7705 commit a3a2b68

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

prelude/cxx/archive.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def _archive_flags(
2626
return ["/Brepro", "/d2threads1"]
2727
elif archiver_type == "windows_clang":
2828
return ["/llvmlibthin"] if thin else []
29+
elif archiver_type == "amdclang":
30+
# amdclang can be used to create archives with --emit-static-lib, so let's
31+
# prefer to let the toolchain define the args instead of hardcoding them here.
32+
return []
2933
flags = ""
3034

3135
# Operate in quick append mode, so that objects with identical basenames
@@ -69,6 +73,8 @@ def _archive(
6973
))
7074
if archiver_type == "windows" or archiver_type == "windows_clang":
7175
command.add([cmd_args(archive_output.as_output(), format = "/OUT:{}")])
76+
elif archiver_type == "amdclang":
77+
command.add(["-o", archive_output.as_output()])
7278
else:
7379
command.add([archive_output.as_output()])
7480

0 commit comments

Comments
 (0)