mlua-rs / mlua

High level Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau bindings to Rust with async/await support
Other
1.64k stars 135 forks source link

Cross compile build error from mac aarch64 to windows x86_64 #328

Open tbillington opened 10 months ago

tbillington commented 10 months ago

Heya, apologies if this isn't the correct repo to open this, still figuring out how the build process works. It could also be in xwin or luau.

When building a binary for x86_64-pc-windows-msvc from aarch64-apple-darwin I get a number of errors that from what I can find online indicate the use of c++ features that the compiler doesn't support/hasn't got enabled. I'm running on Homebrew clang version 17.0.4. Is this something coming from the way luau is being vendored?

error: no template named 'optional' in namespace 'std' (full error line)

warning: In file included from /Users/choc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/luau0-src-0.7.8+luau601/luau/Ast/src/Ast.cpp:2:
warning: /Users/choc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/luau0-src-0.7.8+luau601/luau/Ast/include/Luau/Ast.h(376,46): error: no template named 'optional' in namespace 'std'
warning:   376 |         const AstName& debugname, const std::optional<AstTypeList>& returnAnnotation = {}, AstTypePack* varargAnnotation = nullptr,
warning:       |                                         ~~~~~^

...

error: failed to run custom build command for `mlua-sys v0.3.2`

Caused by:
  process didn't exit successfully: `/Users/choc/code/driving/target/debug/build/mlua-sys-086b5f599c374c51/build-script-main` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=build
  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 = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  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 = Some("--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared  ")
  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 = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  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 = Some("--target=x86_64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um /imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared  ")
  running: "clang-cl" "-nologo" "-MD" "-O2" "-Z7" "-Brepro" "-m64" "--target=x86_64-pc-windows-msvc" "-Wno-unused-command-line-argument" "-fuse-ld=lld-link" "/imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/crt/include" "/imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt" "/imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/um" "/imsvc/Users/choc/Library/Caches/cargo-xwin/xwin/sdk/include/shared" "-I" "/Users/choc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/luau0-src-0.7.8+luau601/luau/Ast/include" "-I" "/Users/choc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/luau0-src-0.7.8+luau601/luau/Common/include" "-DLUAI_MAXCSTACK=100000" "-DLUA_VECTOR_SIZE=3" "-Fo/Users/choc/code/driving/target/x86_64-pc-windows-msvc/debug/build/mlua-sys-bc87202e190734b8/out/luau-build/lib/1650a0a9048e3136-Ast.o" "-c" "--" "/Users/choc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/luau0-src-0.7.8+luau601/luau/Ast/src/Ast.cpp"
khvzak commented 10 months ago

I'll take a look! What x86_64-pc-windows-msvc toolchain do you use?

tbillington commented 10 months ago

I was trying with xwin, cargo xwin build --target=x86_64-pc-windows-msvc. Not for any particular reason though