Skip to content

localtime_r is missing definition when using the clang compiler #2420

@NolanBrad

Description

@NolanBrad
Contributor

When compiling using bazel build, and using the clang compiler, localtime_r is missing definition

i.e. in bazelrc

build --@pico-sdk//bazel/config:PICO_TOOLCHAIN=clang
build --@pico-sdk//bazel/config:PICO_CLIB=auto

Results in error:
ld.lld: error: undefined symbol: localtime_r
referenced by datetime.c:11 (/proc/self/cwd/external/pico-sdk+/src/common/pico_util/datetime.c:11)
datetime.o:(pico_localtime_r) in archive bazel-out/k8-dbg/bin/external/pico-sdk+/src/common/pico_util/libpico_util.a
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

localtime_r has this declared in pico-sdk/src/rp2_common/pico_clib_interface/include/llvm_libc/time.h
struct tm* localtime_r(const time_t* timer, struct tm* buf);

I am using the pico_aon_timer library, specifically the aon_timer_set_time function

It looks as though the libc for clang doesnt support localtime_r. See https://libc.llvm.org/headers/time.html

Activity

lurch

lurch commented on Apr 14, 2025

@lurch
Contributor
self-assigned this
on Apr 14, 2025
added this to the 2.1.2 milestone on Apr 14, 2025
armandomontanez

armandomontanez commented on Apr 14, 2025

@armandomontanez
Contributor
petrhosek

petrhosek commented on Apr 15, 2025

@petrhosek
Contributor

localtime_r is under development, see llvm/llvm-project#110363.

modified the milestones: 2.1.2, 2.2.0 on Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @petrhosek@lurch@kilograham@armandomontanez@NolanBrad

      Issue actions

        localtime_r is missing definition when using the clang compiler · Issue #2420 · raspberrypi/pico-sdk