Open
Description
After creating a static library containing device functions using -fgpu-rdc
and ar
, the library is linked with a command like:
hipcc libdevicelibrary.a main.cpp -fgpu-rdc -o program
This works fine, however, when the argument order is reversed and main.cpp
is passed before libdevicelibrary.a
, the compiler tries to interpret the files from libdevicelibrary.a
as source file:
$ hipcc main.cpp libdevicelibrary.a -fgpu-rdc -o program
/tmp/library.o:1:1: error: expected unqualified-id
<U+007F>ELF<U+0002><U+0001><U+0001><U+0000>.... many more lines
This is caused by that placing main.cpp
on the command line causes hipcc
to emit -x hip
before it, which causes clang++
to interpret library.o
as a .hip
source file:
$ HIPCC_VERBOSE=1 hipcc main.cpp libdevicelibrary.a -fgpu-rdc -o program
hipcc-cmd: /opt/rocm/llvm/bin/clang++ [...extra options omitted for brevity] -x hip main.hip """/tmp/library.o""" -std=c++17 -fgpu-rdc -o "program"