diff --git a/nix/ext/patches/supautils-strtol-glibc-compat.patch b/nix/ext/patches/supautils-strtol-glibc-compat.patch new file mode 100644 index 0000000000..1e3bf484c0 --- /dev/null +++ b/nix/ext/patches/supautils-strtol-glibc-compat.patch @@ -0,0 +1,32 @@ +diff --git a/src/constrained_extensions.c b/src/constrained_extensions.c +index 18e5aee..cdfb63f 100644 +--- a/src/constrained_extensions.c ++++ b/src/constrained_extensions.c +@@ -9,6 +9,27 @@ + #include "constrained_extensions.h" + #include "utils.h" + ++// atoi's inlined strtol resolves to __isoc23_strtol@GLIBC_2.38; pin strtol's oldest ++// version node instead (2.2.5 on x86_64, 2.17 on aarch64, which glibc added support ++// for at 2.17, so it has no earlier tag). ++#if defined(__linux__) && defined(__GLIBC__) && (defined(__x86_64__) || defined(__aarch64__)) ++# if defined(__x86_64__) ++# define SUPAUTILS_GLIBC_COMPAT_VER "GLIBC_2.2.5" ++# else ++# define SUPAUTILS_GLIBC_COMPAT_VER "GLIBC_2.17" ++# endif ++extern void *dlvsym(void *handle, const char *symbol, const char *version); ++__asm__(".symver dlvsym,dlvsym@" SUPAUTILS_GLIBC_COMPAT_VER); ++static int ++_supautils_compat_atoi(const char *nptr) ++{ ++ long (*fn)(const char *, char **, int) = ++ (long (*)(const char *, char **, int)) dlvsym((void *) 0, "strtol", SUPAUTILS_GLIBC_COMPAT_VER); ++ return fn ? (int) fn(nptr, NULL, 10) : 0; ++} ++#define atoi(a) _supautils_compat_atoi(a) ++#endif ++ + static JSON_ACTION_RETURN_TYPE json_array_start(void *state) { + json_constrained_extension_parse_state *parse = state; + diff --git a/nix/ext/supautils.nix b/nix/ext/supautils.nix index 361cd1b741..bd16c8919c 100644 --- a/nix/ext/supautils.nix +++ b/nix/ext/supautils.nix @@ -12,6 +12,8 @@ stdenv.mkDerivation rec { buildInputs = [ postgresql ]; + dontStrip = true; + src = fetchFromGitHub { owner = "supabase"; repo = pname; @@ -19,6 +21,8 @@ stdenv.mkDerivation rec { hash = "sha256-O2zVVVf2OFTCc4BYHuGJ67odU0TwMnTJQuz9uk+a4/0="; }; + patches = [ ./patches/supautils-strtol-glibc-compat.patch ]; + installPhase = '' mkdir -p $out/lib