bazel-compile-commands-extractor icon indicating copy to clipboard operation
bazel-compile-commands-extractor copied to clipboard

cuda_rules triggers assert "Something went wrong in makefile parsing to get headers. The target should be an object file."

Open axbycc-mark opened this issue 1 year ago • 1 comments

I'm using the cuda_rules https://github.com/bazel-contrib/rules_cuda project to generate a cuda_library target. Running :refresh_all triggers the assert here https://github.com/hedronvision/bazel-compile-commands-extractor/blob/4689147cf4b1c2d507fd8bbb8eb748a7bbaad4ef/refresh.template.py#L176C45-L176C102.

The function documentation mentions this clang or gcc. Parse a set of headers from the contents of a *.d dependency file generated by clang (or gcc)

On my system, it is somehow encountering an nvcc generated file, erroring out with the following.

Something went wrong in makefile parsing to get headers. The target should be an object file. Output:
Failed to run D:/TMP/marki/tmpxft_00007f68_00000000-2.bat (The directory name is invalid.

).
nvcc fatal   : Could not set up the environment for Microsoft Visual Studio using 'D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'

Commenting out the assert, and just returning empty set() here allows the :refresh_all to seemingly generate a correct (or at least very usable) compile_commands.json.

axbycc-mark avatar Apr 06 '24 17:04 axbycc-mark

I have a similar issue, but it was due to some .d files are not in the expected format of target.o: dependencies.

In my case, a library has a .d file like:

-no-canonical-prefixes: external/s2n~/crypto/s2n_aead_cipher_aes_gcm.c \
  external/openssl~/include/openssl/aes.h \

After reading that part of the code, it seems the target is unused, so I commented out the assert from the template file. The command works after the fix.

PhamLeHai avatar Jun 13 '24 06:06 PhamLeHai