Skip to content
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

[BUG]: CUB 2.4.0 fails with multiple definition errors in .cpp files #1922

Closed
1 task done
valgur opened this issue Jun 27, 2024 · 3 comments
Closed
1 task done

[BUG]: CUB 2.4.0 fails with multiple definition errors in .cpp files #1922

valgur opened this issue Jun 27, 2024 · 3 comments
Labels
bug Something isn't working right.

Comments

@valgur
Copy link
Contributor

valgur commented Jun 27, 2024

Is this a duplicate?

Type of Bug

Compile-time Error

Component

CUB

Describe the bug

Including cub/util_debug.cuh (or any others that use it) from multiple .cpp files causes linking to fail with:

/usr/bin/ld: b.o: in function `cub::CUB_200400___CUDA_ARCH_LIST___NS::Debug(cudaError, char const*, int)':
b.cpp:(.text+0x0): multiple definition of `cub::CUB_200400___CUDA_ARCH_LIST___NS::Debug(cudaError, char const*, int)'; a.o:a.cpp:(.text+0x0): first defined here

This only happens with CUB 2.4.0 from CUDA 12.5.40. CUB 2.3.2 from CUDA 12.4 and older versions work fine.

I am using GCC 11 as the compiler and linker.

How to Reproduce

  1. Create files a.cpp and b.cpp with #include <cub/util_debug.cuh> as their contents.
  2. Run
g++-11 -I/usr/local/cuda-12.5/targets/x86_64-linux/include -c a.cpp -o a.o
g++-11 -I/usr/local/cuda-12.5/targets/x86_64-linux/include -c b.cpp -o b.o
g++-11 a.o b.o /usr/local/cuda-12.5/targets/x86_64-linux/lib/libcudart.so -o libx.a

Fails with

/usr/bin/ld: b.o: in function `cub::CUB_200400___CUDA_ARCH_LIST___NS::Debug(cudaError, char const*, int)':
b.cpp:(.text+0x0): multiple definition of `cub::CUB_200400___CUDA_ARCH_LIST___NS::Debug(cudaError, char const*, int)'; a.o:a.cpp:(.text+0x0): first defined here
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status

Expected behavior

No linker errors.

Reproduction link

No response

Operating System

Ubuntu Linux

nvidia-smi output

No response

NVCC version

No response

@valgur valgur added the bug Something isn't working right. label Jun 27, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Jun 27, 2024
@alliepiper
Copy link
Collaborator

I believe that has been fixed in main by PR #1643.

The relevant change is the addition of inline to this line

Can you try making this change locally and see if it resolves it for you?

@valgur
Copy link
Contributor Author

valgur commented Jun 28, 2024

Setting _CCCL_FORCEINLINE to inline fixed the issue. Thank you!

Glad to see that the fix has already been applied as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right.
Projects
Archived in project
Development

No branches or pull requests

2 participants