[wip] esp32c3 println path + linker map output#1619
[wip] esp32c3 println path + linker map output#1619luoliwoshang wants to merge 1 commit intoxgo-dev:mainfrom
Conversation
Summary of ChangesHello @luoliwoshang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the build system by adding support for generating linker map files, which are crucial for debugging and optimizing binary sizes in embedded systems. Concurrently, it addresses a critical issue with Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two main enhancements: the ability to generate a linker map file via a -map flag, and a platform-specific implementation for println on esp32c3 baremetal targets. The changes are well-structured and include relevant unit tests for the new linker flag functionality. The println refactoring correctly uses build tags to separate platform-specific code.
I have one suggestion to improve the efficiency of the new printByte implementation for the esp target by avoiding repeated stack allocations. Overall, this is a solid contribution.
| func printByte(v byte) { | ||
| ch := v | ||
| c.Write(stderrFD, c.Pointer(&ch), 1) | ||
| } |
There was a problem hiding this comment.
The current implementation of printByte allocates a new variable ch on the stack for every byte printed. While this is safe, it can be inefficient if printByte is called within a tight loop. To improve performance, you could use a package-level buffer to avoid repeated stack allocations. Since this is for a baremetal target, concurrency is not a concern for a package-level variable.
var printByteBuf [1]byte
func printByte(v byte) {
printByteBuf[0] = v
c.Write(stderrFD, c.Pointer(&printByteBuf[0]), 1)
}| @@ -0,0 +1,110 @@ | |||
| package build | |||
There was a problem hiding this comment.
Minor: Consider adding a license header to this test file for consistency with other test files in the directory (e.g., cache_test.go, fingerprint_test.go).
| {name: "derive from cc", linker: "", cc: "clang++", want: true}, | ||
| {name: "derive ld from cc", linker: "", cc: "ld.lld", want: false}, | ||
| } | ||
|
|
There was a problem hiding this comment.
The test coverage for useCompilerDriverMapFlags could be improved. Consider adding test cases for:
g++variants (testsstrings.HasSuffix(base, "g++")branch):
{name: "g++ linker", linker: "g++", cc: "", want: true},
{name: "cross g++ linker", linker: "arm-none-eabi-g++", cc: "", want: true},- Additional CC fallback scenarios:
{name: "derive gcc from cc", linker: "", cc: "gcc", want: true},
{name: "derive g++ from cc", linker: "", cc: "g++", want: true},
Code Review SummaryOverall: Clean implementation that follows existing codebase patterns well. The Strengths:
Minor suggestions: See inline comments for missing test cases for No security or performance concerns identified. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1619 +/- ##
==========================================
- Coverage 91.06% 91.04% -0.02%
==========================================
Files 45 45
Lines 11938 11917 -21
==========================================
- Hits 10871 10850 -21
Misses 892 892
Partials 175 175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
-mapbuild flag to emit linker map files (supports explicit path andauto)runtime.PrintString/PrintBytethrough platform-specific helpersbaremetal && esp, send println output viaC.write(fd=2) to avoid stdio path issuesValidation
go test ./internal/build -run "Test(UseCompilerDriverMapFlags|ResolveLinkMapArgs)$"llgo build -a -target=esp32c3 _demo/embed/esp32c3/printlnprintln("Hello")now printsHello, then exits via_exitpanic path (current runtime behavior)