tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Build error `tauri-macros`

Open xiaomin1123 opened this issue 3 years ago • 16 comments

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 avatar Jul 29 '22 03:07 xiaomin1123

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,

xiaomin1123 avatar Jul 29 '22 03:07 xiaomin1123

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.

FabianLars avatar Jul 29 '22 12:07 FabianLars

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,

  • Install msys2
  • Install GCC via pacman, pacman -S --needed base-devel mingw-w64-x86_64-toolchain
  • Install rust via pacman, pacman -S mingw-w64-x86_64-rust Be careful with the Path, if rustc works correctly, then,
  • In a IDE, like vs code, run "cargo install tauri-cli"
  • if successfully, run a simple project => cargo tauri init =>cargo tauri dev Here you'll find the compiler failed in compiling tauri-macros, due to the link table too long, over 2*16 -1 Change the optimatization level in cargo.toml [profile.dev.build-override] opt-level = 2 => run cargo build dev again Then it can compile successfully and pop up the widget. But if continue to build it by "cargo tauri build", it will fail again with the same link issue.

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

Regards, Xiaomin

xiaomin1123 avatar Jul 29 '22 12:07 xiaomin1123

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 avatar Jul 29 '22 13:07 FabianLars

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).

FabianLars avatar Jul 30 '22 09:07 FabianLars

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?

xiaomin1123 avatar Jul 30 '22 13:07 xiaomin1123

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

FabianLars avatar Jul 30 '22 14:07 FabianLars

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.

xiaomin1123 avatar Jul 30 '22 15:07 xiaomin1123

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

FabianLars avatar Jul 30 '22 15:07 FabianLars