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

Can't compile with nvcc #139

Open
yanggthomas opened this issue Jan 11, 2022 · 4 comments
Open

Can't compile with nvcc #139

yanggthomas opened this issue Jan 11, 2022 · 4 comments
Assignees

Comments

@yanggthomas
Copy link

yanggthomas commented Jan 11, 2022

Describe the bug
Hi. I get a compile error when I compile with nvcc(cuda).

/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
 GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept
                                        ^~~~
/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ‘operator const int’ in ‘class ghc::filesystem::directory_entry’ does not name a type
/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
 GHC_INLINE directory_entry::operator const filesystem::path&() const noexcept
                                        ^~~~
/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
/tmp/tmp.opBbT90DDi/extern/filesystem/include/ghc/filesystem.hpp:5219:40: error: ‘operator const int’ in ‘class ghc::filesystem::directory_entry’ does not name a type

To Reproduce
single header mode

#include <ghc/filesystem>

I could fix this bug by using forward/implementation in my project.

@gulrak
Copy link
Owner

gulrak commented Jan 13, 2022

Thanks for reporting this, not sure why this is happening. I don't have access to a system with nvcc yet, maybe I can set up one in a VM, but I need more informations like the version of nvcc and the OS to at least try to replicate it.

@gulrak gulrak self-assigned this Jan 13, 2022
@yanggthomas
Copy link
Author

yanggthomas commented Jan 13, 2022

截屏2022-01-13 下午10 32 59

截屏2022-01-13 下午10 33 57

hope these could help you

@gulrak
Copy link
Owner

gulrak commented Apr 3, 2022

Sorry, it took more time than expected to look into this. I had a test installing nvidia-cuda-toolkit on my 20.04 Ubuntu, that gives me:

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

So sadly not exactly the same conditions.

I then made a build folder and from there simply tried:

$  nvcc ../test/filesystem_test.cpp -I ../include/

It ran without any error and the resulting a.out of that test gave me:

$ ./a.out 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.out is a Catch v2.13.7 host application.
Run with -? for options
[... cut expected warning output for things that can vary on platforms ...]
===============================================================================
All tests passed (1081 assertions in 70 test cases)

So my OS is newer but the CUDA toolkit is older, but I have the feeling something else is leading to those errors and I would need some reproducible example with the compile parameters.

I'm by no means a CUDA expert and don't use it in any project, so any help is welcome.

@yanggthomas
Copy link
Author

Sorry for the late reply.

It could be because nvcc is actually passing the pure cpp/c source file to g++/gcc on linux. As you can see in https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#supported-host-compilers, which says "During non-CUDA phases (except the run phase), because these phases will be forwarded by nvcc to this compiler.". Here the host compiler means gcc on Linux.

As for this particular case, the error occurs if I put some code of filesystem in *.cu file, which will be processed by nvcc first. However, basiclly filesystem is not required on device(GPU) since generally this is not the part we want to accelerate via GPU and CUDA. Actually, this is a supported feature of nvcc that host only code in *.cu will be forward to host compiler.

So personally speaking, I tend to regard this problem as a bug of nvcc. Probably add a hint in the documentation to suggest others to use "forward/implementation" style with CUDA, in this way, the filesystem code will be processed only by host compiler and nvcc will stop complaining.

Additionally, to reproduce the error, maybe I can write some small examples. But I am relative new to github and I am not sure how to pass the code properly.

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