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

Support native 64-bit host builds #2823

Merged
merged 7 commits into from
Jun 20, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
variant: host
arch: Host
toolchain: clang
- os: ubuntu-latest
variant: host
arch: Host
toolchain: gcc64
- variant: rp2040
arch: Rp2040

Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Sming/Arch/Host/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------

Expand Down
6 changes: 3 additions & 3 deletions Sming/Arch/Host/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion Sming/Arch/Host/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Sming/Components/Storage/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion Sming/Components/axtls-8266/axtls-8266.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions Sming/Components/lwip/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/lwip/src/Arch/Host/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion Sming/Core/DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion Sming/Libraries/CsvReader
Submodule CsvReader updated 1 files
+1 −1 test/app/parser.cpp
11 changes: 6 additions & 5 deletions Sming/Wiring/WString.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Sming/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sming/component-wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sming/project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions tests/HostTests/modules/CStringArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
Expand Down
Loading