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

[bug] Error while cross-compiling mac m1 -> windows-msvc #7816

Closed
pashokitsme opened this issue Sep 12, 2023 · 3 comments
Closed

[bug] Error while cross-compiling mac m1 -> windows-msvc #7816

pashokitsme opened this issue Sep 12, 2023 · 3 comments
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@pashokitsme
Copy link
Contributor

Describe the bug

I'm using xwin to cross-compile
When i run cargo tauri build --target x86_64-pc-windows-msvc --runner cargo-xwin it fails due to wrong clang arguments

Reproduction

  1. Minimal tauri project
  2. cargo tauri build --target x86_64-pc-windows-msvc --runner cargo-xwin

Expected behavior

No response

Platform and versions

[✔] Environment
    - OS: Mac OS 13.5.2 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.71.1 (eb26296b5 2023-08-03)
    ✔ Cargo: 1.71.1 (7f1d04c00 2023-07-29)
    ✔ rustup: 1.26.0 (2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.5.1
    - npm: 9.8.0

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.14
    - tauri-build [RUST]: 2.0.0-alpha.8
    - wry [RUST]: 0.33.0
    - tao [RUST]: 0.22.2
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.13

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

Running beforeBuildCommand `npm run build`

> vite-project@0.0.0 build
> tsc && vite build

vite v4.4.9 building for production...
transforming...
✓ 34 modules transformed.
rendering chunks...
computing gzip size...
dist/index.html                   0.46 kB │ gzip:  0.30 kB
dist/assets/react-35ef61ed.svg    4.13 kB │ gzip:  2.14 kB
dist/assets/index-d526a0c5.css    1.42 kB │ gzip:  0.74 kB
dist/assets/index-889552fa.js   143.40 kB │ gzip: 46.11 kB
✓ built in 415ms
   Compiling app v0.1.0 (/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri)
The following warnings were emitted during compilation:

warning: clang-16: warning: unknown argument ignored in clang-cl: '-xc' [-Wunknown-argument]
warning: clang-16: warning: '/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out/resource.rc' treated as the '/U' option [-Wslash-u-filename]
warning: clang-16: note: use '--' to treat subsequent arguments as filenames
warning: clang-16: error: no input files

error: failed to run custom build command for `app v0.1.0 (/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri)`

Caused by:
  process didn't exit successfully: `/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/release/build/app-c964aedc32e1a8f5/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=desktop
  cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX=test
  cargo:rustc-env=TAURI_TARGET_TRIPLE=x86_64-pc-windows-msvc
  package.metadata does not exist
  running: "clang-cl" "-nologo" "-MD" "-O2" "-Brepro" "-m64" "--target=x86_64-pc-windows-msvc" "-Wno-unused-command-line-argument" "-fuse-ld=lld-link" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/crt/include" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/um" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/shared" "-I" "/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out" "-xc" "-DRC_INVOKED" "-E" "/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out/resource.rc"
  cargo:warning=clang-16: warning: unknown argument ignored in clang-cl: '-xc' [-Wunknown-argument]

  cargo:warning=clang-16: warning: '/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out/resource.rc' treated as the '/U' option [-Wslash-u-filename]

  cargo:warning=clang-16: note: use '--' to treat subsequent arguments as filenames

  cargo:warning=clang-16: error: no input files

  exit status: 1

  --- stderr


  error occurred: Command "clang-cl" "-nologo" "-MD" "-O2" "-Brepro" "-m64" "--target=x86_64-pc-windows-msvc" "-Wno-unused-command-line-argument" "-fuse-ld=lld-link" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/crt/include" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/ucrt" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/um" "/imsvc/Users/pavel.smirnov/Library/Caches/cargo-xwin/xwin/sdk/include/shared" "-I" "/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out" "-xc" "-DRC_INVOKED" "-E" "/Users/pavel.smirnov/Source/temp/tauri-test/src-tauri/target/x86_64-pc-windows-msvc/release/build/app-1d3f597e4ba51def/out/resource.rc" with args "clang-cl" did not execute successfully (status code exit status: 1).


       Error failed to build app: failed to build app

Additional context

Funny, but it compiles if i create ln -s llvm-lib lib.exe and run cargo tauri build --target x86_64-pc-windows-msvc. With updater plugin it works when i run two commands in a row: without cargo-xwin and with. But anyway it's not correct behavior

@pashokitsme pashokitsme added status: needs triage This issue needs to triage, applied to new issues type: bug labels Sep 12, 2023
@FabianLars
Copy link
Member

I may be missing something but this sounds like a cargo-xwin issue to me, not tauri 🤔 Especially since our plain xwin guide still seems to work as far as i can tell https://tauri.app/v1/guides/building/cross-platform#experimental-build-windows-apps-on-linux-and-macos

(p.s. i can reproduce your issue on my machine too but no idea how to fix it)

@pashokitsme
Copy link
Contributor Author

pashokitsme commented Oct 19, 2023

Seems it happens somewhere around tauri_winres. Also, it reproducible by this:

// build.rs
fn main() {
    tauri_winres::WindowsResource::new().compile().unwrap()
}

Can embed-resource (dependency of tauri_winres) cause this error or this line isn't related to it?
And also, cargo-xwin does something with cmake files to fix issues like this one (but someone calls clang-cl, not cmake file)

@pashokitsme
Copy link
Contributor Author

Will be fixed by rust-lang/cc-rs#911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: macOS status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

3 participants