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

SDK 2.1.0: clang 19.1.1 picolibc_interface compile error #2107

Open
geurtv opened this issue Nov 27, 2024 · 2 comments
Open

SDK 2.1.0: clang 19.1.1 picolibc_interface compile error #2107

geurtv opened this issue Nov 27, 2024 · 2 comments

Comments

@geurtv
Copy link
Contributor

geurtv commented Nov 27, 2024

pico-sdk 2.1.0 compiles fine with clang 18.1.3 (LVM-ET-Arm-18.1.3) but with clang 19.1.1 (LLVM-ET-Arm-19.1.1) I get the following compile error:

pico-sdk/2.1.0/src/rp2_common/pico_clib_interface/picolibc_interface.c:102:83: error: use of undeclared identifier 'CLOCKS_PER_SEC'
  102 |     tms->tms_utime = (clock_t)(to_us_since_boot(get_absolute_time()) / (1000000 / CLOCKS_PER_SEC));
      |                                                                                   ^

I don't know what a correct fix is. For example, if I add the following code to picolibc_interface.c:

#include <time.h>

It compiles and CLOCKS_PER_SEC == 1000000.

clang 18's time.h includes machine/time.h, clang 19's does not. So if instead I add:

#include <machine/time.h>
#include <time.h>

It again compiles, but now CLOCKS_PER_SEC == 100 (same as clang 18).

@lurch
Copy link
Contributor

lurch commented Nov 27, 2024

@geurtv
Copy link
Contributor Author

geurtv commented Nov 27, 2024

I assume llvm_libc/sys/times.h will only be included for clang+llvm_libc (and not clang+picolibc), but I guess it does indicate the value for CLOCKS_PER_SEC is expected to be 100. So that leaves the question what the correct include is to get CLOCKS_PER_SEC == 100 in picolibc_interface.c.

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

No branches or pull requests

2 participants