genodelabs / goa

Tool for streamlining the development of Genode applications
GNU Affero General Public License v3.0
19 stars 18 forks source link

goa: add optional --debug switch to produce debug build artifacts #64

Closed mewmew closed 9 months ago

mewmew commented 10 months ago

Implement debug build mode for the cargo build system.

Follow-up commits are expected to implement debug build mode for other build systems and programming languages (e.g. CMake and C/C++).

Also, add rust_debug example program for debugging Rust programs on Genode.

To run in release build mode, use 'goa run'

To run in debug build mode, use 'goa run --debug'

In the rust_debug demo, wait_for_continue is only invoked in debug build mode. Furthermore, in debug build mode, full debug info is included (e.g. Rust debug symbols).

jschlatow commented 10 months ago

@mewmew Thank you for opening this PR. I really like the idea of building binaries with debug symbols with Goa.

Looking at the cargo documentation, though, I sense that there are a lot more debug options. There are several variables modified by switching between the release and the dev profile and I have the feeling that mapping all these changes to a single --debug flag will not suffice for actual debugging. For instance, I often only need the debug symbols but do not want to change the optimisation level.

My gut feeling is that we could add the same functionality (but with more fine-grained control by the user) if we add support for a _cargoargs file (analogously to _makeargs and _cmakeargs). What do you think?

mewmew commented 10 months ago

Hi @jschlatow,

Thanks for the feedback!

I definitely agree that adding support for cargo_args would be very useful and would mirror the functionality of make_args and cmake_args in an intuitive way.

That being said, I don't think one has to exclude the other.

Personally, I believe the main strength of Goa is to provide sane default and make development fun.

To build a Goa project, just run goa build. Regardless of source language and compiler setup.

Want to run a Goa project, just run goa run.

Want to publish a Goa project, just run goa publish.

Having something along the lines of goa debug would make sense, as it is such a common development use-case.

And not having to read up on what make_args, cmake_args and cargo_args to use to get a sane default for debugging would be a huge benefit to the "joy of coding".

Since wanting to include debug symbols is such a common wish when debugging, having a --debug switch in Goa that provides sane defaults for all supported programming language and build systems would make the Goa build system really joyful to use.

Exactly what those "sane defaults" are, we can discuss and agree upon the specifics (for each language and build system pair). But having a very easy way to toggle release vs. debug build is a great feature to add to Goa.

Another aspect is that it is very common to want to switch between release builds and debug builds. And having a simple flag to toggle that is ideal. If we had say a cargo_args file in the root of the repository, then we'd have to either temporarily remove the file or edit it to comment out various arguments to switch between release and debug builds.

So, in favour of "joyful development" I would very much favour having both support for a --debug switch in Goa, and having support for more fine-grained cargo_args when deemed necessary (e.g. to add debug symbols but still use -O2).

Would be happy to continue the discussion : )

Including Norman in the discussion too, as Goa is his baby. cc: @nfeske

Cheers, Robin

jschlatow commented 10 months ago

@atopia Thanks for your review.

@mewmew I very much agree with your line of thought. I would love to see a goa debug command in the future. Would you mind documenting the cargo-specific implications of the --debug flag in the build-systems.txt. I think it could be helpful for developers to know that it switches to the dev profile.

mewmew commented 10 months ago

Thanks a lot for your contribution, apart from a few nitpicks this looks good to me.

Great! Thanks for the review feedback @atopia. I've updated the PR to fix your nitpicks : )

mewmew commented 10 months ago

@atopia Thanks for your review.

@mewmew I very much agree with your line of thought. I would love to see a goa debug command in the future. Would you mind documenting the cargo-specific implications of the --debug flag in the build-systems.txt. I think it could be helpful for developers to know that it switches to the dev profile.

Wonderful! I've added some updated docs about the dev profile. Let me know if it looks good or needs to be rephrased somehow (ref: 0dd3c6364de7ef25145c7d927086c16761ded835).

Cheers, Robin

jschlatow commented 10 months ago

@mewmew While testing your changes, I noticed that the binary is not automatically rebuilt when changing between goa build and goa build --debug. Do you have an idea how this could be achieved?

atopia commented 10 months ago

Strange, for me cargo rebuilds the respective release or debug binary when running goa build or goa build --debug.

jschlatow commented 10 months ago

@atopia You are right. I must have missed the corresponding messages.

mewmew commented 10 months ago

@atopia You are right. I must have missed the corresponding messages.

Yeah. It rebuilds on my end too when switching between goa build and goa build --debug.

jschlatow commented 9 months ago

@mewmew I merged your commits to staging with adapted commit titles (to fit the recommended limit of 50 characters). I also added a few minor style fixups and added support for the --debug switch to make, cmake and qmake.

mewmew commented 9 months ago

@mewmew I merged your commits to staging with adapted commit titles (to fit the recommended limit of 50 characters). I also added a few minor style fixups and added support for the --debug switch to make, cmake and qmake.

Wonderful! Thanks a lot @jschlatow and @atopia for reviewing the PR and improving it : ) I also learnt a lot (e.g. no need to link against ld.lib.so when including base in used_api).

Cheerful regards and happy coding (and debugging : ), Robin