Re: mbedtls warning "implicit declaration of function 'time'"


David Leach
 

Figured out the problem. This is a multi-layered issue that starts with an invalid Kconfig setting I did. I had, by default, turned on MBEDTLS in the SOC Kconfig. This had a ripple affect:

 

  1. turning this on causes the mbedtls module to be compiled.
  2. The /tests/lib/fdtable sets CONFIG_POSIX_API
  3. By default, the mbedtls module uses config-tls-generic.h for mbed configuration and this config has an #ifdef CONFIG_POSIX_API that defines MBEDTLS_HAVE_TIME.
  4. MBEDTLS_HAVE_TIME tells mbed that the time() function exists and to use it for mbedtls_time()
  5. the project is built with libc_minimal which doesn’t have a define for time() so the compile of routines with mbedtls_time/time function will give warnings but let the symbol resolve at link time.
  6. The linker strips out the functions using mbedtls_time() because they are not used by the application so I’m assuming that is why there is no linker error

 

David

 

From: users@... <users@...> On Behalf Of David Leach via Lists.Zephyrproject.Org
Sent: Sunday, July 28, 2019 10:08 PM
To: users@...
Cc: users@...
Subject: [Zephyr-users] mbedtls warning "implicit declaration of function 'time'"

 

I’m having some weirdness with building the mbedtls module giving me a compiler warning related to “time”:

 

/home/dleach/work/zephyrproject/modules/crypto/mbedtls/include/mbedtls/platform_time.h:74:24: warning: implicit declaration of function 'time'; did you mean 'gmtime'? [-Wimplicit-function-declaration]

#define mbedtls_time   time

                        ^~~~

/home/dleach/work/zephyrproject/modules/crypto/mbedtls/library/ssl_cli.c:697:9: note: in expansion of macro 'mbedtls_time'

     t = mbedtls_time( NULL );

         ^~~~~~~~~~~~

 

The warning is coming from my PR #17736 for /tests/lib/fdtable/. What is confusing me is that using similar configurations for /tests/crypto/rand32, which builds the same file, doesn’t get the warnings. Generally speaking the mbedtls stuff is an optional configuration between mbedtls and tinycrypt but for the KW41Z I have it generically turned mbedtls on.

 

I can also get the warning to go away for the fdtable test if I enable “CONFIG_NEW_LIBC”.

 

David Leach

 

NXP Semiconductors

phone: +1.210.241.6761

Email: david.leach@...

 

 

** PROPRIETARY & COMPANY-CONFIDENTIAL **

 

Join users@lists.zephyrproject.org to automatically receive all group messages.