Skip to content

Refactor preprocessing arguments across toolchain configs#2530

Draft
brondani wants to merge 1 commit into
mainfrom
refactor-linker-script-preprocessing
Draft

Refactor preprocessing arguments across toolchain configs#2530
brondani wants to merge 1 commit into
mainfrom
refactor-linker-script-preprocessing

Conversation

@brondani

@brondani brondani commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Aligns with Open-CMSIS-Pack/cbuild2cmake#503

Changes

  • Refactor preprocessing command construction in the AC6, Clang, TI Clang, GCC, and XC toolchain CMake configurations by moving the -xc language option from the shared CPP_FLAGS variable into the linker script preprocessing command (CPP_ARGS_LD_SCRIPT).
  • Simplify predefined macro dump command definitions by removing the output file redirection/path from CPP_DUMP_MACROS in the AC6, Clang, TI Clang, GCC, XC, and IAR toolchain configurations, leaving only the compiler arguments.
  • Language-specific and common compiler options to macro dump commands will be handled in generated CMakeLists.

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

Risk / Follow-up

These changes affect how preprocessing commands are assembled for multiple supported toolchains. The primary risk is regressions in linker script preprocessing or predefined macro generation, so validating build generation across the affected toolchains is recommended.

@brondani brondani changed the title Refactor linker script preprocessing arguments across toolchain configs Refactor preprocessing arguments across toolchain configs Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.35%. Comparing base (dac8555) to head (d76669e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2530   +/-   ##
=======================================
  Coverage   65.35%   65.35%           
=======================================
  Files         147      147           
  Lines       26785    26785           
  Branches    16227    16227           
=======================================
  Hits        17506    17506           
  Misses       7074     7074           
  Partials     2205     2205           
Flag Coverage Δ
buildmgr-cov 79.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Test Results

  5 files   39 suites   3m 21s ⏱️
185 tests 168 ✅ 17 💤 0 ❌
509 runs  458 ✅ 51 💤 0 ❌

Results for commit d76669e.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors how C preprocessor-related command fragments are defined in the toolchain CMake config templates, aiming to centralize/standardize linker-script preprocessing and predefined-macro dump command construction across multiple toolchains (in line with related upstream work).

Changes:

  • Moves the -xc language selection out of shared CPP_FLAGS and into the linker-script preprocessing invocation (CPP_ARGS_LD_SCRIPT) for AC6, Clang, TI Clang, GCC, and XC.
  • Simplifies predefined-macro dump command fragments (CPP_DUMP_MACROS) by removing the output path handling from toolchain configs (IAR uses --predef_macros; others previously used > redirection).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/buildmgr/cbuildgen/config/XC.5.0.0.cmake Adjusts XC32 preprocessor flags and macro-dump command fragment.
tools/buildmgr/cbuildgen/config/IAR.9.32.1.cmake Simplifies IAR macro-dump command fragment by removing the output filename.
tools/buildmgr/cbuildgen/config/GCC.10.3.1.cmake Moves -xc to linker-script preprocessing args; updates macro-dump fragment.
tools/buildmgr/cbuildgen/config/CLANG.17.0.1.cmake Moves -xc to linker-script preprocessing args; updates macro-dump fragment.
tools/buildmgr/cbuildgen/config/CLANG_TI.4.0.1.cmake Moves -xc to linker-script preprocessing args; updates macro-dump fragment.
tools/buildmgr/cbuildgen/config/AC6.6.16.2.cmake Moves -xc to linker-script preprocessing args; updates macro-dump fragment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
set(CPP_ARGS_LD_SCRIPT "${CPP_FLAGS} -xc ${CPP_DEFINES} ${CPP_INCLUDES} \"${LD_SCRIPT}\" -o \"${LD_SCRIPT_PP}\"")
separate_arguments(CPP_ARGS_LD_SCRIPT NATIVE_COMMAND ${CPP_ARGS_LD_SCRIPT})
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - > \"${COMPILE_MACROS}\"")
set(CPP_DUMP_MACROS "${CPP_FLAGS} -dM - >")
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.

2 participants