@@ -180,6 +180,54 @@ parser.add_option('--openssl-system-ca-path',
180180 help=' Use the specified path to system CA (PEM format) in addition to '
181181 ' the OpenSSL supplied CA store or compiled-in Mozilla CA copy.' )
182182
183+ shared_optgroup.add_option(' --shared-jemalloc' ,
184+ action=' store_true' ,
185+ dest=' shared_jemalloc' ,
186+ help=' Use jemalloc instead of libc malloc'
187+ ' Use this option for custom builds, after examining the impact'
188+ ' on performance. Ensure that the native add-on is linked to either'
189+ ' libc or jemalloc and uses the same allocator to alloc and free.' )
190+
191+ shared_optgroup.add_option(' --shared-jemalloc-includes' ,
192+ action=' store' ,
193+ dest=' shared_jemalloc_includes' ,
194+ help=' directory containing lib jemalloc header files' )
195+
196+ shared_optgroup.add_option(' --shared-jemalloc-libname' ,
197+ action=' store' ,
198+ dest=' shared_jemalloc_libname' ,
199+ default=' jemalloc' ,
200+ help=' alternative lib name to link to [default: %default]' )
201+
202+ shared_optgroup.add_option(' --shared-jemalloc-libpath' ,
203+ action=' store' ,
204+ dest=' shared_jemalloc_libpath' ,
205+ help=' directory to search for the jemalloc lib' )
206+
207+ shared_optgroup.add_option(' --shared-tcmalloc' ,
208+ action=' store_true' ,
209+ dest=' shared_tcmalloc' ,
210+ help=' Use tcmalloc instead of libc malloc'
211+ ' Use this option for custom builds, after examining the impact'
212+ ' on performance. Ensure that the native add-on is linked to either'
213+ ' libc or jemalloc and uses the same allocator to alloc and free.' )
214+
215+ shared_optgroup.add_option(' --shared-tcmalloc-includes' ,
216+ action=' store' ,
217+ dest=' shared_tcmalloc_includes' ,
218+ help=' directory containing lib tcmalloc header files' )
219+
220+ shared_optgroup.add_option(' --shared-tcmalloc-libname' ,
221+ action=' store' ,
222+ dest=' shared_tcmalloc_libname' ,
223+ default=' tcmalloc' ,
224+ help=' alternative lib name to link to [default: %default]' )
225+
226+ shared_optgroup.add_option(' --shared-tcmalloc-libpath' ,
227+ action=' store' ,
228+ dest=' shared_tcmalloc_libpath' ,
229+ help=' directory to search for the tcmalloc lib' )
230+
183231shared_optgroup.add_option(' --shared-http-parser' ,
184232 action=' store_true' ,
185233 dest=' shared_http_parser' ,
@@ -1443,6 +1491,11 @@ configure_library('http_parser', output)
14431491configure_library(' libuv' , output)
14441492configure_library(' libcares' , output)
14451493configure_library(' nghttp2' , output)
1494+
1495+ # we don't want to link to both tcmalloc and jemalloc
1496+ if bool(options.shared_jemalloc) ! = bool(options.shared_tcmalloc):
1497+ configure_library(' jemalloc' , output)
1498+ configure_library(' tcmalloc' , output)
14461499# stay backwards compatible with shared cares builds
14471500output[' variables' ][' node_shared_cares' ] = \
14481501 output[' variables' ].pop(' node_shared_libcares' )
0 commit comments