raviqqe/melior

'mlir-c/AffineExpr.h' file not found

oovm opened this issue · 6 comments

oovm commented

I am compiling on windows, and it seems that mlir-c in the llvm directory cannot be found correctly.

image

Another problem is CXXFLAGS always send -std:c++17, while needs c++17


  • Full logs:
error: failed to run custom build command for `tblgen v0.3.0`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_TEST_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `C:\Users\Dell\CLionProjects\mlir-backend\target\debug\build\tblgen-46227c0434f68353\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-changed=wrapper.h
  cargo:rerun-if-changed=cc
  cargo:rustc-link-search=C:\Users\Dell\CLionProjects\llvm-project\llvm\out\build\x64-Release\lib
  cargo:rustc-link-lib=static=LLVMCore
  cargo:rustc-link-lib=static=LLVMSupport
  cargo:rustc-link-lib=static=LLVMTableGen
  cargo:rustc-link-lib=
  cargo:rustc-link-search=C:\Users\Dell\CLionProjects\mlir-backend\target\debug\build\tblgen-33e1f869219f9010\out
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  cargo:rerun-if-env-changed=CXX_x86_64-pc-windows-msvc
  CXX_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CXX_x86_64_pc_windows_msvc
  CXX_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  DEBUG = Some("false")
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-pc-windows-msvc
  CXXFLAGS_x86_64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_pc_windows_msvc
  CXXFLAGS_x86_64_pc_windows_msvc = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = Some("-IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\include -IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\out\\build\\x64-Release\\include -std:c++17   /EHs-c- /GR- -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS")
  running: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\include" "-IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\out\\build\\x64-Release\\include" "-std:c++17" "/EHs-c-" "/GR-" "-D_CRT_SECURE_NO_DEPRECATE" "-D_CRT_SECURE_NO_WARNINGS" "-D_CRT_NONSTDC_NO_DEPRECATE" "-D_CRT_NONSTDC_NO_WARNINGS" "-D_SCL_SECURE_NO_DEPRECATE" "-D_SCL_SECURE_NO_WARNINGS" "-DUNICODE" "-D_UNICODE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-I" "cc/include" "-I" "C:/Users/Dell/CLionProjects/llvm-project/llvm/include" "-FoC:\\Users\\Dell\\CLionProjects\\mlir-backend\\target\\debug\\build\\tblgen-33e1f869219f9010\\out\\cc/lib\\Record.o" "-c" "cc/lib\\Record.cpp"
  Record.cpp
  C:\Users\Dell\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tblgen-0.3.0\cc\lib\TableGen.hpp(63): error C7555: Using the specified initializer requires at least "/std:c++20"
  cc/lib\Record.cpp(22): error C7555: Using the specified initializer requires at least "/std:c++20"
  exit code: 2
  --- stderr
  error occurred: Command "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\include" "-IC:\\Users\\Dell\\CLionProjects\\llvm-project\\llvm\\out\\build\\x64-Release\\include" "-std:c++17" "/EHs-c-" "/GR-" "-D_CRT_SECURE_NO_DEPRECATE" "-D_CRT_SECURE_NO_WARNINGS" "-D_CRT_NONSTDC_NO_DEPRECATE" "-D_CRT_NONSTDC_NO_WARNINGS" "-D_SCL_SECURE_NO_DEPRECATE" "-D_SCL_SECURE_NO_WARNINGS" "-DUNICODE" "-D_UNICODE" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-I" "cc/include" "-I" "C:/Users/Dell/CLionProjects/llvm-project/llvm/include" "-FoC:\\Users\\Dell\\CLionProjects\\mlir-backend\\target\\debug\\build\\tblgen-33e1f869219f9010\\out\\cc/lib\\Record.o" "-c" "cc/lib\\Record.cpp" with args "cl.exe" did not execute successfully (status code exit code: 2).
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `mlir-sys v0.2.1`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_TEST_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
  process didn't exit successfully: `C:\Users\Dell\CLionProjects\mlir-backend\target\debug\build\mlir-sys-ca7903e2b2ae84b8\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=wrapper.h
  cargo:rustc-link-search=C:\Users\Dell\CLionProjects\llvm-project\llvm\out\build\x64-Release\lib
  cargo:rustc-link-lib=
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  --- stderr
  wrapper.h:1:10: fatal error: 'mlir-c/AffineExpr.h' file not found
  thread 'main' panicked at C:\Users\Dell\.cargo\registry\src\index.crates.io-6f17d22bba15001f\mlir-sys-0.2.1\build.rs:98:10:
  called `Result::unwrap()` on an `Err` value: ClangDiagnostic("wrapper.h:1:10: fatal error: 'mlir-c/AffineExpr.h' file not found\n")
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\panicking.rs:597
     1: core::panicking::panic_fmt
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\core\src\panicking.rs:72
     2: core::result::unwrap_failed
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\core\src\result.rs:1653
     3: core::result::Result<T,E>::unwrap
     4: <core::ops::control_flow::ControlFlow<B,C> as core::ops::try_trait::Try>::branch
     5: <core::ops::control_flow::ControlFlow<B,C> as core::ops::try_trait::Try>::branch
     6: core::ops::function::FnOnce::call_once
     7: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
     8: std::rt::lang_start::{{closure}}
     9: std::rt::lang_start_internal::closure$2
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\rt.rs:148
    10: std::panicking::try::do_call
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\panicking.rs:504
    11: std::panicking::try
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\panicking.rs:468
    12: std::panic::catch_unwind
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\panic.rs:142
    13: std::rt::lang_start_internal
               at /rustc/4578435e1695863d921c7763d5a0add98f8e3869/library\std\src\rt.rs:148
    14: std::rt::lang_start
    15: main
    16: invoke_main
               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    17: __scrt_common_main_seh
               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    18: BaseThreadInitThunk
    19: RtlUserThreadStart
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Do you actually see the header file in the mlir-c directory?

Ah wait. Now I can see your screenshot.

BTW, the issue seems to be happening in the mlir-sys crate. Can you reopen the same issue in its repository? Can you also try building only the mlir-sys crate?

oovm commented

image

Transfer can only be initiated by the owner

oovm commented

why my llvm-config --cxxflags use -std:c++17

outputs:

-IC:\Users\Dell\CLionProjects\llvm-project\llvm\include -IC:\Users\Dell\CLionProjects\llvm-project\llvm\out\build\x64-Release\include 
-std:c++17  /EHs-c- /GR- 
-D_CRT_SECURE_NO_DEPRECATE 
-D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE 
-D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

@oovm I'm not sure but it should be built into the binary at build time of LLVM. So some flags of CMake should have things to do with it.