-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[CLANG][GPU] Error using printf on device with -fno-builtin[-printf] #68478
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
Labels
clang
Clang issues not falling into any other category
Comments
GCC docs for
But this also doesn't work with |
Maetveis
pushed a commit
to Maetveis/llvm-project
that referenced
this issue
Oct 8, 2023
Previously __builtin_printf would result to emitting call to printf, even though directly calling printf was translated. Ref: llvm#68478
arsenm
pushed a commit
that referenced
this issue
Feb 5, 2024
Previously `__builtin_printf` would result to emitting call to `printf`, even though directly calling `printf` was translated. Ref: #68478
agozillon
pushed a commit
to agozillon/llvm-project
that referenced
this issue
Feb 5, 2024
…#68515) Previously `__builtin_printf` would result to emitting call to `printf`, even though directly calling `printf` was translated. Ref: llvm#68478
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When
-fno-builtin-printf
is in effect (such as when passing this option or simply-fno-builtin
),compiling a device function with printf results in an error.
Impact
/Oi-
commonly used on Windows when debugging (this is the default setting of Visual Studio) is translated byclang-cl
to-fno-builtin
.There's no option to re-enable a builtin that was disabled by a previous flag, so the only option is to not use
-fno-builtin
or list all builtin functions except printf.Environment
Reproducer
Assuming a file named main.cu with the contents:
For cuda:
For HIP:
(This happens with both with
-mprintf-kind=
buffered
andhostcall
)OpenMP offloading is probably also affected, but I didn't try it.
Analysis
Here's what I think goes wrong:
Clang rewrites
printf
tovprintf
for Cuda, and directly emits runtime calls for AMDGPU, but this only happens when builtins are enabled, when builtins are not enabled a normal function call is emitted toprintf
, but it won't be found because:vprintf
.printf
fails earlier (at compile time instead of link-time).The text was updated successfully, but these errors were encountered: