Replace obi-genfiles with Makefile-based code generation#1290
Conversation
cmd/obi-genfiles with direct makeobi-genfiles with Makefile-based code generation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1290 +/- ##
==========================================
- Coverage 43.41% 43.40% -0.02%
==========================================
Files 304 304
Lines 32779 32779
==========================================
- Hits 14232 14228 -4
- Misses 17630 17632 +2
- Partials 917 919 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR removes the custom obi-genfiles generator tool and shifts eBPF code generation to a Makefile-driven workflow (including Docker-based generation), aiming to simplify the architecture and improve incremental rebuild performance.
Changes:
- Removed
cmd/obi-genfilesand its environment-variable-driven orchestration logic. - Added Makefile targets for incremental generation (
generate), forced regeneration (generate/all), and containerized generation (docker-generate) using bpf2go.ddependency files. - Updated the generator container to run
make generateand updated.gitignoreto exclude generated.dfiles.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| generator.Dockerfile | Simplifies the generator image to run make generate instead of building/running obi-genfiles. |
| cmd/obi-genfiles/obi_genfiles.go | Removes the bespoke generator implementation (file deleted). |
| Makefile | Introduces Make-based incremental dependency tracking for eBPF codegen and updates Docker generation target. |
| .gitignore | Ignores generated .d dependency files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
rafaelroquetto
left a comment
There was a problem hiding this comment.
Niceeee! Thanks for doing this. obi-genfiles is a relic from that time in which we were experimenting with generating .o files directly into the OBI/Beyla package root (to avoid committing .o files to the repo) so it had to do some gymnastics to be able to write to Go modules and the likes. It no longer serves its purpose.
This is much better, cleaner and simpler (and faster!!)
mariomac
left a comment
There was a problem hiding this comment.
Looks good! Thanks for doing
If there are no existing bpf generated files (i.e. a new clone or cleaned repository), defer the generate command to generate/all so all the files are first created.
Document parallel build issues.
|
The CI failures should get fixed once we merge the PR from @skl. I'm watching for it to finish CI and I'll merge. |
This target was used to ensure the github.com/cilium/ebpf package version was the same in the generator as that used locally. This was made unneeded in open-telemetry#1290.
The
obi-genfilescommand is superfluous, its complexity can be simplified into direct use ofmakebased commands. Other OpenTelemetry projects like opentelemetry-go-instrumentation run generation entirely usingmake, providing a simpler and more maintainable approach. This PR aligns OBI with that established pattern.Changes
Removed
cmd/obi-genfiles/OTEL_EBPF_GENFILES_*)Added/Modified
generatetarget: Smart incremental builds using Make's dependency systemgenerate/alltarget: Force regeneration (for clean repos or CI)docker-generatetarget: Simplified Docker-based generationBPF2GO_MAKEBASEexport: Enables bpf2go to generate Make-compatible dependency files (.dfiles).dfilesmake generateBenefits
1. Dramatically Faster Incremental Builds
make generatetook ~60 seconds (always regenerated everything)make generatetakes ~0.05 seconds when nothing changed (1200x faster)2. Smart Dependency Tracking
The system now tracks source dependencies via
.dfiles generated by bpf2go:3. Parallel Execution Support
$ make -j4 generate # 28.5s (287% CPU) vs 60s sequential (2x faster)4. Simpler Architecture
5. Single-Target Docker Generation
$ make docker-generate # Just works, no environment variables neededValidation
✅ Clean Repository (git clean -dxf scenario)
✅ Incremental Builds
✅ Dependency Tracking
24
.dfiles generated locally, providing accurate source dependency information✅ Backward Compatibility
make docker-generatecontinues to work (mounts workspace, runs generation in container)//go:generatedirectives unchangedTesting Performed
make generate/all)make generate)make -j4 generate)make docker-generate)