@@ -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+
103124def 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.
0 commit comments