Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_esp32dev_idf6.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: esp32dev_idf6

# Compile-smoke of the classic-ESP32 I2S clockless driver against ESP-IDF v6.0+
# via pioarduino's prep_IDF6 branch (arduino-esp32 master with IDF v6.0.1+).
# via the pioarduino 61.04.00-RC1 release (Arduino 4 on IDF v6).
#
# This job exercises the `i2s_ll_enable_bus_clock` + `PERIPH_RCC_ATOMIC()` path
# in `src/platforms/esp/32/drivers/i2s/i2s_periph_compat.h` (landed in #3511 /
Expand Down Expand Up @@ -50,4 +50,4 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'ci-platform:esp*')))
uses: ./.github/workflows/build_template.yml
with:
args: esp32dev_idf6 --examples Blink,SpecialDrivers/ESP/DriverTest
args: esp32dev_idf6 --examples Blink,Test,SpecialDrivers/ESP/DriverTest
12 changes: 12 additions & 0 deletions .github/workflows/nightly-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ jobs:
uses: ./.github/workflows/build_template.yml
with:
args: esp32s3 --examples AutoResearch

arduino4_idf6:
# Nightly Arduino 4 / ESP-IDF 6 board build (FastLED#4827). Test.ino carries
# the legacy unqualified memset/memcpy/free-on-CRGB* regression.
uses: ./.github/workflows/build_template.yml
with:
args: esp32dev_idf6 --examples Blink,Test,Audio,AudioInput

arduino3_esp32dev:
uses: ./.github/workflows/build_template.yml
with:
args: esp32dev --examples Blink,Test
14 changes: 5 additions & 9 deletions ci/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
ESP32_IDF_5_5_PIOARDUINO = "https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip"
ESP32_IDF_5_5_1_PIOARDUINO = "https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip"
ESP32_IDF_5_5_5_PIOARDUINO = "https://github.com/pioarduino/platform-espressif32/releases/download/55.03.311/platform-espressif32.zip"
# IDF 6.0 preview via pioarduino prep_IDF6 branch (commit 98230ad4aa, 2026-05-25).
# platform.json in this branch pins framework-arduinoespressif32 to
# arduino-esp32/archive/master.zip — arduino-esp32 master built on ESP-IDF v6.0.1+.
# Moves to a release tag when pioarduino cuts one. See FastLED#3516.
ESP32_IDF_6_PIOARDUINO = (
"https://github.com/pioarduino/platform-espressif32.git#prep_IDF6"
)
# Arduino 4 on ESP-IDF 6: pioarduino 61.04.00-RC1 release (FastLED#4827,
# FastLED#3516). Bump to the final 61.04.x tag when pioarduino cuts it.
ESP32_IDF_6_PIOARDUINO = "https://github.com/pioarduino/platform-espressif32/releases/download/61.04.00-RC1/platform-espressif32.zip"
ESP32_IDF_LATEST_PIOARDUINO = ESP32_IDF_5_5_1_PIOARDUINO

