Skip to content
Draft
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
7 changes: 6 additions & 1 deletion nix/overlays/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ self, ... }:
{
flake.overlays.default = final: _prev: {
flake.overlays.default = final: prev: {
# NOTE: add any needed overlays here. in theory we could
# pull them from the overlays/ directory automatically, but we don't
# want to have an arbitrary order, since it might matter. being
Expand All @@ -17,6 +17,11 @@

xmrig = throw "The xmrig package has been explicitly disabled in this flake.";

# Force the pre-2.42 glibc symbol version for cfgetospeed so the portable CLI bundle keeps working on older-glibc hosts.
ncurses = prev.ncurses.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ ./patches/ncurses-cfgetospeed-old-glibc-compat.patch ];
});

cargo-pgrx = final.callPackage ../cargo-pgrx/default.nix {
inherit (final) lib;
inherit (final) fetchCrate;
Expand Down
127 changes: 127 additions & 0 deletions nix/overlays/patches/ncurses-cfgetospeed-old-glibc-compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
--- a/ncurses/tinfo/lib_baudrate.c 2026-07-31 08:24:24
+++ b/ncurses/tinfo/lib_baudrate.c 2026-07-31 12:03:39
@@ -45,6 +45,39 @@
#endif

/*
+ * On Linux/glibc, resolve cfgetospeed to the old (functionally identical)
+ * GLIBC_2.17 symbol version at runtime, so binaries built against newer
+ * glibc still run on hosts with older glibc that only export that version.
+ * Done via dlvsym rather than a link-time .symver directive, since the
+ * latter conflicts with ncurses' own --version-script linking. Both dlvsym
+ * and its dlsym fallback are declared directly (rather than via
+ * <dlfcn.h>/_GNU_SOURCE, which may already be locked in by earlier headers
+ * in this file), and neither path calls the bare cfgetospeed identifier, so
+ * no versioned reference to it survives in the compiled output.
+ */
+#if defined(__linux__) && defined(__GLIBC__)
+extern void *dlvsym(void *handle, const char *symbol, const char *version);
+extern void *dlsym(void *handle, const char *symbol);
+static speed_t
+_supabase_compat_cfgetospeed(const struct termios *t)
+{
+ static int inited = 0;
+ static speed_t (*fn)(const struct termios *) = NULL;
+ if (!inited) {
+ fn = (speed_t (*)(const struct termios *))
+ dlvsym((void *) 0, "cfgetospeed", "GLIBC_2.17");
+ if (!fn) {
+ fn = (speed_t (*)(const struct termios *))
+ dlsym((void *) 0, "cfgetospeed");
+ }
+ inited = 1;
+ }
+ return fn ? fn(t) : 0;
+}
+#define cfgetospeed(t) _supabase_compat_cfgetospeed(t)
+#endif
+
+/*
* These systems use similar header files, which define B1200 as 1200, etc.,
* but can be overridden by defining USE_OLD_TTY so B1200 is 9, which makes all
* of the indices up to B115200 fit nicely in a 'short', allowing us to retain
--- a/ncurses/tinfo/tinfo_driver.c 2026-07-31 08:24:24
+++ b/ncurses/tinfo/tinfo_driver.c 2026-07-31 12:03:50
@@ -37,6 +37,39 @@
#include <tic.h>
#include <termcap.h> /* ospeed */

+/*
+ * On Linux/glibc, resolve cfgetospeed to the old (functionally identical)
+ * GLIBC_2.17 symbol version at runtime, so binaries built against newer
+ * glibc still run on hosts with older glibc that only export that version.
+ * Done via dlvsym rather than a link-time .symver directive, since the
+ * latter conflicts with ncurses' own --version-script linking. Both dlvsym
+ * and its dlsym fallback are declared directly (rather than via
+ * <dlfcn.h>/_GNU_SOURCE, which may already be locked in by earlier headers
+ * in this file), and neither path calls the bare cfgetospeed identifier, so
+ * no versioned reference to it survives in the compiled output.
+ */
+#if defined(__linux__) && defined(__GLIBC__)
+extern void *dlvsym(void *handle, const char *symbol, const char *version);
+extern void *dlsym(void *handle, const char *symbol);
+static speed_t
+_supabase_compat_cfgetospeed(const struct termios *t)
+{
+ static int inited = 0;
+ static speed_t (*fn)(const struct termios *) = NULL;
+ if (!inited) {
+ fn = (speed_t (*)(const struct termios *))
+ dlvsym((void *) 0, "cfgetospeed", "GLIBC_2.17");
+ if (!fn) {
+ fn = (speed_t (*)(const struct termios *))
+ dlsym((void *) 0, "cfgetospeed");
+ }
+ inited = 1;
+ }
+ return fn ? fn(t) : 0;
+}
+#define cfgetospeed(t) _supabase_compat_cfgetospeed(t)
+#endif
+
#if HAVE_NANOSLEEP
#include <time.h>
#if HAVE_SYS_TIME_H
--- a/progs/tset.c 2026-07-31 08:24:24
+++ b/progs/tset.c 2026-07-31 12:03:59
@@ -89,6 +89,40 @@
#include <reset_cmd.h>
#include <termcap.h>
#include <transform.h>
+
+/*
+ * On Linux/glibc, resolve cfgetospeed to the old (functionally identical)
+ * GLIBC_2.17 symbol version at runtime, so binaries built against newer
+ * glibc still run on hosts with older glibc that only export that version.
+ * Done via dlvsym rather than a link-time .symver directive, since the
+ * latter conflicts with ncurses' own --version-script linking. Both dlvsym
+ * and its dlsym fallback are declared directly (rather than via
+ * <dlfcn.h>/_GNU_SOURCE, which may already be locked in by earlier headers
+ * in this file), and neither path calls the bare cfgetospeed identifier, so
+ * no versioned reference to it survives in the compiled output.
+ */
+#if defined(__linux__) && defined(__GLIBC__)
+extern void *dlvsym(void *handle, const char *symbol, const char *version);
+extern void *dlsym(void *handle, const char *symbol);
+static speed_t
+_supabase_compat_cfgetospeed(const struct termios *t)
+{
+ static int inited = 0;
+ static speed_t (*fn)(const struct termios *) = NULL;
+ if (!inited) {
+ fn = (speed_t (*)(const struct termios *))
+ dlvsym((void *) 0, "cfgetospeed", "GLIBC_2.17");
+ if (!fn) {
+ fn = (speed_t (*)(const struct termios *))
+ dlsym((void *) 0, "cfgetospeed");
+ }
+ inited = 1;
+ }
+ return fn ? fn(t) : 0;
+}
+#define cfgetospeed(t) _supabase_compat_cfgetospeed(t)
+#endif
+
#include <tty_settings.h>

#if HAVE_GETTTYNAM
Loading