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

support: use cgo to generate Go constants from eBPF #332

Merged
merged 3 commits into from
Jan 30, 2025
Merged

Conversation

florianl
Copy link
Contributor

Pragmatic approach to get rid of some CGO parts.

Creating just a draft atm to figure out details and more testing.

Fixes #331

support/helper.go Outdated Show resolved Hide resolved
@florianl florianl force-pushed the issue-331 branch 6 times, most recently from c6696f4 to 165a7c6 Compare January 30, 2025 08:14
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl marked this pull request as ready for review January 30, 2025 08:36
@florianl florianl requested review from a team as code owners January 30, 2025 08:36
@rockdaboot

This comment was marked as resolved.

@dmathieu
Copy link
Member

Probably for another PR, but shouldn't we have a CI check that runs make generate and verifies the GIT repository remains clean (to ensure the generated code is always up do date)?

support/generate.sh Outdated Show resolved Hide resolved
#!/usr/bin/env bash

set -eu

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Use a exit function for the cleanup like

function cleanup {
  # Clean up temporary files
  rm -rf _obj/ types_gen.go
}
trap cleanup EXIT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replacing a single line instruction with a multiple line alternative feels not right. Such clean up functions make sense, if they are more complex. But I don't see the need for this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just ended up too often after a failure or a ctrl-c with temporary files on my disk. It is a bit annoying and costs my time. A proper cleanup is good engineering practice.

Copy link
Member

@christos68k christos68k Jan 30, 2025

Choose a reason for hiding this comment

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

If the intermediate files are not useful for debugging failures (and they don't seem to be) let's add cleanup here like @rockdaboot suggests. The other option would be to add them to make clean.

EDIT: Actually maybe make clean is better as the intermediate files being present can speed up debugging a failure and updating support/types.go.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of interest, how often are you going to debug the constants so that it is worth it to always keep intermediate files? (My gut feeling says never)

@florianl
Copy link
Contributor Author

Probably for another PR, but shouldn't we have a CI check that runs make generate and verifies the GIT repository remains clean (to ensure the generated code is always up do date)?

This exists already. The Makefile target generate is executed as dependency of make test:

run: make test TARGET_ARCH=${{ matrix.target_arch }}

@dmathieu
Copy link
Member

Ah, sorry, I looked for make generate and missed that.

Makefile Show resolved Hide resolved
Copy link
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

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

Too bad that there is the -m64 when cross-compiling, so that this shell script is required 😞

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
#!/usr/bin/env bash

set -eu

Copy link
Member

@christos68k christos68k Jan 30, 2025

Choose a reason for hiding this comment

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

If the intermediate files are not useful for debugging failures (and they don't seem to be) let's add cleanup here like @rockdaboot suggests. The other option would be to add them to make clean.

EDIT: Actually maybe make clean is better as the intermediate files being present can speed up debugging a failure and updating support/types.go.

support/generate.sh Outdated Show resolved Hide resolved
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
@florianl florianl merged commit b86cd51 into main Jan 30, 2025
25 checks passed
@florianl florianl deleted the issue-331 branch January 30, 2025 15:14
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.

Can't import go.opentelemetry.io/ebpf-profiler/libpf with CGO_ENABLED=false
4 participants