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

Compilation error since 11.1.0 with NVIDIA's nvcc compiler #4297

Open
breyerml opened this issue Jan 8, 2025 · 3 comments
Open

Compilation error since 11.1.0 with NVIDIA's nvcc compiler #4297

breyerml opened this issue Jan 8, 2025 · 3 comments

Comments

@breyerml
Copy link

breyerml commented Jan 8, 2025

Using the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.15)

project(MyProject)

enable_language(CUDA)

add_executable(prog main.cu)

include(FetchContent)
FetchContent_Declare(fmt
                 GIT_REPOSITORY https://github.com/fmtlib/fmt.git
                 GIT_TAG 11.1.0
                 QUIET
)
FetchContent_MakeAvailable(fmt)

target_link_libraries(prog PUBLIC fmt::fmt)

with the main.cu file

#include "fmt/format.h"
#include "fmt/chrono.h"

#include <chrono>
#include <iostream>

int main() {
  std::cout << fmt::format("{}", std::chrono::milliseconds{ 10 }) << std::endl;
  return 0;
}

built via cmake .. && make together with nvcc version cuda_12.2.r12.2/compiler.33191640_0 results in the following compiler error:

/Documents/test/fmt/build/_deps/fmt-src/include/fmt/chrono.h(2310): error: too many arguments in function call
          detail::utc_clock::to_sys(val), ctx);
                                    ^

/Documents/test/fmt/build/_deps/fmt-src/include/fmt/chrono.h(2310): error: the object has type qualifiers that are not compatible with the member function "fmt::v11::detail::utc_clock::to_sys"
            object type is: const fmt::v11::detail::utc_clock
          detail::utc_clock::to_sys(val), ctx);
          ^

This error happens with versions 11.1.0,11.1.1, and master.
A git bisect revealed that the offending commit is: 89af1ad

@breyerml
Copy link
Author

breyerml commented Jan 8, 2025

Changing line 263 in chrono.h from

struct utc_clock {
  void to_sys();
};

to

struct utc_clock {
  template <typename T>
  void to_sys(T);
};

fixes the compilation error with nvcc. But I don't believe that that should be the final fix.

@vitaut
Copy link
Contributor

vitaut commented Jan 8, 2025

Adding an argument to the fallback to_sys is the correct fix. A PR would be welcome.

@breyerml
Copy link
Author

breyerml commented Jan 9, 2025

I opened a PR.

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