hujun260 opened a new pull request, #21840:
URL: https://github.com/apache/nuttx/pull/21840
# NuttX PR Description
## Title
arm/clang.cmake: keep `-pg` out of link flags
## Description
This PR prevents the `-pg` profiling option from being passed to pure link
steps when building ARM targets with the Clang CMake toolchain.
## Problem
The `-pg` option affects compiler code generation and instrumentation. It is
not needed by a link-only command. Previously, the option was collected into
`NUTTX_EXTRA_FLAGS` and propagated to link commands.
Clang reports the option as unused during linking. Since the build inherits
`-Werror`, the warning becomes a build error:
```text
clang: warning: argument unused during compilation: '-pg'
[-Wunused-command-line-argument]
error: warnings treated as errors
```
## Changes
- Keep `-pg` in the compiler/code-generation flags.
- Remove or filter `-pg` from the flags used by pure link steps.
- Prevent Clang from reporting an unused `-pg` argument during linking.
- Allow ARM Clang CMake builds with profiling enabled to complete under
`-Werror`.
## Motivation
Fix ARM Clang CMake builds that enable profiling and treat warnings as
errors.
The change preserves profiling instrumentation during compilation while
preventing an invalid compiler-only option from reaching the linker.
## Build Testing
The affected ARM CMake build was tested with the GNU Arm Embedded target and
Clang toolchain configuration.
### Before the fix
```text
Configuration/Tool: ARM CMake target with profiling enabled
Linking NuttX...
clang: warning: argument unused during compilation: '-pg'
[-Wunused-command-line-argument]
cc1: warnings treated as errors
make: *** [link target] Error 1
```
### After the fix
```text
Configuration/Tool: ARM CMake target with profiling enabled
Configuring done
Generating done
Building NuttX...
Linking NuttX...
Build completed successfully
```
## Testing Status
- [x] Verified that `-pg` remains available for compiler code generation.
- [x] Verified that pure link commands do not receive `-pg`.
- [x] Verified that Clang no longer reports the unused-link-flag warning.
- [x] Verified that the build succeeds with warnings treated as errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]