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

warnings when using newlibc and threads #39413

Closed
bpbradley opened this issue Oct 13, 2021 · 5 comments
Closed

warnings when using newlibc and threads #39413

bpbradley opened this issue Oct 13, 2021 · 5 comments
Assignees
Labels
area: newlib Newlib C Standard Library

Comments

@bpbradley
Copy link
Contributor

Describe the bug
I noticed after going from 2.6 to the latest 2.7 release candidate, I was getting a number of warnings about type conversions that were unrelated to my application. They appear to be related to use of CONFIG_NEWLIB_LIBC

To Reproduce
Steps to reproduce the behavior:

  1. Build samples/basic/threads with CONFIG_NEWLIB_LIBC=y
  2. Observe warnings

Expected behavior
Clean build without warning with or without CONFIG_NEWLIB_LIBC=y

Environment (please complete the following information):

  • OS: (Windows)
  • Toolchain (gnuarmemb)
  • zephyr version: 11dd83b
@bpbradley bpbradley added the bug The issue is a bug, or the PR is fixing a bug label Oct 13, 2021
@carlescufi carlescufi added the area: newlib Newlib C Standard Library label Oct 14, 2021
@stephanosio
Copy link
Member

I am unable to reproduce this (though, it was on Linux).

Please post a more detailed bug report that includes essential information such as:

  1. The actual warning messages
  2. The board you are building
  3. The version of the GNU Arm Embedded toolchain you are using

@bpbradley
Copy link
Contributor Author

Ah sure, sorry I forgot to mention that.

The board was nrf52840dk_nrf52840. Here is the output when building.

PS C:\Users\bbradley\Documents\git\Firmware\zephyr\fp-workspace> west build -b nrf52840dk_nrf52840 -s .\rtos\zephyr\samples\basic\threads\
-- west build: generating a build system
Including boilerplate (Zephyr base): C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/samples/basic/threads
-- Zephyr version: 2.7.99 (C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr), build: v2.7.99-498-g11dd83b02b3c
-- Found Python3: C:/Users/bbradley/.pyenv/pyenv-win/versions/3.8.2/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
-- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
-- Board: nrf52840dk_nrf52840
-- Cache files will be written to: C:\Users\bbradley\AppData\Local/.cache/zephyr
-- Found dtc: C:/ProgramData/chocolatey/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (C:/gnuarmemb)
-- Found BOARD.dts: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Generated zephyr.dts: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/dts.cmake
Parsing C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/Kconfig
Loaded configuration 'C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration 'C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/samples/basic/threads/prj.conf'
Configuration saved to 'C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/.config'
Kconfig header saved to 'C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/gnuarmemb/bin/arm-none-eabi-gcc.exe
CMake Warning at C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/CMakeLists.txt:1649 (message):
  __ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/build
-- west build: building application
[26/135] Building C object zephyr/lib/libc/newlib/CMakeFiles/lib__libc__newlib.dir/libc-hooks.c.obj
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_init':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:358:8: warning: assignment makes integer from pointer without a cast [-Wint-conversion]      
  *lock = malloc(sizeof(struct k_sem));
        ^
In file included from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\modules\hal_nordic\nrfx\nrfx_glue.h:10:0,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/modules/hal/nordic/nrfx/nrfx.h:39,
                 from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\soc\arm\nordic_nrf\soc_nrf_common.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/soc/arm/nordic_nrf/nrf52/soc.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/cortex_m/cmsis.h:17,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu_v7m.h:11,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/arch.h:187,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/cpu.h:19,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:7:
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:362:17: warning: comparison between pointer and integer
  __ASSERT(*lock != NULL, "non-recursive lock allocation failed");
                 ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:94:9: note: in definition of macro '__ASSERT'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_init_recursive':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:374:8: warning: assignment makes integer from pointer without a cast [-Wint-conversion]      
  *lock = malloc(sizeof(struct k_mutex));
        ^
In file included from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\modules\hal_nordic\nrfx\nrfx_glue.h:10:0,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/modules/hal/nordic/nrfx/nrfx.h:39,
                 from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\soc\arm\nordic_nrf\soc_nrf_common.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/soc/arm/nordic_nrf/nrf52/soc.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/cortex_m/cmsis.h:17,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu_v7m.h:11,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/arch.h:187,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/cpu.h:19,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:7:
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:378:17: warning: comparison between pointer and integer
  __ASSERT(*lock != NULL, "recursive lock allocation failed");
                 ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:94:9: note: in definition of macro '__ASSERT'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_close':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:386:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:388:7: warning: passing argument 1 of 'free' makes pointer from integer without a cast [-Wint-conversion]
  free(lock);
       ^~~~
In file included from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:10:0:
c:\gnuarmemb\arm-none-eabi\include\malloc.h:45:13: note: expected 'void *' but argument is of type '_LOCK_T {aka int}'
 extern void free (void *);
             ^~~~
In file included from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\modules\hal_nordic\nrfx\nrfx_glue.h:10:0,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/modules/hal/nordic/nrfx/nrfx.h:39,
                 from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\soc\arm\nordic_nrf\soc_nrf_common.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/soc/arm/nordic_nrf/nrf52/soc.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/cortex_m/cmsis.h:17,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu_v7m.h:11,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/arch.h:187,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/cpu.h:19,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:7:
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_close_recursive':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:397:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:399:7: warning: passing argument 1 of 'free' makes pointer from integer without a cast [-Wint-conversion]
  free(lock);
       ^~~~
In file included from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:10:0:
c:\gnuarmemb\arm-none-eabi\include\malloc.h:45:13: note: expected 'void *' but argument is of type '_LOCK_T {aka int}'
 extern void free (void *);
             ^~~~
In file included from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\modules\hal_nordic\nrfx\nrfx_glue.h:10:0,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/modules/hal/nordic/nrfx/nrfx.h:39,
                 from c:\users\bbradley\documents\git\firmware\zephyr\fp-workspace\rtos\zephyr\soc\arm\nordic_nrf\soc_nrf_common.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/soc/arm/nordic_nrf/nrf52/soc.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/cortex_m/cmsis.h:17,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu_v7m.h:11,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/mpu/arm_mpu.h:14,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/arm/aarch32/arch.h:187,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/arch/cpu.h:19,
                 from C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:7:
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_acquire':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:408:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_acquire_recursive':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:415:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_try_acquire':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:422:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_try_acquire_recursive':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:429:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_release':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:436:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c: In function '__retarget_lock_release_recursive':
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/lib/libc/newlib/libc-hooks.c:443:23: warning: comparison between pointer and integer
  __ASSERT_NO_MSG(lock != NULL);
                       ^
C:/Users/bbradley/Documents/git/Firmware/zephyr/fp-workspace/rtos/zephyr/include/sys/__assert.h:86:9: note: in definition of macro '__ASSERT_NO_MSG'
   if (!(test)) {                                            \
         ^~~~
[128/135] Linking C executable zephyr\zephyr_prebuilt.elf

[135/135] Linking C executable zephyr\zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       33972 B         1 MB      3.24%
            SRAM:        9920 B       256 KB      3.78%
        IDT_LIST:          0 GB         2 KB      0.00%
PS C:\Users\bbradley\Documents\git\Firmware\zephyr\fp-workspace>

Here is the conf file

CONFIG_PRINTK=y
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=y
CONFIG_GPIO=y
CONFIG_NEWLIB_LIBC=y

@stephanosio stephanosio added question and removed bug The issue is a bug, or the PR is fixing a bug labels Oct 14, 2021
@stephanosio
Copy link
Member

-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1

It looks like you are using a very old GNU Arm Embedded/GCC release that bundles an incompatible newlib version (in particular, incompatible retargetable locking interface).

Please upgrade to the latest version and you should not see these warnings. I have tested with the 10-2020-q4-major (GCC 10.2.1) release and there are no warnings.

@bpbradley
Copy link
Contributor Author

I just noticed the same thing after you mentioned that. I have been running with this version for some time. I will update and see what I get.

Thanks!

@bpbradley
Copy link
Contributor Author

Okay you are correct, I was just using an ancient toolchain. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: newlib Newlib C Standard Library
Projects
None yet
Development

No branches or pull requests

3 participants