From db003224886e6c5fcaa773de8a662feb111b05a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Marek?= Date: Mon, 30 Mar 2026 12:46:48 +0200 Subject: [PATCH 1/5] Prefer GNU make on Solaris Solaris comes with own make implementation which is does not work with GNU tools well. Running configure ends with this error: config.status: error: Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index bc1d27317a..3f9f82e629 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,12 @@ dnl Created autoconf implementation thompson@dtosolutions, 26NOV12 AC_PREREQ([2.65]) AC_CONFIG_AUX_DIR([config]) AC_USE_SYSTEM_EXTENSIONS + +dnl Prefer GNU make on Solaris where /usr/bin/make is not suitable +AS_IF([test -z "$MAKE"], [ + AS_CASE(["`uname -s`"], [SunOS], [MAKE=/usr/gnu/bin/make]) +]) + AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall]) AM_SILENT_RULES([yes]) AM_PROG_AR From 655a937c7d86896657a924666d3c98a3d168772b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Marek?= Date: Mon, 30 Mar 2026 12:51:08 +0200 Subject: [PATCH 2/5] Modify the tests to work on Solaris - run tools from /usr/gnu - disable color testing on Solaris - change the way JQ_COLORS is exported to the process First two poinst are self-explanatory. As for JQ_COLORS, the script originally used this form: JQ_COLORS=blah $JQ ... 2>...warning It runs $JQ and compares stderr with expected value. On Solaris the 'warning' file contains also the variable being set. $ cat warning + JQ_COLORS=/ Failed to set $JQ_COLORS Exporting it in advance makes the tests succeed even on Solaris. --- tests/shtest | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/shtest b/tests/shtest index 90a96eafd6..4d6c24ef34 100755 --- a/tests/shtest +++ b/tests/shtest @@ -4,14 +4,21 @@ msys=false mingw=false +sunos=false case "$(uname -s)" in MSYS*) msys=true;; MINGW*) mingw=true;; +SunOS*) sunos=true;; esac JQ_NO_B=$JQ JQ="$JQ -b" +# On Solaris, GNU tools are available in /usr/gnu. This script should prefer +# them over the native tools, because the native versions may lack some +# command-line options the script relies on. +$sunos && PATH="/usr/gnu/bin:$PATH" + PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null SHELL=/bin/sh @@ -603,16 +610,18 @@ cmp $d/color $d/expect echo 'Failed to set $JQ_COLORS' > $d/expect_warning $JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/expect for colors in '/' '[30' '30m' '30:31m:32' '30:*:31' 'invalid'; do - JQ_COLORS=$colors \ - $JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/color 2>$d/warning + export JQ_COLORS=$colors + $JQ -Ccn '[{"a":true,"b":false},"abc",123,null]' > $d/color 2>$d/warning cmp $d/color $d/expect cmp $d/warning $d/expect_warning done +unset JQ_COLORS # Check $NO_COLOR test_no_color=true $msys && test_no_color=false $mingw && test_no_color=false +$sunos && test_no_color=false if $test_no_color && command -v script >/dev/null 2>&1; then if script -qc echo /dev/null >/dev/null 2>&1; then faketty() { script -qec "$*" /dev/null; } From 456387cb2d4fa0802e2f51558ca095dfd8e99ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Marek?= Date: Mon, 30 Mar 2026 12:51:31 +0200 Subject: [PATCH 3/5] Fix strptime day of week/year on Solaris On Solaris, strptime clears the tm structure before parsing. This breaks the sentinel logic in builtin.c, which then incorrectly assumes that strptime set tm_wday and tm_yday. Defining _STRPTIME_DONTZERO disables that behavior. As described in strptime(3C): o If _STRPTIME_DONTZERO is not defined, the tm struct is ze- roed on entry and strptime() updates the fields of the tm struct associated with the specifiers in the format string. o If _STRPTIME_DONTZERO is defined, strptime() does not zero the tm struct on entry. Additionally, for some specifiers, strptime() will use some values in the input tm struct to recalculate the date and re-assign the appropriate members of the tm struct. --- configure.ac | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 3f9f82e629..5dac42655a 100644 --- a/configure.ac +++ b/configure.ac @@ -289,6 +289,14 @@ AC_SUBST(onig_LDFLAGS) AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes]) AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno]) +dnl On Solaris, strptime clears the tm structure before parsing. This breaks the +dnl sentinel logic in builtin.c, which then incorrectly assumes that strptime set +dnl tm_wday and tm_yday. Defining _STRPTIME_DONTZERO disables that behavior. +AS_IF([test "x`uname -s 2>/dev/null`" = "xSunOS"], [ + CPPFLAGS="$CPPFLAGS -D_STRPTIME_DONTZERO" +]) + + AC_CONFIG_MACRO_DIRS([config/m4 m4]) AC_CONFIG_FILES([Makefile libjq.pc]) AC_OUTPUT From 910da6fc3cbc99dccf5e823df3e180c15befd29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Marek?= Date: Mon, 30 Mar 2026 12:54:34 +0200 Subject: [PATCH 4/5] Fix universal time on Solaris Solaris prefers the global timezone similarly to Apple. But in addition needs a 'tzset' call in order to recognise that the environment was changed. Without this change shtests fails with: + TZ=Europe/Paris + r='2024-11-14 23:35:41 +0100 CET' + [ '2024-11-14 23:35:41 +0100 CET' '!=' '2024-11-14 23:35:41 +0000 UTC' ] + [ '2024-11-14 23:35:41 +0100 CET' '!=' '2024-11-14 23:35:41 +0000 GMT' ] + echo 'Incorrectly formatted universal time' Incorrectly formatted universal time --- src/builtin.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/builtin.c b/src/builtin.c index a6a1d33302..90a3af2da9 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1783,21 +1783,29 @@ static jv f_strftime(jq_state *jq, jv a, jv b) { int fmt_not_empty = *fmt != '\0'; size_t max_size = strlen(fmt) + 100; char *buf = jv_mem_alloc(max_size); -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__sun) /* Apple Libc (as of version 1669.40.2) contains a bug which causes it to * ignore the `tm.tm_gmtoff` in favor of the global timezone. To print the * proper timezone offset we temporarily switch the TZ to UTC. */ char *tz = (tz = getenv("TZ")) != NULL ? strdup(tz) : NULL; setenv("TZ", "UTC", 1); +#endif +#if defined(__sun) + /* Solaris moreover needs call to tzset to take the changed environment into + * account ... */ + tzset(); #endif size_t n = strftime(buf, max_size, fmt, &tm); -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__sun) if (tz) { setenv("TZ", tz, 1); free(tz); } else { unsetenv("TZ"); } +#endif +#if defined(__sun) + tzset(); #endif jv_free(b); /* POSIX doesn't provide errno values for strftime() failures; weird */ From 697c432d93e63916ed490e5fadf04a973737eff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Marek?= Date: Mon, 30 Mar 2026 14:28:49 +0200 Subject: [PATCH 5/5] Do not test system jq --- tests/shtest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shtest b/tests/shtest index 4d6c24ef34..cb88745277 100755 --- a/tests/shtest +++ b/tests/shtest @@ -690,7 +690,7 @@ EOF echo "WARNING: Not testing localization" else dt1=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S') - dt2=$(LC_ALL=$l jq -nr 'now | strflocaltime("%a %d %b %Y at %H:%M:%S")') + dt2=$(LC_ALL=$l $JQ -nr 'now | strflocaltime("%a %d %b %Y at %H:%M:%S")') dt3=$(LC_ALL=$l date +'%a %d %b %Y at %H:%M:%S') if [ "$dt1" != "$dt2" ] && [ "$dt2" != "$dt3" ]; then echo "jq does not honor LC_ALL environment variable ($dt1, $dt2, $dt3)"