diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d9fb17b35..870f129e5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,10 @@ jobs: variant: host arch: Host toolchain: clang + - os: ubuntu-latest + variant: host + arch: Host + toolchain: gcc64 - variant: rp2040 arch: Rp2040 @@ -36,6 +40,7 @@ jobs: SMING_ARCH: ${{ matrix.arch }} SMING_SOC: ${{ matrix.variant }} CLANG_BUILD: ${{ matrix.toolchain == 'clang' && '15' || '0' }} + BUILD64: ${{ matrix.toolchain == 'gcc64' && 1 || 0 }} steps: - name: Fix autocrlf setting diff --git a/Sming/Arch/Host/README.rst b/Sming/Arch/Host/README.rst index 92718875e0..9acb1ca446 100644 --- a/Sming/Arch/Host/README.rst +++ b/Sming/Arch/Host/README.rst @@ -71,6 +71,13 @@ Configuration Note: This setting is not 'sticky' +.. envvar:: BUILD64 + + default: undefined + + Set to 1 to build in native 64-bit mode. + + Components ---------- diff --git a/Sming/Arch/Host/app.mk b/Sming/Arch/Host/app.mk index 4af8f3fe53..940dc9a4d9 100644 --- a/Sming/Arch/Host/app.mk +++ b/Sming/Arch/Host/app.mk @@ -5,9 +5,9 @@ ### # linker flags used to generate the main object file -LDFLAGS += \ - -m32 - +ifneq ($(BUILD64),1) +LDFLAGS += -m32 +endif # Executable TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT) diff --git a/Sming/Arch/Host/build.mk b/Sming/Arch/Host/build.mk index 2129b2e506..f14bb481b5 100644 --- a/Sming/Arch/Host/build.mk +++ b/Sming/Arch/Host/build.mk @@ -41,8 +41,11 @@ GDB := $(TOOLSPEC)gdb GCC_UPGRADE_URL := https://sming.readthedocs.io/en/latest/arch/host/host-emulator.html\#c-c-32-bit-compiler-and-libraries +ifneq ($(BUILD64),1) +CPPFLAGS += -m32 +endif + CPPFLAGS += \ - -m32 \ -D_FILE_OFFSET_BITS=64 \ -D_TIME_BITS=64 diff --git a/Sming/Components/FlashString b/Sming/Components/FlashString index a44b584a10..f2f3a40163 160000 --- a/Sming/Components/FlashString +++ b/Sming/Components/FlashString @@ -1 +1 @@ -Subproject commit a44b584a100848fdb89cc6ea5f1778b4557d3227 +Subproject commit f2f3a401634c393ffdde8e5ce73b0fb88a625b33 diff --git a/Sming/Components/Storage/component.mk b/Sming/Components/Storage/component.mk index eb711a1054..70fb882817 100644 --- a/Sming/Components/Storage/component.mk +++ b/Sming/Components/Storage/component.mk @@ -3,6 +3,9 @@ COMPONENT_SRCDIRS := src COMPONENT_DOXYGEN_INPUT := src/include COMPONENT_VARS := ENABLE_STORAGE_SIZE64 +ifeq ($(BUILD64),1) +override ENABLE_STORAGE_SIZE64 := 1 +endif ifeq ($(ENABLE_STORAGE_SIZE64),1) GLOBAL_CFLAGS += -DENABLE_STORAGE_SIZE64 endif diff --git a/Sming/Components/axtls-8266/axtls-8266.patch b/Sming/Components/axtls-8266/axtls-8266.patch index 19688134c4..9311810b10 100644 --- a/Sming/Components/axtls-8266/axtls-8266.patch +++ b/Sming/Components/axtls-8266/axtls-8266.patch @@ -731,7 +731,7 @@ index 5bd2394..5363d22 100644 if (memcmp(mac, orig_mac, SHA1_SIZE)) { diff --git a/ssl/tls1.c b/ssl/tls1.c -index 8f0fbfb..b2dcddd 100644 +index 8f0fbfb..f099e2c 100644 --- a/ssl/tls1.c +++ b/ssl/tls1.c @@ -85,7 +85,7 @@ static const cipher_info_t cipher_info[NUM_PROTOCOLS] = @@ -914,6 +914,15 @@ index 8f0fbfb..b2dcddd 100644 #endif ret = SSL_ERROR_NOT_SUPPORTED; goto error; /* not an error - just get out of here */ +@@ -1432,7 +1436,7 @@ int basic_read(SSL *ssl, uint8_t **in_data) + /* is the allocated buffer large enough to handle all the data? if not, increase its size*/ + if (ssl->need_bytes > ssl->max_plain_length+RT_EXTRA-BM_RECORD_OFFSET) + { +- printf("ssl->need_bytes=%d > %d\r\n", ssl->need_bytes, ssl->max_plain_length+RT_EXTRA-BM_RECORD_OFFSET); ++ printf("ssl->need_bytes=%u > %u\r\n", ssl->need_bytes, (unsigned)ssl->max_plain_length+RT_EXTRA-BM_RECORD_OFFSET); + ret = increase_bm_data_size(ssl, ssl->need_bytes + BM_RECORD_OFFSET - RT_EXTRA); + if (ret != SSL_OK) + { @@ -1562,7 +1566,7 @@ int increase_bm_data_size(SSL *ssl, size_t size) required = (required < RT_MAX_PLAIN_LENGTH) ? required : RT_MAX_PLAIN_LENGTH; uint8_t* new_bm_all_data = (uint8_t*) realloc(ssl->bm_all_data, required + RT_EXTRA); diff --git a/Sming/Components/lwip/component.mk b/Sming/Components/lwip/component.mk index c6d48d82a8..b692dcf685 100644 --- a/Sming/Components/lwip/component.mk +++ b/Sming/Components/lwip/component.mk @@ -38,6 +38,9 @@ endif ifeq ($(SMING_RELEASE),1) LWIP_CMAKE_OPTIONS += -DLWIP_NOASSERT=1 endif +ifneq ($(BUILD64),1) + LWIP_CMAKE_OPTIONS += -DBUILD_MODE=-m32 +endif LWIP_TARGET := $(COMPONENT_LIBDIR)/lib$(LWIP_LIBNAME).a COMPONENT_TARGETS += $(LWIP_TARGET) diff --git a/Sming/Components/lwip/src/Arch/Host/Linux/CMakeLists.txt b/Sming/Components/lwip/src/Arch/Host/Linux/CMakeLists.txt index 19ba30ac35..a4a9c4e6a7 100644 --- a/Sming/Components/lwip/src/Arch/Host/Linux/CMakeLists.txt +++ b/Sming/Components/lwip/src/Arch/Host/Linux/CMakeLists.txt @@ -37,6 +37,6 @@ set_target_properties(lwip PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${USER_LIBDIR} OUTPUT_NAME "${LWIP_LIBNAME}" ) -target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} -m32) +target_compile_options(lwip PRIVATE ${LWIP_COMPILER_FLAGS} ${BUILD_MODE}) target_compile_definitions(lwip PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) target_include_directories(lwip PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS}) diff --git a/Sming/Core/DateTime.cpp b/Sming/Core/DateTime.cpp index 688d1ee3ed..57b20d23d5 100644 --- a/Sming/Core/DateTime.cpp +++ b/Sming/Core/DateTime.cpp @@ -17,7 +17,7 @@ #if defined(__WIN32) || (defined(ARCH_ESP32) && ESP_IDF_VERSION_MAJOR < 5) static_assert(sizeof(time_t) != 8, "Great! Now supports 64-bit - please update code"); #warning "**Y2038** time_t is only 32-bits in this build configuration" -#elif defined(ARCH_HOST) && !defined(__USE_TIME_BITS64) +#elif defined(ARCH_HOST) && __TIMESIZE != 64 && !defined(__USE_TIME_BITS64) #warning "**Y2038** Expecting 64-bit time_t - please use GCC 10 or later" #else static_assert(sizeof(time_t) == 8, "Expecting 64-bit time_t - please use GCC 10 or later"); diff --git a/Sming/Libraries/CsvReader b/Sming/Libraries/CsvReader index 8f4d416442..8d441afdf8 160000 --- a/Sming/Libraries/CsvReader +++ b/Sming/Libraries/CsvReader @@ -1 +1 @@ -Subproject commit 8f4d416442292927d15fe00d80130fb2fc7d8bb6 +Subproject commit 8d441afdf80c40265a29d2bddc6cad64ea0f128c diff --git a/Sming/Libraries/jerryscript b/Sming/Libraries/jerryscript index 21ac3e053d..f355d307de 160000 --- a/Sming/Libraries/jerryscript +++ b/Sming/Libraries/jerryscript @@ -1 +1 @@ -Subproject commit 21ac3e053d2a63ebc1955f2a62c2978c7447e119 +Subproject commit f355d307de19bc3f498d2edb4ac945cccfb4b5d2 diff --git a/Sming/Wiring/WString.h b/Sming/Wiring/WString.h index f6c5a689ac..915cbf5926 100644 --- a/Sming/Wiring/WString.h +++ b/Sming/Wiring/WString.h @@ -804,7 +804,8 @@ class String float toFloat(void) const; /// Max chars. (excluding NUL terminator) we can store in SSO mode - static constexpr size_t SSO_CAPACITY = STRING_OBJECT_SIZE - 2; + static constexpr size_t SSO_SIZE = std::max(size_t(STRING_OBJECT_SIZE), sizeof(char*) * 3); + static constexpr size_t SSO_CAPACITY = SSO_SIZE - 2; protected: /// Used when contents allocated on heap @@ -824,10 +825,10 @@ class String SsoBuf sso; }; - static_assert(STRING_OBJECT_SIZE == sizeof(SsoBuf), "SSO Buffer alignment problem"); - static_assert(STRING_OBJECT_SIZE >= sizeof(PtrBuf), "STRING_OBJECT_SIZE too small"); - static_assert(STRING_OBJECT_SIZE <= 128, "STRING_OBJECT_SIZE too large (max. 128)"); - static_assert(STRING_OBJECT_SIZE % 4 == 0, "STRING_OBJECT_SIZE must be a multiple of 4"); + static_assert(SSO_SIZE == sizeof(SsoBuf), "SSO Buffer alignment problem"); + static_assert(SSO_SIZE >= sizeof(PtrBuf), "STRING_OBJECT_SIZE too small"); + static_assert(SSO_SIZE <= 128, "STRING_OBJECT_SIZE too large (max. 128)"); + static_assert(SSO_SIZE % 4 == 0, "STRING_OBJECT_SIZE must be a multiple of 4"); protected: // Free any heap memory and set to non-SSO mode; isNull() will return true diff --git a/Sming/build.mk b/Sming/build.mk index c932ff78cd..0253b8dbb7 100644 --- a/Sming/build.mk +++ b/Sming/build.mk @@ -140,6 +140,13 @@ DEBUG_VARS += AWK # invokes an awk compatibility mode. It has no effect on other awk implementations. AWK ?= POSIXLY_CORRECT= awk +DEBUG_VARS += SED +ifeq ($(UNAME),Darwin) +SED ?= gsed +else +SED ?= sed +endif + # Python command DEBUG_VARS += PYTHON ifdef PYTHON diff --git a/Sming/component-wrapper.mk b/Sming/component-wrapper.mk index 88aca58d41..ee82818afb 100644 --- a/Sming/component-wrapper.mk +++ b/Sming/component-wrapper.mk @@ -112,7 +112,7 @@ CXXFLAGS += $(COMPONENT_CXXFLAGS) # GCC 10 escapes ':' in path names which breaks GNU make for Windows so filter them ifeq ($(UNAME),Windows) -OUTPUT_DEPS := | sed "s/\\\\:/:/g" > $$@ +OUTPUT_DEPS := | $(SED) "s/\\\\:/:/g" > $$@ else OUTPUT_DEPS := -MF $$@ endif diff --git a/Sming/project.mk b/Sming/project.mk index cf928ea1b0..e1830fca6a 100644 --- a/Sming/project.mk +++ b/Sming/project.mk @@ -19,7 +19,7 @@ endif .PHONY: all all: checksoc checkdirs submodules ##(default) Build all Component libraries - $(MAKE) components application + $(Q) $(MAKE) components application # Load current build type from file BUILD_TYPE_FILE := out/build-type.mk diff --git a/tests/HostTests/modules/CStringArray.cpp b/tests/HostTests/modules/CStringArray.cpp index bb640bf83f..c149aa59df 100644 --- a/tests/HostTests/modules/CStringArray.cpp +++ b/tests/HostTests/modules/CStringArray.cpp @@ -239,24 +239,22 @@ class CStringArrayTest : public TestGroup TEST_CASE("release") { - CStringArray csa(FS_Basic); - csa += FS_Basic; // Allocate > SSO + String orig; + // Allocate > SSO + while(orig.length() <= String::SSO_CAPACITY) { + orig += FS_Basic; + } + CStringArray csa = orig; Serial << csa.join() << endl; auto cstrWant = csa.c_str(); String s = csa.release(); REQUIRE(!csa); REQUIRE(s.c_str() == cstrWant); - REQUIRE(s == String(FS_Basic) + FS_Basic); + REQUIRE(s == orig); csa = std::move(s); - REQUIRE(csa == String(FS_Basic) + FS_Basic); - - String js; - js += FS_BasicJoined; - js += ','; - js += FS_BasicJoined; - REQUIRE(csa.join() == js); + REQUIRE(csa == orig); } } };