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

Tries to open nonexistent .d file in LLVM ASM build #80

Closed
tru opened this issue Jul 31, 2023 · 11 comments
Closed

Tries to open nonexistent .d file in LLVM ASM build #80

tru opened this issue Jul 31, 2023 · 11 comments

Comments

@tru
Copy link
Contributor

tru commented Jul 31, 2023

Hi,

Another weird one (sorry!). After #78 was fixed I was able to build .cpp files from the LLVM repo on Windows, but I run into problems with ASM files, here is the error:

read lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir\blake3_avx2_x86-64_windows_msvc.asm.obj.d: The system cannot find the file specified. (os error 2)

Here is the command invocation:

C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\ml64.exe -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\code\llvm\llvm-project\out\debug\lib\Support\BLAKE3 -IC:\code\llvm\llvm-project\llvm\lib\Support\BLAKE3 -IC:\code\llvm\llvm-project\out\debug\include -IC:\code\llvm\llvm-project\llvm\include  -c -Fo lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir\blake3_avx2_x86-64_windows_msvc.asm.obj C:\code\llvm\llvm-project\llvm\lib\Support\BLAKE3\blake3_avx2_x86-64_windows_msvc.asm
failed: Building ASM_MASM object lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir\blake3_avx2_x86-64_windows_msvc.asm.obj

I am guessing that n2 tries to find the dependency file for the .asm file, but ml64 doesn't output (maybe no assemblers do?). Hopefully an easy fix.

@tru
Copy link
Contributor Author

tru commented Aug 28, 2023

Any thoughts on this one @evmar ?

@evmar
Copy link
Owner

evmar commented Aug 29, 2023

Sorry for not responding! Can you find the relevant snippet of the build.ninja file that runs that command? n2 is only supposed to look for that .d file if the build.ninja mentions a depfile attribute, maybe something is going wrong in how n2 is parsing the file?

@evmar evmar changed the title Can't compile ASM files on Windows with ml64.exe Tries to open nonexistent .d file in LLVM ASM build Aug 29, 2023
@evmar
Copy link
Owner

evmar commented Aug 29, 2023

(Alternatively, you could attach your entire build.ninja file and I could take a look)

@evmar
Copy link
Owner

evmar commented Sep 25, 2023

Ping @tru :)

@evmar
Copy link
Owner

evmar commented Oct 4, 2023

I'll wait for someone else to repro, no prob.

@evmar evmar closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
@tru
Copy link
Contributor Author

tru commented Oct 5, 2023

Hi! So sorry I didn't reply, it's been busy days for me. But I pulled latest from the n2 repo and reproduced it with llvm-project

  • n2.exe installed as ninja.exe
  • ran ninja LLVMSupportBlake3
C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\MSVC\1437~1.328\bin\Hostx64\x64\ml64.exe -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_LIBCPP_ENABLE_HARDENED_MODE -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/code/llvm/llvm-project/out/debug/lib/Support/BLAKE3 -IC:/code/llvm/llvm-project/llvm/lib/Support/BLAKE3 -IC:/code/llvm/llvm-project/out/debug/include -IC:/code/llvm/llvm-project/llvm/include  -c -Fo lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse41_x86-64_windows_msvc.asm.obj C:/code/llvm/llvm-project/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_windows_msvc.asm
failed: Building ASM_MASM object lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_windows_msvc.asm.obj

Attached is the build.ninja file.

build.ninja.zip

@tru
Copy link
Contributor Author

tru commented Jan 5, 2024

@evmar did you see my reply on this one? I just retried it today and it still have the same problem. I can provide new files if you want.

tru added a commit to tru/n2 that referenced this issue Jan 5, 2024
CMake can sometimes write depfile directives to build.ninja
even when no depfile is generated. This was handled by "ninja"
by just ignoring the missing file and going on with the build,
see the code here:

https://github.com/ninja-build/ninja/blob/master/src/build.cc#L894

This fixes evmar#80
@evmar evmar reopened this Jan 5, 2024
@evmar
Copy link
Owner

evmar commented Jan 5, 2024

I didn’t, thanks for pinging oops!

@evmar
Copy link
Owner

evmar commented Jan 6, 2024

It looks like the relevant snippet is

build lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_windows_msvc.asm.obj: ASM_MASM_COMPILER__LLVMSupportBlake3_unscanned_Debug C$:/code/llvm/llvm-project/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_windows_msvc.asm || cmake_object_order_depends_target_LLVMSupportBlake3
  DEFINES = -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_LIBCPP_ENABLE_HARDENED_MODE -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
  DEP_FILE = lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir\blake3_sse2_x86-64_windows_msvc.asm.obj.d
  INCLUDES = -IC:/code/llvm/llvm-project/out/debug/lib/Support/BLAKE3 -IC:/code/llvm/llvm-project/llvm/lib/Support/BLAKE3 -IC:/code/llvm/llvm-project/out/debug/include -IC:/code/llvm/llvm-project/llvm/include
  OBJECT_DIR = lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir
  OBJECT_FILE_DIR = lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir
  TARGET_COMPILE_PDB = lib\Support\BLAKE3\CMakeFiles\LLVMSupportBlake3.dir\
  TARGET_PDB = ""

but I don't see the definition of ASM_MASM_COMPILER__LLVMSupportBlake3_unscanned_Debug here, I think it might be in one of the adjacent .ninja files CMake generates?

@tru
Copy link
Contributor Author

tru commented Jan 6, 2024

@evmar i don't have access to a computer right now, but it just does depfile = $DEP_FILE for rule definition. I then compared how ninja handled this and stepped through it in the debugger and noticed that it just ignored the not found error. So I think this is the "right" fix.

@evmar
Copy link
Owner

evmar commented Jan 8, 2024

Some notes from random digging:

  • it seems like the ASM_MASM related logic is part of CMake, not LLVM specific
  • some discussion of depfiles with assembly here https://gitlab.kitware.com/cmake/cmake/-/issues/20426
  • as best as I can gather, cmake basically unconditionally sets DEP_FILE, while masm is the MS assembler that doesn't support writing depfiles

So I conclude treating missing files as empty is more or less right.

@evmar evmar mentioned this issue Jan 8, 2024
@evmar evmar closed this as completed in 02f9546 Jan 8, 2024
evmar pushed a commit that referenced this issue Jan 8, 2024
CMake can sometimes write depfile directives to build.ninja
even when no depfile is generated. This was handled by "ninja"
by just ignoring the missing file and going on with the build,
see the code here:

https://github.com/ninja-build/ninja/blob/master/src/build.cc#L894

This fixes #80
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

Successfully merging a pull request may close this issue.

2 participants