Skip to content

With PicoLibC the SCA CodeChecker/clang-tidy fails for target efr32bg22_brd4184a. #62278

@kmeinhar

Description

@kmeinhar

Describe the bug
With the step to set PicoLibC as default LibC the SCA CodeChecker fails for target efr32bg22_brd4184a.
clang-tidy fails with error error: unknown argument: '-fno-printf-return-value' [clang-diagnostic-error].
This flag is not supported by Clang and is removed when compiling with Clang: https://github.com/zephyrproject-rtos/zephyr/blob/main/cmake/compiler/clang/compiler_flags.cmake#L11

CodeChecker starts clang-tidy with options in ${CMAKE_BINARY_DIR}/compile_commands.json.
It includes the GCC specific flag -fno-printf-return-value.

To Reproduce

CodeChecker and clang-tidy succeed with:

  • west build -b efr32bg22_brd4184a -d build_hello_world zephyr/samples/hello_world -p -- -DZEPHYR_SCA_VARIANT=codechecker -DCONFIG_MINIMAL_LIBC=y

CodeChecker and clang-tidy fail with:

  • west build -b efr32bg22_brd4184a -d build_hello_world zephyr/samples/hello_world -p -- -DZEPHYR_SCA_VARIANT=codechecker -DCONFIG_PICOLIBC=y

Expected behavior
clang-tidy is called without flag -fno-printf-return-value.

Logs and console output

[ERROR 2023-09-05 11:10] -                                                                                                                                                         
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing rb.c with clangsa  failed!                                                                                                                                                                                                                                                                                                       
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] - Analyzing main.c with clangsa  failed!                                                                                                                                                                                                                                                                                                     
[ERROR 2023-09-05 11:10] -                                                                                                                                                         
                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] -                                                                                                                                                         
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] - Analyzing printk.c with clangsa  failed!                                                                                                                                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing hex.c with clangsa  failed!                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing sem.c with clangsa  failed!                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing fdtable.c with clangsa  failed!                                                                                                                                                                                                                                                                                                  
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing dec.c with clangsa  failed!                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] - Analyzing heap.c with clangsa  failed!                                                                                                                                                                                                                                                                                                     
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                   
[ERROR 2023-09-05 11:10] -                                                                                                                                                                                                                                                                                                                                            
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                      
[ERROR 2023-09-05 11:10] -                                                                                                                                                         
clang-15: error: unknown argument: '-fno-printf-return-value'                                                                                                                                                                                                                                                                                                         

Additional context

Related to #54345

clang-tidy has the flag --extra-arg=<string>. But as far as I can tell this does not make it possible to remove compiler flags imported from compile_commands.json.

Metadata

Metadata

Assignees

Labels

Stalearea: picolibcPicolibc C Standard LibrarybugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions