Skip to content

Instantly share code, notes, and snippets.

@ibrahima
Last active April 7, 2025 23:20
Show Gist options
  • Save ibrahima/fcc65e084e79b6519ac6fb0da5005378 to your computer and use it in GitHub Desktop.
Save ibrahima/fcc65e084e79b6519ac6fb0da5005378 to your computer and use it in GitHub Desktop.
Patch for jemalloc 3.6.0 to allow it to work with newer versions of glibc
diff -ruN jemalloc-3.6.0-pristine/configure jemalloc-3.6.0-patched/configure
--- jemalloc-3.6.0-pristine/configure 2014-03-31 09:38:51.000000000 -0700
+++ jemalloc-3.6.0-patched/configure 2025-04-07 16:03:09.996708990 -0700
@@ -5079,7 +5079,7 @@
main ()
{
static __thread int
- __attribute__((tls_model("initial-exec"))) foo;
+ __attribute__((tls_model("initial-exec"), unused)) foo;
foo = 0;
;
return 0;
diff -ruN jemalloc-3.6.0-pristine/configure.ac jemalloc-3.6.0-patched/configure.ac
--- jemalloc-3.6.0-pristine/configure.ac 2014-03-31 09:37:49.000000000 -0700
+++ jemalloc-3.6.0-patched/configure.ac 2025-04-07 16:03:17.274716777 -0700
@@ -387,7 +387,7 @@
JE_CFLAGS_APPEND([-Werror])
JE_COMPILABLE([tls_model attribute], [],
[static __thread int
- __attribute__((tls_model("initial-exec"))) foo;
+ __attribute__((tls_model("initial-exec"), unused)) foo;
foo = 0;],
[je_cv_tls_model])
CFLAGS="${SAVED_CFLAGS}"
@ibrahima
Copy link
Author

ibrahima commented Apr 7, 2025

This is based on GafferHQ/dependencies#263 which is in turn based on jemalloc/jemalloc#124. This was helpful for getting jemalloc 3.6.0 working with newer versions of Ubuntu, at least when used via LD_PRELOAD.

Apply like so:

patch -p1 < jemalloc_initial_exec.patch

The p1 removes the initial directory.

This patches both the configure script and configure.ac, so that if you use autogen.sh the changes will be reflected, and if you use the bundled configure script from the source tarball, that will also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment