如何在 Cargo.toml 中启用 --gc-targets? [英] How can I enable --gc-targets in my Cargo.toml?

查看:85
本文介绍了如何在 Cargo.toml 中启用 --gc-targets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 wasm-gc 中的存档通知,

According to the archival notice in wasm-gc,

wasm-pack(和 wasm-bindgen)项目已经默认为您运行 [--gc-targets],因此无需再次运行.

The wasm-pack (and wasm-bindgen) project will already run [--gc-targets] by default for you, so there's no need to run it again.

我们如何在 Cargo.toml 中明确指定它?

How do we specify this in Cargo.toml explictly?

推荐答案

Rustc 传递参数

-C, --codegen OPT[=VALUE]
                    Set a codegen option

你想要的代码生成选项 link-arg 所以你可以像 -C link-arg=--gc-targets 一样使用它,你可以在 Cargo.toml 中设置它与,

The codegen option you want link-arg so you'd use it like -C link-arg=--gc-targets you can set that up in your Cargo.toml with,

[[bin]]
rustflags = [
  "-C", "link-arg=--gc-targets",
]

或者,您现在可以直接使用新的 Cargo 中的实验性extra-link-arg 选项.

Alternatively, you can now set this up directly with the new experimental extra-link-arg option in Cargo.

这篇关于如何在 Cargo.toml 中启用 --gc-targets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