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

new(build): add RelWithDebInfo target #3440

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shane-lawrence
Copy link
Contributor

@shane-lawrence shane-lawrence commented Dec 23, 2024

Signed-off-by: Shane Lawrence [email protected]

What type of PR is this?
/kind feature

Any specific area of the project related to this PR?
/area build

What this PR does / why we need it:
Debug binaries can behave differently from release binaries, which can make it hard to reproduce Release bugs in a Debug environment for certain edge cases. However, the release target doesn't produce debug symbols so it is difficult to trace certain kinds of bugs.

This PR adds the cmake-standard RelWithDebInfo target so we can create a binary that behaves exactly the same as the release target but has debug symbols available in a separate file.

Which issue(s) this PR fixes:
Fixes #2268.

Special notes for your reviewer:
This PR requires additional testing to ensure that the binary really is the same as the release binary. This first attempt might also need additional changes to conform to the existing style and good coding practices for this project.

Does this PR introduce a user-facing change?:
NO

NONE

@poiana
Copy link
Contributor

poiana commented Dec 23, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shane-lawrence
Once this PR has been reviewed and has the lgtm label, please assign lucaguerra for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shane-lawrence
Copy link
Contributor Author

I've only tried to remove debug symbols from the original binary, but I'm seeing a substantial change in file size compared to the release binary. Building with bundled deps and no specified CMAKE_BUILD_TYPE (defaults to Release), I get a userspace/falco/falco binary that's 398MB. Building with CMAKE_BUILD_TYPE=RelWithDebInfo, I get a userspace/falco/falco.debug file that's 222MB and a userspace/falco/falco binary that's 90% smaller at only 26MB. The binary seems to work the same though.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 2, 2025

Hi! Thanks for this PR! I really like the idea and i think we could start shipping (perhaps just as github release artifacts) the debug symbols files, wdyt?

Building with bundled deps and no specified CMAKE_BUILD_TYPE (defaults to Release), I get a userspace/falco/falco binary that's 398MB. Building with CMAKE_BUILD_TYPE=RelWithDebInfo, I get a userspace/falco/falco.debug file that's 222MB and a userspace/falco/falco binary that's 90% smaller at only 26MB. The binary seems to work the same though.

Mmmh the 0.39.2-x86_64 Falco released binary is:

du -h falco
25M	falco

thus we are pretty near.
Latest from master is instead 29.9 Mb but we switched to zig (that uses clang) thus a small difference is expected.

@shane-lawrence
Copy link
Contributor Author

Yes that would be great. Just need the symbols to come from the same build as the running binary to use them.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 3, 2025

Just need the symbols to come from the same build as the running binary to use them.

Yep exactly!
Sorry, why did you close this one? It seemed good to me :D

@shane-lawrence shane-lawrence reopened this Jan 3, 2025
@shane-lawrence
Copy link
Contributor Author

Oh, I closed it by mistake.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 3, 2025

That's a classic 🤣

@FedeDP
Copy link
Contributor

FedeDP commented Jan 7, 2025

Can you remove last commit?
Also, i will update the PR title to reflect our https://github.com/falcosecurity/.github/blob/main/CONTRIBUTING.md#commit-convention :)

@FedeDP FedeDP changed the title Add RelWithDebInfo target. new(build): add RelWithDebInfo target Jan 7, 2025
@FedeDP
Copy link
Contributor

FedeDP commented Jan 7, 2025

What i see is:

  • i test this one
  • we merge it
  • i'll open a PR to port our release pipeline to use the new target
  • i will also update the release workflow to upload the debug info artifacts

This is something that has been on my mind for so long, but never scratched my head around it :) Thank you so much!

/milestone 0.20.0 (wrong repo milestone 🤣 )

@poiana
Copy link
Contributor

poiana commented Jan 7, 2025

@FedeDP: The provided milestone is not valid for this repository. Milestones in this repository: [0.40.0, 0.41.0, 1.0.0, TBD]

Use /milestone clear to clear the milestone.

In response to this:

What i see is:

  • i test this one
  • we merge it
  • i'll open a PR to port our release pipeline to use the new target
  • i will also update the release workflow to upload the debug info artifacts

This is something that has been on my mind for so long, but never scratched my head around it :) Thank you so much!
/milestone 0.20.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 7, 2025

/milestone 0.40.0

@poiana poiana added this to the 0.40.0 milestone Jan 7, 2025
@@ -194,6 +194,24 @@ if(MUSL_OPTIMIZED_BUILD AND CMAKE_BUILD_TYPE STREQUAL "release")
)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo" AND NOT WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

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

So, what happens on win32 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll have to figure out how to do the equivalent of objcopy in Windows if we want to separate out the debug info properly. I'm only familiar with one way of doing so, and it only works with Visual Studio so I'd like to come up with a more generic method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the insight! For now it is not a big deal since we don't ship windows artifacts (ie: Falco is not officially distributed for windows; we only want to make sure that we build there), perhaps we can leave a TODO comment there?

@shane-lawrence
Copy link
Contributor Author

I had pushed the empty commit because one of the action runners timed out waiting for the job to start but I think it was a fluke. I've removed it now and rebased. I think that's a good idea to publish the artifact as part of the release workflow.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 8, 2025

Yes we are having issues with the arm64 cncf provided runners, that's not your fault :)

Signed-off-by: Shane Lawrence <[email protected]>
@shane-lawrence
Copy link
Contributor Author

I added a TODO comment for win32 and opened an issue to track it #3445. Is there anything else missing before we can merge this?

@leogr leogr requested review from FedeDP and LucaGuerra January 13, 2025 11:47
@FedeDP
Copy link
Contributor

FedeDP commented Jan 13, 2025

Nope, we just need to fix arm64 runners :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

RelWithDebInfo build
3 participants