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