Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Link error: multiple definition error of associate_descriptor when including <cuda/annotated_ptr> #270

Closed
xuantengh opened this issue Apr 24, 2022 · 2 comments · Fixed by #274
Assignees
Labels
bug: functional Does not work as intended. P0: must have Absolutely must ship with the milestone.
Milestone

Comments

@xuantengh
Copy link

When I try to include the header <cuda/annotated_ptr> in multiple compile units, the linker returns multiple definition errors indicating something gets repeatedly defined.

  • source files
// a.cu
#include <cuda/annotated_ptr>

__global__ void hello();

int main() {
  hello<<<1, 1>>>();
  return 0;
}
// b.cu
#include <cstdio>
#include <cuda/annotated_ptr>

__global__ void hello() {
  printf("hello from (%d, %d)\n", blockIdx.x, threadIdx.x); 
}

NVIDIA GPU driver version: 470.82.01, nvcc version: 11.6.124 .
compilation command & errors:

nvcc a.cu b.cu -arch=sm_80 -o a.out

/tmp/tmpxft_00035cb1_00000000-18_b.o: In function `void* cuda::__4::__detail_ap::__associate_descriptor<unsigned long>(void*, unsigned long)':
tmpxft_00035cb1_00000000-10_b.cudafe1.cpp:(.text+0x16): multiple definition of `void* cuda::__4::__detail_ap::__associate_descriptor<unsigned long>(void*, unsigned long)'
/tmp/tmpxft_00035cb1_00000000-15_a.o:tmpxft_00035cb1_00000000-6_a.cudafe1.cpp:(.text+0x16): first defined here
/tmp/tmpxft_00035cb1_00000000-18_b.o: In function `void* cuda::__4::__detail_ap::__associate_descriptor<cuda::__4::access_property::shared>(void*, cuda::__4::access_property::shared)':
tmpxft_00035cb1_00000000-10_b.cudafe1.cpp:(.text+0x37): multiple definition of `void* cuda::__4::__detail_ap::__associate_descriptor<cuda::__4::access_property::shared>(void*, cuda::__4::access_property::shared)'
/tmp/tmpxft_00035cb1_00000000-15_a.o:tmpxft_00035cb1_00000000-6_a.cudafe1.cpp:(.text+0x37): first defined here
/tmp/tmpxft_00035cb1_00000000-18_b.o: In function `cuda::__4::discard_memory(void volatile*, unsigned long)':
tmpxft_00035cb1_00000000-10_b.cudafe1.cpp:(.text+0x54): multiple definition of `cuda::__4::discard_memory(void volatile*, unsigned long)'
/tmp/tmpxft_00035cb1_00000000-15_a.o:tmpxft_00035cb1_00000000-6_a.cudafe1.cpp:(.text+0x54): first defined here
collect2: error: ld returned 1 exit status
@wmaxey
Copy link
Member

wmaxey commented Apr 24, 2022

It looks like this is from a toolkit. Thanks for the report!

@wmaxey wmaxey added P0: must have Absolutely must ship with the milestone. bug: functional Does not work as intended. labels Apr 24, 2022
@wmaxey wmaxey self-assigned this Apr 24, 2022
@wmaxey wmaxey added this to the 1.8.1 milestone Apr 24, 2022
@gonzalobg
Copy link
Collaborator

#274 fixes these and some other ODR issues in the annotated_ptr and access_property implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: functional Does not work as intended. P0: must have Absolutely must ship with the milestone.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants