Skip to content

nvcc fatal : Cannot find compiler 'cl.exe' in PATH #169

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
axbycc-mark opened this issue Feb 7, 2024 · 4 comments
Closed

nvcc fatal : Cannot find compiler 'cl.exe' in PATH #169

axbycc-mark opened this issue Feb 7, 2024 · 4 comments

Comments

@axbycc-mark
Copy link

Reproduction https://github.com/axbycc-mark/hedron-compile-commands-repro/tree/cuda_rules

OS: Windows 10
Bazel Version: 7.0.2
Compiler: Visual Studio 2019
NVCC: 11.7, V11.7.64

I'm using rules_cuda (https://github.com/bazel-contrib/rules_cuda) which sets the path to cl.exe when invoking nvcc. When running @@hedron_compile_commands//:refresh_all, this path is not set, leading to the following error: nvcc fatal : Cannot find compiler 'cl.exe' in PATH.

Full error output appears below.

bazel run @hedron_compile_commands//:refresh_all
Starting local Bazel server and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
INFO: Analyzed target @@hedron_compile_commands//:refresh_all (72 packages loaded, 333 targets configured).
INFO: Found 1 target...
Target @@hedron_compile_commands//:refresh_all up-to-date:
  bazel-bin/external/hedron_compile_commands/refresh_all.zip
  bazel-bin/external/hedron_compile_commands/refresh_all.exe
  bazel-bin/external/hedron_compile_commands/refresh_all.check_python_version.py
  bazel-bin/external/hedron_compile_commands/refresh_all.py
INFO: Elapsed time: 7.082s, Critical Path: 0.04s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/hedron_compile_commands/refresh_all.exe
>>> Analyzing commands used in @//...
Traceback (most recent call last):
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.check_python_version.py", line 15, in <module>
    refresh_all.main()
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 1421, in main
    compile_command_entries.extend(_get_commands(target, flags))
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 1283, in _get_commands
    yield from _convert_compile_commands(parsed_aquery_output)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 1163, in _convert_compile_commands
    for source_files, header_files, compile_command_args in outputs:
  File "D:\Python310\lib\concurrent\futures\_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "D:\Python310\lib\concurrent\futures\_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "D:\Python310\lib\concurrent\futures\_base.py", line 451, in result
    return self.__get_result()
  File "D:\Python310\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "D:\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 1127, in _get_cpp_command_for_files
    source_files, header_files = _get_files(compile_action)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 678, in _get_files
    header_files = _get_headers(compile_action, source_file)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 596, in _get_headers
    headers, should_cache = _get_headers_gcc(compile_action.arguments, source_path, compile_action.actionKey)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 302, in _get_headers_gcc
    headers = _parse_headers_from_makefile_deps(header_search_process.stdout)
  File "C:\Users\marki\AppData\Local\Temp\Bazel.runfiles_fuolzcoy\runfiles\hedron_compile_commands\refresh_all.py", line 176, in _parse_headers_from_makefile_deps
    assert target.endswith(('.o', '.obj')), "Something went wrong in makefile parsing to get headers. The target should be an object file. Output:\n" + d_file_content
AssertionError: Something went wrong in makefile parsing to get headers. The target should be an object file. Output:
nvcc fatal   : Cannot find compiler 'cl.exe' in PATH
@cpsauer
Copy link
Contributor

cpsauer commented Feb 8, 2024

Thanks for reporting, @axbycc-mark. Sorry about all these windows issues.

Taking a crack at fixing rn

cpsauer added a commit that referenced this issue Feb 8, 2024
@cpsauer
Copy link
Contributor

cpsauer commented Feb 8, 2024

Just pushed--could I ask you to give that a whirl for me on windows? We should now inherit the action environment when invoking in that case (and some others), though Bazel has a variety of issues about not surfacing all environment variables--some chance we'll still run into something like that here.

@axbycc-mark
Copy link
Author

Success! Thanks so much!

@cpsauer
Copy link
Contributor

cpsauer commented Feb 8, 2024

Great! Thanks so much for reporting and testing and generally helping make things better for those who come after you!

@cpsauer cpsauer closed this as completed Feb 8, 2024
ngiloq6 added a commit to ngiloq6/bazel-compile-commands-extractor that referenced this issue Aug 17, 2024
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