xref: /freebsd/contrib/jemalloc/FREEBSD-upgrade (revision c43cad87172039ccf38172129c79755ea79e6102)
1#!/bin/sh
2
3# Note: you need docbook installed, as well as gmake (we need it to
4# make private_namespace.h)
5
6# git subtree merge -- not committed at this time.
7 git subtree merge -P contrib/jemalloc vendor/jemalloc
8cd contrib/jemalloc
9
10# Gut the tests, since they take up too much space.
11# Everything else can stay, but if not, add more to trim (there's
12# always a trade off between time and saved size.
13git rm -rf test msvc
14git commit --amend
15
16# kill the tests with empty files so we don't have to hack configure.ac
17mkdir -p test/include/test
18touch test/include/test/jemalloc_test_defs.h.in
19touch test/include/test/jemalloc_test.h.in
20echo 'exit 0' > test/test.sh.in
21
22# Reconfigure -- needed only to regenerate the .h files... We don't
23# use all the files generated.
24#
25# Also note: 5.2 lacks --with-lg-page-sizes, but 5.3 has it.
26# Also, there's got to be a way to not hard-wire version / hash.
27./autogen.sh --enable-xmalloc --enable-fill --enable-lazy-lock --enable-stats \
28	     --enable-utrace --with-malloc-conf=abort_conf:false \
29	     --with-xslroot=/usr/local/share/xsl/docbook --with-private-namespace=__ \
30	     --with-lg-page-sizes=12,13,14,15,16 \
31	     --with-version=5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c
32
33# Copy over the important generated .h files in configure
34cp ./include/jemalloc/jemalloc.h ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc
35git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
36cp ./include/jemalloc/jemalloc_defs.h ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc
37git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_defs.h
38
39# need to make the namespace .h files, and copy a small subset into the tree
40# These are super-awkward to generate at buildworld time. Also, we assume we
41# only have to make one of these (currently true due to current unlikely to
42# change dependencies.
43gmake include/jemalloc/internal/private_namespace.h
44for i in private_namespace.h jemalloc_internal_defs.h public_namespace.h jemalloc_preamble.h; do
45    cp include/jemalloc/internal/$i ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/
46    git add ../../lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/$i
47    rm include/jemalloc/internal/$i
48done
49# OK, commit all the generated files
50git add VERSION
51git commit --amend
52
53# Clean up the mess
54git clean -f .
55
56# Save the cheat sheet
57cp ~/jemalloc-upd FREEBSD-upgrade
58git add FREEBSD-upgrade
59git commit --amend
60
61# Remove hash.c from lib/libc/stdlib/malloc/jemalloc/Makefile.inc
62# mutex_pool.c prng.c
63# Add
64# bin_info.c san.c san_bump.c counter.c prof_data.c prof_log.c prof_recent.c prof_stats.c prof_sys.c
65# emap.c edata.c edata_cache.c pa.c pa_extra.c pac.c decay.c hpa.c hpa_hooks.c fxp.c hpdata.c pai.c
66# ecache.c ehooks.c eset.c sec.c cache_bin.c peak_event.c psset.c inspect.c exp_grow.c thread_event.c
67#
68
69# Manually comment out the following in lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
70# /* #define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
71# Add
72# #define JEMALLOC_OVERRIDE_VALLOC
73# and #include "jemalloc_FreeBSD.h"
74# With some adjustments to the old jemalloc_FreeBSD.h, but git can help
75
76# Had to manually remove
77# -#define __malloc_options_1_0 JEMALLOC_N(__malloc_options_1_0)
78# -#define _malloc_first_thread JEMALLOC_N(_malloc_first_thread)
79# -#define __malloc_message_1_0 JEMALLOC_N(__malloc_message_1_0)
80# -#define isthreaded JEMALLOC_N(isthreaded)
81#
82# Also had to remove the following to fix jemalloc 3 ABI compat
83# -#define je_allocm JEMALLOC_N(je_allocm)
84# -#define je_dallocm JEMALLOC_N(je_dallocm)
85# -#define je_nallocm JEMALLOC_N(je_nallocm)
86# -#define je_rallocm JEMALLOC_N(je_rallocm)
87# -#define je_sallocm JEMALLOC_N(je_sallocm)
88# Without the diff you end up with non-exported _je_je*allocm symbols. With you get symbols of the form:
89#  365: 000000000018e2a0   406 FUNC    WEAK   DEFAULT   14 rallocm@FBSD_1.3 (5)
90#  657: 000000000018e2a0   406 FUNC    GLOBAL DEFAULT   14 __rallocm@FBSD_1.3 (5)
91#
92