-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking static library with device functions depends on argument order #77
Comments
It seems like the issue can be resolved by "resetting" the language before the object file is passed by using /opt/rocm/llvm/bin/clang++ [...extra options omitted for brevity] -x hip main.hip -x none """/tmp/library.o""" -std=c++17 -fgpu-rdc -o "program" seems to work fine. |
cc @yxsamliu |
That is a hipcc issue. hipcc by default adds -x hip before .cpp files. hipcc is supposed to be a thin wrapper for clang and not intended for complicated command arguments handling. It is recommended to use clang++ instead of hipcc. Also it is recommended to use .hip as extension of HIP program instead of .cpp. If .cpp has to be used and .a file has to be after .cpp file, use '-x hip' before .cpp and '-x none' before .a file. |
@Snektron Internal ticket is created to investigate this issue. Thanks! |
Typically this is not the way that libraries are placed on the command line, as they are usually placed last. The workaround works, yes, but in my opinion it would be nice if there was a proper solution. If hipcc does it's own language detection, would it not be relatively straight forward to detect the .a type and automatically pass -x none? I'm fairly sure that nvcc let's me pass the device library as last argument. Note c that this came up during development of the static_device_library ROCm sample, see here. |
After creating a static library containing device functions using
-fgpu-rdc
andar
, the library is linked with a command like:This works fine, however, when the argument order is reversed and
main.cpp
is passed beforelibdevicelibrary.a
, the compiler tries to interpret the files fromlibdevicelibrary.a
as source file:This is caused by that placing
main.cpp
on the command line causeshipcc
to emit-x hip
before it, which causesclang++
to interpretlibrary.o
as a.hip
source file:The text was updated successfully, but these errors were encountered: