Skip to content

Commit 6e502d1

Browse files
authored
Merge pull request #2995 from ROCm/du_pass_arch_to_crosstool
[develop-upstream] Pass AMDGPU_TARGETS to crosstool wrapper
2 parents a8fe5b4 + 5bdb8f5 commit 6e502d1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

third_party/xla/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_rocm.tpl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,27 @@ def GetHostCompilerOptions(argv):
100100

101101
return opts
102102

103+
def GetHipccOptions(argv):
104+
"""Collect the -hipcc_options values from argv.
105+
Args:
106+
argv: A list of strings, possibly the argv passed to main().
107+
Returns:
108+
The string that can be passed directly to hipcc.
109+
"""
110+
111+
parser = ArgumentParser()
112+
parser.add_argument('--offload-arch', nargs='*', action='append')
113+
# TODO find a better place for this
114+
parser.add_argument('-gline-tables-only', action='store_true')
115+
116+
args, _ = parser.parse_known_args(argv)
117+
118+
hipcc_opts = ' -gline-tables-only ' if args.gline_tables_only else ''
119+
if args.offload_arch:
120+
hipcc_opts = hipcc_opts + ' '.join(['--offload-arch=' + a for a in sum(args.offload_arch, [])])
121+
122+
return hipcc_opts
123+
103124
def system(cmd):
104125
"""Invokes cmd with os.system().
105126
@@ -129,6 +150,7 @@ def InvokeHipcc(argv, log=False):
129150
"""
130151

131152
host_compiler_options = GetHostCompilerOptions(argv)
153+
hipcc_compiler_options = GetHipccOptions(argv)
132154
opt_option = GetOptionValue(argv, 'O')
133155
m_options = GetOptionValue(argv, 'm')
134156
m_options = ''.join([' -m' + m for m in m_options if m in ['32', '64']])
@@ -167,7 +189,7 @@ def InvokeHipcc(argv, log=False):
167189
srcs = ' '.join(src_files)
168190
out = ' -o ' + out_file[0]
169191

170-
hipccopts = ' '
192+
hipccopts = hipcc_compiler_options + ' '
171193
# In hip-clang environment, we need to make sure that hip header is included
172194
# before some standard math header like <complex> is included in any source.
173195
# Otherwise, we get build error.

third_party/xla/third_party/gpus/rocm_configure.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,9 @@ def _create_local_rocm_repository(repository_ctx):
725725
"%{crosstool_verbose}": _crosstool_verbose(repository_ctx),
726726
"%{gcc_host_compiler_path}": str(cc),
727727
"%{crosstool_clang}": "1" if _is_clang_enabled(repository_ctx) else "0",
728+
"%{rocm_amdgpu_targets}": ",".join(
729+
["\"%s\"" % c for c in rocm_config.amdgpu_targets],
730+
),
728731
},
729732
)
730733

0 commit comments

Comments
 (0)