tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.65k stars 2.37k forks source link

[bug] Build error `tauri-macros` #4794

Open xiaomin1123 opened 1 year ago

xiaomin1123 commented 1 year ago

Describe the bug

In command "Cargo tauri dev", it failed at compiling tauri-macros error: export ordinal too large: 68600 collect2.exe: error: ld returned 1 exit status

error: could not compile tauri-macros due to previous error

After changed the "Cargo.toml" with [profile.dev.build-override] opt-level = 2

It can solve this issue in "dev". But it will happen again in releasing with command "Cargo tauri build"

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment › OS: Windows 10.0.19042 X64 › Webview2: 103.0.1264.71 › MSVC: › Node.js: Not installed! › npm: Not installed! › pnpm: Not installed! › yarn: Not installed! › rustup: Not installed! › rustc: 1.62.0 › cargo: 1.62.0 › Rust toolchain:

I don't know why here doesn't show the rust toolchain. The toolchain I used is x86-64-windows-gnu. The GCC is installed through msys2.

Stack trace

No response

Additional context

No response

xiaomin1123 commented 1 year ago

version of tauri

› @tauri-apps/cli [NPM]: 1.0.5 › @tauri-apps/api [NPM]: Not installed! › tauri [RUST]: 1.0.5, › tauri-build [RUST]: 1.0.4, › tao [RUST]: 0.12.2, › wry [RUST]: 0.19.0,

FabianLars commented 1 year ago

we officially only support the msvc toolchain (you probably will run into other errors with gnu after this one), so if it's possible for you to use that, i'd suggest using that instead. It's generally considered the better one in the rust world anyway 🤷

Apart from this, the whole output of tauri info (as requested) may be helpful to double check your config. A common issue is a misconfigured devPath/distDir which can make it copy too many unwanted files into the binary, but normally the error for that would look different. Other than this i don't think we can help you without a reproduction example, because you're the first one reporting this issue.

I don't know why here doesn't show the rust toolchain

Because it wasn't installed via rustup which we use to identify it iirc.

xiaomin1123 commented 1 year ago

we officially only support the msvc toolchain (you probably will run into other errors with gnu after this one), so if it's possible for you to use that, i'd suggest using that instead. It's generally considered the better one in the rust world anyway 🤷

Apart from this, the whole output of tauri info (as requested) may be helpful to double check your config. A common issue is a misconfigured devPath/distDir which can make it copy too many unwanted files into the binary, but normally the error for that would look different. Other than this i don't think we can help you without a reproduction example, because you're the first one reporting this issue.

I don't know why here doesn't show the rust toolchain

Because it wasn't installed via rustup which we use to identify it iirc.

Hello FabianLars,

Thank you for the reply. It can be reproduced by below steps,


I hope this issue can be solved for GCC toolchain. 😊 I don't have an access to MSVC.

Regards, Xiaomin

FabianLars commented 1 year ago

Install rust via pacman, pacman -S mingw-w64-x86_64-rust

Can you try installing rust via rustup instead? Because i can't reproduce your issue right now with that (= it compiles fine for me with the gnu toolchain installed via rustup). I can try installing rust via pacman later today, to see if i can repro it with that.

FabianLars commented 1 year ago

Someone else reported the issue in #4798 too, but it looks like they use the gnu toolchain installed via rustup. There goes my theory then 😢 Still no idea how to reproduce this on my end (i did everything as described).

xiaomin1123 commented 1 year ago

I used a new enviroment and reproduced it with rustup toolchain. it failed at compiling tauris-macros also ` error: export ordinal too large: 66355 collect2.exe: error: ld returned 1 exit status

error: could not compile tauri-macros due to previous error`

Here's the enviroment `Environment › OS: Windows 10.0.22621 X64 › Webview2: 103.0.1264.71 › MSVC: › Node.js: Not installed! › npm: Not installed! › pnpm: Not installed! › yarn: Not installed! › rustup: 1.24.3 › rustc: 1.62.1 › cargo: 1.62.1 › Rust toolchain: stable-x86_64-pc-windows-gnu

Packages WARNING: no lock files found, defaulting to npm › @tauri-apps/cli [NPM]: 1.0.5 › @tauri-apps/api [NPM]: Not installed! › tauri [RUST]: 1.0.5, › tauri-build [RUST]: 1.0.4, › tao [RUST]: 0.12.2, › wry [RUST]: 0.19.0,`

It looks like to be a comman issue I think. @FabianLars Could you please show me your enviroment when you running it with gnu toolchain?

FabianLars commented 1 year ago

I just tested it on a completely different computer, and here's the env from that one

Environment
  › OS: Windows 10.0.19043 X64
  › Webview2: 103.0.1264.77
  › MSVC:
  › Node.js: 16.16.0
  › npm: 8.11.0
  › pnpm: 7.7.1
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.62.1
  › cargo: 1.62.1
  › Rust toolchain: stable-x86_64-pc-windows-gnu

Packages
  › @tauri-apps/cli [NPM]: 1.0.5
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.5,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.2,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: ../dist

App directory structure
  ├─ dist
  ├─ node_modules
  └─ src-tauri
xiaomin1123 commented 1 year ago

emm, I have no idea. What's the gcc version then? Here's my, gcc (Rev3, Built by MSYS2 project) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

FabianLars commented 1 year ago

I have the same version. I just installed it on that system so everything should be at the latest version.