ESP32_IDF_LATEST_PIOARDUINO = (
Expand Down Expand Up @@ -826,8 +822,8 @@ def to_project_ini(
)

# IDF 6.0 target for the classic-ESP32 I2S parallel-out driver bring-up
# (FastLED#3515). Uses pioarduino's prep_IDF6 branch until an IDF6 release
# tag ships. No FASTLED_ESP32_I2S selector — the driver auto-compiles via
# (FastLED#3515). Uses the pioarduino 61.04.00-RC1 release (Arduino core
# 4.0.0-RC1 on ESP-IDF 6.1, FastLED#4827). No FASTLED_ESP32_I2S selector — the driver auto-compiles via
# FASTLED_ESP32_HAS_I2S (feature flag) and gc-sections elides it when
# unused. Users select the I2S driver at runtime via
# `FastLED.enableDriver<fl::Bus::FLEX_IO, 0>()` or
Expand Down
7 changes: 7 additions & 0 deletions ci/lint_cpp_rs/src/checkers/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ impl FileContentChecker for UsingNamespaceChecker {
if regex_define_using_namespace().is_match(&line_clean) {
continue;
}
// fl/stl/adl_barrier.h: this directive hides fl's generic templates
// from ADL while keeping them reachable as fl::name (FastLED#4827).
if line_clean.trim() == "using namespace adl_barrier;"
&& normalize_path(&file_content.path).ends_with("src/fl/stl/adl_barrier.h")
{
continue;
}

let mut is_conditional = false;
for previous_index in index.saturating_sub(5)..index {
Expand Down
5 changes: 5 additions & 0 deletions ci/lint_cpp_rs/src/lint_core/banned_header_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ const BANNED_HEADER_EXCEPTIONS: &[(&str, &str)] = &[
"third_party/object_fled/src/ObjectFLEDDmaManager.h",
),
("Arduino.h", "platforms/wasm/compiler/Arduino.h"),
// The host/WASM Arduino.h shim must expose the C library the way every
// real Arduino core does, so unmodified sketches calling memset/free
// compile (FastLED#4827).
("string.h", "platforms/stub/Arduino.h"),
("stdlib.h", "platforms/stub/Arduino.h"),
("Arduino.h", "platforms/wasm/led_sysdefs_wasm.h"),
("pthread.h", "fl/stl/thread_local.h"),
("mutex", "fl/stl/mutex.h"),
Expand Down
18 changes: 18 additions & 0 deletions examples/Test/Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,28 @@

// Test configuration

// Compile-time regression for FastLED#4827: legacy sketches call libc memory
// functions unqualified on CRGB*. These must stay unambiguous on every board.
static void legacyLibcOnCrgb() {
CRGB src[4] = {CRGB(1, 2, 3), CRGB(4, 5, 6), CRGB(7, 8, 9), CRGB(10, 11, 12)};
CRGB* dst = static_cast<CRGB*>(malloc(sizeof(CRGB) * 4)); // ok bare allocation
if (!dst) {
return;
}
memset(dst, 0, sizeof(CRGB) * 4);
memcpy(dst, src, sizeof(CRGB) * 4);
memmove(dst + 1, dst, sizeof(CRGB) * 3);
if (memcmp(dst, src, sizeof(CRGB)) != 0) {
Serial.println("legacy libc copy mismatch");
}
free(dst); // ok bare allocation
}


void setup() {
Serial.begin(115200); // Fast baud for avr8js
Serial.println("Test setup starting");
legacyLibcOnCrgb();


delay(100);
Expand Down
2 changes: 1 addition & 1 deletion src/fl/channels/adapters/spi_channel_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SpiChannelEngineAdapter : public IChannelDriver {
private:
/// @brief Friend declaration for make_shared to access private constructor
template<typename T, typename... Args>
friend fl::shared_ptr<T> fl::make_shared(Args&&... args) FL_NO_EXCEPT;
friend fl::shared_ptr<T> fl::adl_barrier::make_shared(Args&&... args) FL_NO_EXCEPT; // see fl/stl/adl_barrier.h

/// @brief Private constructor - use create() factory method
SpiChannelEngineAdapter(const char* name) FL_NO_EXCEPT;
Expand Down
2 changes: 1 addition & 1 deletion src/fl/channels/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class Channel: public CPixelLEDController<RGB>, public IChannel {
private:
/// @brief Friend declaration for make_shared to access private constructor
template<typename T, typename... Args>
friend fl::shared_ptr<T> fl::make_shared(Args&&... args) FL_NO_EXCEPT;
friend fl::shared_ptr<T> fl::adl_barrier::make_shared(Args&&... args) FL_NO_EXCEPT; // see fl/stl/adl_barrier.h
template<const EmitterProfile& Profile>
friend class StaticProfileChannel;

Expand Down
2 changes: 1 addition & 1 deletion src/fl/channels/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ChannelData {
private:
/// @brief Friend declaration for make_shared to access private constructor
template<typename T, typename... Args>
friend fl::shared_ptr<T> fl::make_shared(Args&&... args) FL_NO_EXCEPT;
friend fl::shared_ptr<T> fl::adl_barrier::make_shared(Args&&... args) FL_NO_EXCEPT; // see fl/stl/adl_barrier.h

/// @brief Private constructor - variant-based (modern API)
ChannelData(
Expand Down
2 changes: 1 addition & 1 deletion src/fl/channels/rx/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RxChannel {

private:
template<typename T, typename... Args>
friend fl::shared_ptr<T> fl::make_shared(Args&&... args) FL_NO_EXCEPT;
friend fl::shared_ptr<T> fl::adl_barrier::make_shared(Args&&... args) FL_NO_EXCEPT; // see fl/stl/adl_barrier.h

RxChannel(const RxChannelConfig& config, fl::shared_ptr<RxDevice> device) FL_NO_EXCEPT;

Expand Down
10 changes: 9 additions & 1 deletion src/fl/math/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ template <typename T, typename U> constexpr inline common_type_t<T, U> max(T a,

FL_DISABLE_WARNING_POP

template <typename T> FASTLED_FORCE_INLINE T clamp(T value, T lo, T hi) FL_NO_EXCEPT {
// lo/hi are their own template parameters, constrained to T, so this generic
// clamp is less specialized than C++17 std::clamp(const T&, ...). Under
// `using namespace std` an unqualified clamp on an fl type picks std::clamp
// instead of tying (FastLED#4827); fl's fixed-point clamp overloads stay
// more specialized than this one.
template <typename T, typename L, typename H>
FASTLED_FORCE_INLINE enable_if_t<is_same<T, L>::value && is_same<T, H>::value, T>
clamp(T value, L lo, H hi) FL_NO_EXCEPT {
if (value < lo) return lo;
if (value > hi) return hi;
return value;
}


// ===== Approximate equality ===================================================

template <typename T, typename U>
Expand Down
37 changes: 37 additions & 0 deletions src/fl/stl/adl_barrier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

/// @file adl_barrier.h
/// Keeps fl's generic templates out of argument-dependent lookup (ADL).
///
/// Every fl type (CRGB, CHSV, palettes, containers, ...) lives in namespace
/// fl, so an unqualified call on one of them searches fl. If fl declared
/// `template <class T> void swap(T&, T&)` or `void* memcpy(void*, const void*,
/// size_t)` directly, those would join the overload set next to std::swap or
/// ::memcpy and tie. That made legacy code like `memset(leds, 0, n)`,
/// `free(leds)` and even `std::reverse(leds, leds + n)` (libstdc++ calls swap
/// unqualified) fail to compile (FastLED#4827).
///
/// Such functions are declared in fl::adl_barrier instead, and fl imports them
/// with a using-directive. ADL ignores using-directives, so the barrier is
/// invisible to it. Ordinary lookup does follow the directive, so `fl::swap(a,
/// b)`, `fl::memcpy(...)` and unqualified calls inside fl work as before.
///
/// Rules:
/// - Put every namespace-scope overload of a barrier name in the barrier.
/// Qualified `fl::name` lookup stops at fl and skips the directive if fl
/// declares any `name` itself.
/// - The C library mirrors (fl::memcpy, fl::free, fl::strlen, ...) use a
/// different fix, see fl/stl/cstring.h: they are templates with an unused
/// defaulted parameter, so the non-template ::memcpy wins any tie, including
/// under a using-directive for fl, which a using-directive cannot help with.
/// - swap and clamp are exceptions: it stays directly in fl so `swap(a, b)` on fl
/// types still works via ADL; their generic overloads are written to be
/// less specialized than std::swap / std::clamp so std wins ties (see
/// type_traits.h and fl/math/math.h).
/// - Before 3.10.4 CRGB was a global type, so none of these names were
/// reachable through ADL on a pixel; the barrier restores that behaviour.

namespace fl {
namespace adl_barrier {}
using namespace adl_barrier; // ok bare using
} // namespace fl
9 changes: 9 additions & 0 deletions src/fl/stl/algorithm.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once

#include "fl/stl/adl_barrier.h"
#include "fl/stl/type_traits.h"
#include "fl/stl/move.h"
#include "fl/math/random.h"
#include "fl/stl/noexcept.h"

namespace fl {

namespace adl_barrier { // see fl/stl/adl_barrier.h

template <typename Iterator>
void reverse(Iterator first, Iterator last) FL_NO_EXCEPT {
while ((first != last) && (first != --last)) {
Expand Down Expand Up @@ -291,6 +294,8 @@ Iterator remove_if(Iterator first, Iterator last, UnaryPredicate pred) FL_NO_EXC
return result;
}

} // namespace adl_barrier

namespace detail {

// Insertion sort implementation for small arrays
Expand Down Expand Up @@ -546,6 +551,8 @@ void mergesort_impl(Iterator first, Iterator last, Compare comp) FL_NO_EXCEPT {

} // namespace detail

namespace adl_barrier { // see fl/stl/adl_barrier.h

// Lower bound: find first position in sorted [first, last) where value could be inserted.
template <typename Iterator, typename T, typename Compare>
Iterator lower_bound(Iterator first, Iterator last, const T& value, Compare comp) FL_NO_EXCEPT {
Expand Down Expand Up @@ -663,4 +670,6 @@ void shuffle(Iterator first, Iterator last) FL_NO_EXCEPT {
shuffle(first, last, default_random());
}

} // namespace adl_barrier

} // namespace fl
18 changes: 9 additions & 9 deletions src/fl/stl/cstdlib.cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void aligned_free_via_malloc(void *ptr) FL_NO_EXCEPT {
// fl::aligned_alloc / fl::aligned_free
// ============================================================================

void *aligned_alloc(fl::size_t alignment, fl::size_t size) FL_NO_EXCEPT {
void *libc_impl::aligned_alloc(fl::size_t alignment, fl::size_t size) FL_NO_EXCEPT {
#if defined(FL_IS_AVR) || defined(FL_IS_ESP8266) || defined(FL_IS_ARM) || \
defined(FL_IS_APOLLO3) || defined(FL_IS_CI13XX)
// Many bare-metal toolchains (newlib-nano on STM32, nRF52, SAMD, RP2040,
Expand Down Expand Up @@ -121,7 +121,7 @@ static int charToDigit(char c) FL_NO_EXCEPT {
return 0;
}

long strtol(const char* str, char** endptr, int base) FL_NO_EXCEPT {
long libc_impl::strtol(const char* str, char** endptr, int base) FL_NO_EXCEPT {
if (!str) {
if (endptr) {
*endptr = const_cast<char*>(str);
Expand Down Expand Up @@ -194,7 +194,7 @@ long strtol(const char* str, char** endptr, int base) FL_NO_EXCEPT {
return negative ? -result : result;
}

unsigned long strtoul(const char* str, char** endptr, int base) FL_NO_EXCEPT {
unsigned long libc_impl::strtoul(const char* str, char** endptr, int base) FL_NO_EXCEPT {
if (!str) {
if (endptr) {
*endptr = const_cast<char*>(str);
Expand Down Expand Up @@ -266,15 +266,15 @@ unsigned long strtoul(const char* str, char** endptr, int base) FL_NO_EXCEPT {
return result;
}

int atoi(const char* str) FL_NO_EXCEPT {
int libc_impl::atoi(const char* str) FL_NO_EXCEPT {
return static_cast<int>(strtol(str, nullptr, 10));
}

long atol(const char* str) FL_NO_EXCEPT {
long libc_impl::atol(const char* str) FL_NO_EXCEPT {
return strtol(str, nullptr, 10);
}

double strtod(const char* str, char** endptr) FL_NO_EXCEPT {
double libc_impl::strtod(const char* str, char** endptr) FL_NO_EXCEPT {
if (!str) {
if (endptr) {
*endptr = const_cast<char*>(str);
Expand Down Expand Up @@ -476,7 +476,7 @@ void detail::qsort_impl(char* base, size_t nmemb, size_t size, qsort_compare_fn
}

// qsort - Direct implementation without using fl::sort to avoid proxy iterator issues
void qsort(void* base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO_EXCEPT {
void libc_impl::qsort(void* base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO_EXCEPT {
if (!base || nmemb <= 1 || size == 0 || !compar) {
return;
}
Expand All @@ -485,13 +485,13 @@ void qsort(void* base, size_t nmemb, size_t size, qsort_compare_fn compar) FL_NO
detail::qsort_impl(arr, nmemb, size, compar);
}

u32 rand() FL_NO_EXCEPT {
u32 libc_impl::rand() FL_NO_EXCEPT {
return static_cast<u32>(::rand());
}

// Get the value of an environment variable
// Only functional on FL_IS_STUB (stub platform), returns nullptr otherwise
const char* getenv(const char* name) FL_NO_EXCEPT {
const char* libc_impl::getenv(const char* name) FL_NO_EXCEPT {
#ifdef FL_IS_STUB
return ::getenv(name);
#else
Expand Down
Loading
Loading