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

Disabling optimizations for specific packages in Cargo.toml? #83

Closed
adundovi opened this issue Nov 28, 2021 · 14 comments
Closed

Disabling optimizations for specific packages in Cargo.toml? #83

adundovi opened this issue Nov 28, 2021 · 14 comments

Comments

@adundovi
Copy link
Contributor

adundovi commented Nov 28, 2021

Describe the bug
I've encountered the following bug in Rust, i.e., when building a package with perseus build (or serve or test), the "Building your app to Wasm..." step never ends (finally being killed by the OOM killer). It only happens for the --release target of wasm32, not for x86_64 and wasm32 without --release.

A workaround for this bug is to disable optimizations for fluent-bundle.

How do I specify opt-level = 0 for the fluent-bundle package in Cargo.toml so that perseus-cli picks it up and builds the package with the option present? I tried just putting in Cargo.toml, but it didn't work. It would be great to see in Perseus' docs how to do this...

Environment:

  • Perseus Version: 0.3.0-beta.17
  • Sycamore Version: 0.6
  • OS: Linux
@adundovi
Copy link
Contributor Author

Adding

[profile.release.package]
fluent-bundle = { opt-level = 2 }

in .perseus/Cargo.toml works as the mentioned workaround, but I wouldn't like to modify the .perseus directory manually.

@phaleth
Copy link
Contributor

phaleth commented Nov 28, 2021

As far as optimizations are concerned I'd think the --release flag is one of the gotchas.

I suggest dropping the --release flag completely as hinted here #52 (comment).

In case you want to avoid modifying .perseus/ dir contents you can use the perseus-size-opt plugin as demonstrated here #69 (comment).

Also, please, next time specify at least your linux distro.

@adundovi
Copy link
Contributor Author

Hmm, to me it looks like the --release flag is always on, whether I pass --release to build/serve/export or not.

@arctic-hen7
Copy link
Member

@adundovi I think this should probably be an issue on the size optimizations plugin, as Perseus itself is agnostic about how you perform optimizations. I could also create another plugin, but I think the simplest thing is just to patch the size optimizations plugin to perform that workaround.

@adundovi
Copy link
Contributor Author

@arctic-hen7 thanks for the feedback. Are the perseus plugins listed somewhere?

@arctic-hen7
Copy link
Member

Yes! See the Plugins section on the website. (At the moment there's only one...)

arctic-hen7 added a commit to arctic-hen7/perseus-size-opt that referenced this issue Dec 2, 2021
This prevents the infinite compiling problem described [here](framesurge/perseus#83).
@arctic-hen7
Copy link
Member

Okay, the size optimizations plugin now has this patch inbuilt unless the default_2018() function is used (seeing as this only seems to affect Rust 2021). @adundovi I would recommend using v0.1.4 of that plugin to perform your size optimizations for you, and this error should then no longer be a problem! Please let me know if that's not the case and I'll reopen this issue.

@adundovi
Copy link
Contributor Author

adundovi commented Dec 5, 2021

Hi @arctic-hen7, thank you for the plugin and for including the workaround in the plugin by default.

May I just note that I have to change the prescribed line on how to use the plugin into:

plugins: Plugins::new().plugin(|| perseus_size_opt(), SizeOpts::default())

since otherwise, I cannot compile:

plugins: Plugins::new().plugin(perseus_size_opt(), SizeOpts::default() )
                        expected an `Fn<()>` closure, found `Plugin<_, SizeOpts>`

@arctic-hen7
Copy link
Member

arctic-hen7 commented Dec 5, 2021

Ah! Yes, sorry, that's an issue in the docs for the plugin. You don't need a closure, just use perseus_size_opt without the brackets. There's an example here.

@adundovi
Copy link
Contributor Author

adundovi commented Dec 6, 2021

Eh, yes, you're right, and it makes perfect sense. (me embarrassed)

@adundovi
Copy link
Contributor Author

adundovi commented Dec 6, 2021

Hmm, does not work after perseus clean.

@arctic-hen7
Copy link
Member

Have you run perseus tinker afterward?

@adundovi
Copy link
Contributor Author

adundovi commented Dec 6, 2021

No, I forgot. Afterward, it worked. Thank you.

@arctic-hen7
Copy link
Member

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants