Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/arm/gcc: disable coverage analysis temporarily #7409

Merged
merged 1 commit into from Oct 24, 2022

Conversation

anchao
Copy link
Contributor

@anchao anchao commented Oct 24, 2022

Summary

boards/arm/gcc: disable coverage analysis temporarily

Please revert this change if arm resolved this issue in the next release

ARM GNU toolchain 11.3.Rel1 missing gcov_* symbols:

https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53354/arm-gnu-toolchain-11-3-rel1-missing-gcov_-symbols

$ arm-none-eabi-gcc -v

...
gcc version 11.3.1 20220712 (Arm GNU Toolchain 11.3.Rel1)

$ cat main.c

int __start(void)
{
  return 0;
}

Compiler with arm GCC-11.3:

$ arm-none-eabi-gcc -c -Wstrict-prototypes -Os -fno-strict-aliasing -fomit-frame-pointer -fprofile-generate \ -ftest-coverage -mthumb --coverage -fno-common -Wall -Wshadow -Wundef -ffunction-sections -fdata-sections -g \ -mlittle-endian -mcpu=cortex-m0 -mthumb -mfloat-abi=soft main.c -o main.o
$ arm-none-eabi-ld --entry=__start -nostdlib --gc-sections -Tpimoroni-tiny2040-flash.ld -o test_gcov --start-group main.o \ ~/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v6-m/nofp/libgcov.a --end-group arm-none-eabi-ld: main.o: in function `__start':
/home/archer/code/nuttx/n4/incubator-nuttx/main.c:2: undefined reference to `__gcov_indirect_call_profiler_v4' 
arm-none-eabi-ld: /home/archer/code/nuttx/n4/incubator-nuttx/main.c:4: undefined reference to `__gcov_indirect_call' 
arm-none-eabi-ld: /home/archer/code/nuttx/n4/incubator-nuttx/main.c:4: undefined reference to `__gcov_time_profiler_counter'

link success with arm GCC-10.3:

$ arm-none-eabi-ld --entry=__start -nostdlib --gc-sections -Tpimoroni-tiny2040-flash.ld -o test_gcov --start-group main.o \ ~/lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/libgcov.a --end-group
$ ls -l test_gcov
-rwxrwxr-x 1 archer archer 68744 10月 24 12:51 test_gcov

Signed-off-by: chao an anchao@xiaomi.com

Impact

$ arm-none-eabi-gcc -v
...
gcc version 11.3.1 20220712 (Arm GNU Toolchain 11.3.Rel1)

Testing

CI- check

@pkarashchenko
Copy link
Contributor

Anyway I still think that we are too fast with toolchain upgrade, but I'm more conservative. Do we have a significant gain in optimisation with new compiler? Or what is the rush here?

@anchao
Copy link
Contributor Author

anchao commented Oct 24, 2022

Anyway I still think that we are too fast with toolchain upgrade, but I'm more conservative. Do we have a significant gain in optimisation with new compiler? Or what is the rush here?

The new toolchain adds more static analyzer on compile stage, which will helpful for code quality:
https://gcc.gnu.org/gcc-11/changes.html
img_v2_5edc10d7-b3cb-4363-ac37-4cebf16c548l

For example:

    if (focus != NULL) {
        nxipc_client_disconnect(focus->send_proxy);
        nxipc_sub_disconnect(focus->receive_proxy);
        free((void*)focus->name);
        free((void*)focus);
        pthread_mutex_destroy(&focus->mutex);   <--  use-after-free
    }

build will break on gcc-11.3 ([-Werror=use-after-free])

../common/src/client/app_focus_c.c: In function 'app_focus_release':
../common/src/client/app_focus_c.c:157:9: error: pointer 'handle' used after 'free' [-Werror=use-after-free]
  157 |         pthread_mutex_destroy(&focus->mutex);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../common/src/client/app_focus_c.c:156:9: note: call to 'free' here
  156 |         free((void*)focus);
      |         ^~~~~~~~~~~~~~~~~~

**Please revert this change if arm resolved this issue in the next release**

ARM GNU toolchain 11.3.Rel1 missing gcov_* symbols:

https://community.arm.com/support-forums/f/compilers-and-libraries-forum/53354/arm-gnu-toolchain-11-3-rel1-missing-gcov_-symbols

$ arm-none-eabi-gcc -v
...
gcc version 11.3.1 20220712 (Arm GNU Toolchain 11.3.Rel1)

$ cat main.c
int __start(void)
{
  return 0;
}

Compiler with arm GCC-11.3:

$ arm-none-eabi-gcc -c -Wstrict-prototypes -Os -fno-strict-aliasing -fomit-frame-pointer -fprofile-generate \
-ftest-coverage -mthumb --coverage -fno-common -Wall -Wshadow -Wundef -ffunction-sections -fdata-sections -g \
-mlittle-endian -mcpu=cortex-m0 -mthumb -mfloat-abi=soft main.c -o main.o

$ arm-none-eabi-ld --entry=__start -nostdlib --gc-sections -Tpimoroni-tiny2040-flash.ld -o test_gcov --start-group main.o \
~/gcc/linux/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/thumb/v6-m/nofp/libgcov.a --end-group
arm-none-eabi-ld: main.o: in function `__start':
/home/archer/code/nuttx/n4/incubator-nuttx/main.c:2: undefined reference to `__gcov_indirect_call_profiler_v4'
arm-none-eabi-ld: /home/archer/code/nuttx/n4/incubator-nuttx/main.c:4: undefined reference to `__gcov_indirect_call'
arm-none-eabi-ld: /home/archer/code/nuttx/n4/incubator-nuttx/main.c:4: undefined reference to `__gcov_time_profiler_counter'

link success with arm GCC-10.3:

$ arm-none-eabi-ld --entry=__start -nostdlib --gc-sections -Tpimoroni-tiny2040-flash.ld -o test_gcov --start-group main.o \
~/lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/libgcov.a --end-group
$ ls -l test_gcov
-rwxrwxr-x 1 archer archer 68744 10月 24 12:51 test_gcov

Signed-off-by: chao an <anchao@xiaomi.com>
@xiaoxiang781216
Copy link
Contributor

Let's merge this patch to unblock ci.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants