#19124·esp-idf

ESP-IDF linux target doesn't build on Apple/Darwin (IDFGH-18330)

Author: andreaslundeenCreated Sep 23, 2026Updated Sep 30, 2026
LabelsType: BugStatus: Opened

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.5.5 and above

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

There are a number of issues when building on macos for target linux. I am listing a few of them below: lwip disable wrap: In components/lwip/CMakeLists.txt, add guard around wrap:

  •    if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  •        foreach(wrap ${WRAP_FUNCTIONS})
  •                    target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")
  •                    target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __wrap_${wrap}")
  •        endforeach()
  •    endif()

freertos_corefoundation_link: In components/freertos/CMakeLists.txt add:

  • if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  •    target_link_libraries(${COMPONENT_LIB} PRIVATE "-framework CoreFoundation")
  • endif()

idf_port: In components/freertos/FreeRTOS-Kernel/portable/linux/port_idf.c add/make configurable: +#if (defined(APPLE) && defined(MACH)) +#include <CoreFoundation/CoreFoundation.h> +#endif +#if (defined(APPLE) && defined(MACH)) +/* macOS: Cocoa (and therefore SDL's video backend) only works on the process's

    • real main thread. Run the FreeRTOS scheduler on a dedicated pthread
    • instead, so the real main thread is free to run a CFRunLoop (below) -
    • which also drains the GCD main dispatch queue, letting
    • dispatch_sync(dispatch_get_main_queue(), ...) calls made from FreeRTOS
    • tasks actually execute on this thread. A bare dispatch_main() is NOT
    • sufficient here: it drains the main queue but doesn't run an actual
    • CFRunLoop, and SDL's Cocoa init still reports "No available video
    • device" without one. */ +static void *apple_scheduler_thread(void *arg) +{
  • (void)arg;
  • vTaskStartScheduler();
  • return NULL;

+} +#endif inside main() add: ESP_LOGI(TAG, "Starting scheduler."); +#if (defined(APPLE) && defined(MACH))

  • pthread_t apple_sched_thread;
  • int apple_sched_ret = pthread_create(&apple_sched_thread, NULL, apple_scheduler_thread, NULL);
  • assert(apple_sched_ret == 0);
  • (void)apple_sched_ret;
  • /* CFRunLoopRun() can return on its own once it briefly has no sources
  • * scheduled (e.g. between dispatch_sync() calls from other threads),
  • * despite being documented as running "indefinitely" - restart it
  • * rather than falling through to the assert(false) below. */
  • for (;;)
  • {
  •    CFRunLoopRun();
  • }

+#else vTaskStartScheduler(); +#endif

What is the actual behavior?

Not able to build / run on macos (using SDL in my project)

Steps to reproduce.

See description above

Build or installation Logs.

plain

Diagnostic report archive.

No response

More Information.

No response