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

Build in debug mode by default #15

Merged
merged 3 commits into from
Aug 18, 2021
Merged

Build in debug mode by default #15

merged 3 commits into from
Aug 18, 2021

Conversation

maximebedard
Copy link
Contributor

@maximebedard maximebedard commented Aug 12, 2021

Instead of always compiling in release mode and enabling all the optimizations, I'm compiling everything in debug instead. However, when compiling in debug mode, there's an assertion in wizer that gets tripped due to a bug in LLVM (see bytecodealliance/wizer#27). As a work-around, I'm using wasm-strip and wasm-opt directly on the engine during the build step.

We would have to figure out how we want to handle release builds, but I don't think they are necessary right now. This should make compile times much faster since we make better use of incremental builds.

@maximebedard maximebedard force-pushed the use-profile-env branch 4 times, most recently from ba6117a to 97b2a69 Compare August 12, 2021 15:10
@saulecabrera
Copy link
Member

saulecabrera commented Aug 12, 2021

We would have to figure out how we want to handle release builds, but I don't think they are necessary right now

They are not, but perhaps a custom script (make release) will suffice in which we build the crates in release mode, copy the resulting wasm (from quickjs-sys and core) into the cli and package that up.

EDIT: Sorry, I misunderstood what you meant by release build, I thought you were referring to releasing (distributing) the CLI, not the release profile for compiling.

let mut engine_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
engine_path.pop();
engine_path.pop();
let engine_path = engine_path.join("target/wasm32-wasi/debug/javy_core.wasm");
Copy link
Member

@saulecabrera saulecabrera Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the debug mode shouldn't be hardcoded here? Instead, it should be parametrized? Having the ability to specify release makes sense for benchmarking mostly (even if we are not concerned about actually releasing)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be helpful to locally install the cli too via cargo install --path crates/cli for local testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be configurable though and not necessarily rely on the build profile of a different crate. We could potentially just export a different env variable that points to the engine we want. WDYT?

Copy link
Member

@saulecabrera saulecabrera Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too, I believe that as long as we can build release and debug profiles without too much trouble we can go with whatever approach for now. If you feel that the env var works let's do that 👍

On a more personal note, I believe that artifact dependencies are a thing and should be the norm, in the same way that you depend on .a or .so files generated by other crates that are statically linked by a final executable for example. I hope that this rfc gets implemented soon which will make all this process easier and standard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point that I'm trying to make is, in which case would it make sense to have core be built in debug mode and the cli built in release mode or vice-versa? Even though core is not listed in the CLI's Cargo.toml as a dependency, it is still a dependency like any other, it's just that there's no standard way to express it. At least not until the RFC linked above is finalized. But again, we can use an env var if you feel that it's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with that RFC implemented in rust stable it would have made our lives much, much easier. For the meantime, I can still use the PROFILE env variable and hope that the crate has build this artifact properly first.

@@ -2,28 +2,32 @@
.DEFAULT_GOAL := cli

cli: core
cd crates/cli && cargo build --release
cd crates/cli && cargo build && cd -
Copy link
Member

@saulecabrera saulecabrera Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should put back the release option here? Maybe it's not as critical, I don't feel strongly but sometimes there's a need to check the release profile for debugging. Alternatively we can just manually run the commands, I believe that this is less critical than my comment above (about allowing to copy the release binary)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to build everything in debug mode for now, it just makes local development so much faster since we don't have to go through the many optimization layers.

@maximebedard
Copy link
Contributor Author

@saulecabrera all good if I merge this one as is right now? I think it's pretty much a noop right now, except I'm running the optimizations just in case at build time. It mainly just makes the build script a bit simpler at this point...

@maximebedard maximebedard merged commit af0de45 into main Aug 18, 2021
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

Successfully merging this pull request may close these issues.

2 participants