CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
227 stars 34 forks source link

Hipcc not handling spaces in macros #945

Closed colleeneb closed 1 month ago

colleeneb commented 1 month ago

It looks like hipcc fails to work if a macro passed to it has a space in it. This should work as long as the space is protected with a blackslash. It's easy to reproduce (h/t @TApplencourt):

Failing with space:

> hipcc -DPACKAGE_STRING=\"H\ H\"   foo.c
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file

Remove space and the error is gone (but there's a new error about the missing file which is expected since there's no file).

clang++: error: no such file or directory: 'foo.c'
TApplencourt commented 1 month ago

For some context, this is used by OSU (http://mvapich.cse.ohio-state.edu/benchmarks/). So kinda important

colleeneb commented 1 month ago

It looks like it's from https://github.com/CHIP-SPV/HIPCC/blob/30f38d7d15e396079ae1e7318d86208e4b616ab0/src/hipBin_spirv.h#L165 . It looks like it makes one large string out of all arguments and then resplits them based on whitespaces. It doesn't work if there's a whitespace in an argument like above. Could we instead just run the regex per argument instead of making one big string?

colleeneb commented 1 month ago

I submitted a PR in https://github.com/CHIP-SPV/HIPCC/pull/7 with a possible solution.