From ecb71a6dc55548c8fb441bc2c5062897bd2587dd Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Thu, 15 Jun 2023 21:12:21 -0400 Subject: [PATCH] Fossil/Skagen hybrids: patch jerryscript for gcc 12+ in watchface build script --- external/build_fossil_hr_watchface.sh | 2 ++ .../jerryscript-gcc-12-build-fix.patch | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 external/patches/jerryscript-gcc-12-build-fix.patch diff --git a/external/build_fossil_hr_watchface.sh b/external/build_fossil_hr_watchface.sh index 5be14b9bd..209469192 100755 --- a/external/build_fossil_hr_watchface.sh +++ b/external/build_fossil_hr_watchface.sh @@ -1,5 +1,7 @@ #!/bin/bash pushd jerryscript +gcc_version="$(gcc -v 2>&1 | grep -oe '^gcc version [0-9][0-9\.]*[0-9]' | sed 's|^.* ||;s|\..*||')" +(( gcc_version > 11 )) && git apply ../patches/jerryscript-gcc-12-build-fix.patch python3 tools/build.py --jerry-cmdline-snapshot ON popd pushd fossil-hr-watchface diff --git a/external/patches/jerryscript-gcc-12-build-fix.patch b/external/patches/jerryscript-gcc-12-build-fix.patch new file mode 100644 index 000000000..943c7b80b --- /dev/null +++ b/external/patches/jerryscript-gcc-12-build-fix.patch @@ -0,0 +1,35 @@ +diff --git a/jerry-ext/handler/handler-register.c b/jerry-ext/handler/handler-register.c +index ad35d8c3..d808061f 100644 +--- a/jerry-ext/handler/handler-register.c ++++ b/jerry-ext/handler/handler-register.c +@@ -63,7 +63,13 @@ jerryx_set_properties (const jerry_value_t target_object, /**< target object */ + { + #define JERRYX_SET_PROPERTIES_RESULT(VALUE, IDX) ((jerryx_register_result) { VALUE, IDX }) + uint32_t idx = 0; +- for (; ((entries + idx) != NULL) && (entries[idx].name != NULL); idx++) ++ ++ if (entries == NULL) ++ { ++ return JERRYX_SET_PROPERTIES_RESULT (jerry_create_undefined (), 0); ++ } ++ ++ for (; (entries[idx].name != NULL); idx++) + { + const jerryx_property_entry *entry = &entries[idx]; + +@@ -99,9 +105,12 @@ void + jerryx_release_property_entry (const jerryx_property_entry entries[], /**< list of property entries */ + const jerryx_register_result register_result) /**< previous result of registration */ + { +- for (uint32_t idx = register_result.registered; +- ((entries + idx) != NULL) && (entries[idx].name != NULL); +- idx++) ++ if (entries == NULL) ++ { ++ return; ++ } ++ ++ for (uint32_t idx = register_result.registered; entries[idx].name != NULL; idx++) + { + jerry_release_value (entries[idx].value); + }