[wip] Add builtin debugtrap target verification script#1740
[wip] Add builtin debugtrap target verification script#1740luoliwoshang wants to merge 3 commits intogoplus:mainfrom
Conversation
Summary of ChangesHello, 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 introduces a new verification script aimed at ensuring the consistent and correct compilation of the 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. Ignored Files
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a verification script for __builtin_debugtrap() across various targets. The script is well-designed, leveraging a mix of Bash and an embedded Python script for handling target configurations. My review highlights a few opportunities to enhance the script's portability and maintainability. Specifically, I've pointed out a hardcoded path that limits portability, an unnecessary directory change that could affect robustness, and some code duplication that can be refactored. These changes will make the script more robust and easier to maintain.
|
|
||
| SYS_CLANG="${CLANG:-clang}" | ||
| ESP_CLANG_DEFAULT="${HOME}/Library/Caches/llgo/crosscompile/esp-clang-19.1.2_20250905-3/bin/clang" | ||
| ESP_CLANG="${ESP_CLANG:-${ESP_CLANG_DEFAULT}}" |
There was a problem hiding this comment.
The use of ESP_CLANG_DEFAULT makes the script non-portable due to its hardcoded macOS path on line 26. It's better to default to esp-clang and let it be found in the PATH, which is more robust and consistent with how SYS_CLANG is handled. Please remove line 26 and apply the suggested change to this line.
| ESP_CLANG="${ESP_CLANG:-${ESP_CLANG_DEFAULT}}" | |
| ESP_CLANG="${ESP_CLANG:-esp-clang}" |
| print("\t".join([name, llvm_target, cpu, features])) | ||
| PY | ||
|
|
||
| cd "${REPO_ROOT}" |
There was a problem hiding this comment.
| if [[ -n "${cpu}" ]]; then | ||
| if [[ "${llvm_target}" == avr* ]]; then | ||
| asm_flags=(-mmcu="${cpu}" "${asm_flags[@]}") | ||
| ir_flags=(-mmcu="${cpu}" "${ir_flags[@]}") | ||
| else | ||
| asm_flags=(-mcpu="${cpu}" "${asm_flags[@]}") | ||
| ir_flags=(-mcpu="${cpu}" "${ir_flags[@]}") | ||
| fi | ||
| fi | ||
|
|
||
| case "${llvm_target}" in | ||
| avr*) | ||
| asm_flags=(-mdouble=64 "${asm_flags[@]}") | ||
| ir_flags=(-mdouble=64 "${ir_flags[@]}") | ||
| ;; | ||
| riscv32-esp-elf) | ||
| asm_flags=(-march=rv32imc -fforce-enable-int128 "${asm_flags[@]}") | ||
| ir_flags=(-march=rv32imc -fforce-enable-int128 "${ir_flags[@]}") | ||
| ;; | ||
| riscv32-*) | ||
| asm_flags=(-march=rv32imac -fforce-enable-int128 "${asm_flags[@]}") | ||
| ir_flags=(-march=rv32imac -fforce-enable-int128 "${ir_flags[@]}") | ||
| ;; | ||
| riscv64-*) | ||
| asm_flags=(-march=rv64gc "${asm_flags[@]}") | ||
| ir_flags=(-march=rv64gc "${ir_flags[@]}") | ||
| ;; | ||
| esac |
There was a problem hiding this comment.
The logic for adding compiler flags is duplicated for asm_flags and ir_flags throughout this block. This can be simplified and made more maintainable by using a helper function to add flags to both arrays at once.
For example, you could define a function at the top of the script:
add_flags() {
asm_flags= ("$@" "${asm_flags[@]}")
ir_flags= ("$@" "${ir_flags[@]}")
}And then use it within this block to reduce duplication, like so:
if [[ -n "${cpu}" ]]; then
if [[ "${llvm_target}" == avr* ]]; then
add_flags "-mmcu=${cpu}"
else
add_flags "-mcpu=${cpu}"
fi
fi
Summary
__builtin_debugtrap()verification script that walkstargets/*.jsoninheritsso each target is checked against its effective codegen configurationSKIPwith an explicit reasonVerification
bash _demo/embed/targetsbuild/verify_builtin_debugtrap.sh esp32 nrf51-s110v8 atmega328pbash _demo/embed/targetsbuild/verify_builtin_debugtrap.shNotes