Skip to content

extern "C" (on declaration only) produces mangled symbols for __host__ functions #630

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

Closed
jithunnair-amd opened this issue Aug 14, 2018 · 2 comments

Comments

@jithunnair-amd
Copy link

If a __host__ function is declared as extern "C", but the definition isn't labelled as extern "C", hipcc/hcc produces a mangled symbol in the resulting object file. However, if the definition also has an extern "C" label, the symbol is non-mangled as expected. Also, this unexpected behaviour doesn't occur for __global__ functions (they produce the expected non-mangled symbol regardless of whether the definition also has an extern "C"). Below is a testcase for the same:

experiment.h:
extern "C" void FuncA(int exp);

experiment.cu:
#include <stdio.h>
#include "experiment.h"
#include "hip/hip_runtime.h"

/*extern "C"*/ __host__ void FuncA(int exp) {
printf("I got %d", exp);
}

Compile command: hipcc -fPIC -c experiment.cu -o experiment.o

rocm-user@51f7736e9394:~/experiment$ nm experiment.o | grep FuncA
00000000000038e0 T _Z5FuncAi

@whchung
Copy link
Contributor

whchung commented Aug 14, 2018

from the look of it it's related to HCC Clang CodeGen. probably better file the ticket in hcc repo

@jithunnair-amd jithunnair-amd changed the title extern "C" (on declaration only) doesn't produce non-mangled symbols for __host__ functions extern "C" (on declaration only) produces mangled symbols for __host__ functions Aug 14, 2018
@jithunnair-amd
Copy link
Author

Closing this issue because opened identical issue in HCC: ROCm/hcc#839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants