dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.21k stars 4.72k forks source link

Error loading rules.ninja when building coreclr tests locally #106005

Open huoyaoyuan opened 2 months ago

huoyaoyuan commented 2 months ago

Environment

Windows 11 22631.3880 Visual Studio 17.10.5, with bundled CMake and ninja tools

Description

The working tree was clean and has successfully ran build.cmd clr+libs for Debug and Release. When trying to run src\tests\build.cmd, it complains for:

BUILDTEST: Starting Build at 13:04:23.03
BUILDTEST: Commencing CoreCLR test build
BUILDTEST: Common MSBuild args: "/p:TargetOS=windows" "/p:Configuration=Debug" "/p:TargetArchitecture=x64" "/p:RuntimeFlavor=coreclr" /nologo /verbosity:minimal /clp:Summary /maxcpucount
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.10.5
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
BUILDTEST: Commencing build of native test components for x64/Debug
BUILDTEST: Number of processor cores 24
Not searching for unused variables given on the command line.
-- The C compiler identification is MSVC 19.40.33813.0
-- The CXX compiler identification is MSVC 19.40.33813.0
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
CMake Error:
  Running

   'C:/PROGRA~1/MICROS~2/2022/ENTERP~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe' '-C' 'C:/Users/Meow/source/dotnet/runtime/artifacts/tests/coreclr/obj/windows.x64.Debug/Native/CMakeFiles/CMakeScratch/TryCompile-q9nxyt' '-t' 'recompact'

  failed with:

   ninja: error: build.ninja:35: loading 'CMakeFiles\rules.ninja': 系统找不到指定的文件。

  include CMakeFiles\rules.ninja

                                ^ near here

CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:56 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!
BUILDTEST: Error: failed to generate native component build project

The erroring line in CMakeTestCCompiler.cmake is:

  try_compile(CMAKE_C_COMPILER_WORKS
    SOURCE_FROM_VAR testCCompiler.c __TestCompiler_testCCompilerSource
    OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT)

Looking at artifacts\tests\coreclr\obj\windows.x64.Debug\Native\CMakeFiles, there's no rules.ninja generated. Copying one from artifacts\obj\coreclr\windows.x64.Debug\CMakeFiles doesn't mitigate the issue. Using -msbuild was a workaround, but now it compiles with issues.

Any idea for why it only reproduces locally? Am I missing some step in repo setup?

dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @dotnet/runtime-infrastructure See info in area-owners.md if you want to be subscribed.

huoyaoyuan commented 1 month ago

It works fine now with Visual Studio 17.11.4. Maybe some issue behind the bundled toolchain?