evmar / n2

n2 ("into"), a ninja compatible build system
Apache License 2.0
338 stars 26 forks source link

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

Closed tru closed 9 months ago

tru commented 1 year ago

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 commented 1 year ago

Any thoughts on this one @evmar ?

evmar commented 1 year ago

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 commented 1 year ago

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

evmar commented 1 year ago

Ping @tru :)

evmar commented 1 year ago

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

tru commented 1 year ago

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

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 commented 9 months ago

@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.

evmar commented 9 months ago

I didn’t, thanks for pinging oops!

evmar commented 9 months ago

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 commented 9 months ago

@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 commented 9 months ago

Some notes from random digging:

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