Opened 19 months ago
Last modified 16 months ago
#65945 assigned defect
jemalloc fails on 10.5.8: Undefined symbols: _malloc_default_purgeable_zone, __Unwind_Resume using a modified MacPorts setup on 10.5 that is defaulting to use gcc11
Reported by: | barracuda156 | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.7.2 |
Keywords: | powerpc, leopard, snowleopard | Cc: | |
Port: | jemalloc |
Description
Sure enough, the error introduced with a recent revision (missing __Unwind_Resume
) is not specific to 10.6 PPC, but also occurs on 10.5.8. In addition, another symbol missing:
Undefined symbols: "_malloc_default_purgeable_zone", referenced from: _je_zone_register in zone.pic.o _malloc_default_purgeable_zone$non_lazy_ptr in zone.pic.o (maybe you meant: _malloc_default_purgeable_zone$non_lazy_ptr) "__Unwind_Resume", referenced from: __ZL9handleOOMmb in jemalloc_cpp.pic.o ld: symbol(s) not found collect2: error: ld returned 1 exit status make: *** [lib/libjemalloc.2.dylib] Error 1
Any ideas welcomed. I do not know why this happens. __Unwind_Resume
is sitting in libgcc_s.10.5.dylib
and should be available.
Attachments (2)
Change History (25)
Changed 19 months ago by barracuda156
comment:1 follow-up: 6 Changed 19 months ago by kencu (Ken)
comment:2 follow-up: 3 Changed 19 months ago by kencu (Ken)
Summary: | jemalloc fails on 10.5.8: Undefined symbols: _malloc_default_purgeable_zone, __Unwind_Resume → jemalloc fails on 10.5.8: Undefined symbols: _malloc_default_purgeable_zone, __Unwind_Resume using a modified MacPorts setup on 10.5 that is defaulting to use gcc11 |
---|
comment:3 Changed 19 months ago by barracuda156
Replying to kencu:
Thank you for responding!
did you make any patches to gcc11/libgcc11 at all?
No, not on 10.5.8. I would not mess with compilers unless it is absolutely necessary (not for “religious” reasons, I simply do not understand them well enough to improve).
I presume you have upgraded your default libgcc to libgcc11 as well.
Yes, sure.
what linker have you set as default? ld64-97? or ld64-127? or something from Iain's repo, per the tools PR that catap had generated a while ago that has not as yet been merged
ld64-97
.
I have not yet tried xtools
on any of the systems yet (I have them built outside Macports, but did not use catap’s port so far).
comment:4 Changed 19 months ago by barracuda156
- S. I will deal with this tomorrow or Monday the latest – no 10.5.8 setup at home. (And here I need 10.5.8, since it has an extra error to fix.)
comment:5 Changed 19 months ago by barracuda156
Output from manual linking:
36-249:jemalloc-5.3.0 svacchanda$ sudo /opt/local/bin/gcc-mp-11 -Wl,-v -shared -Wl,-install_name,/opt/local/lib/libjemalloc.2.dylib -o lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -L/opt/local/lib -Wl,-headerpad_max_install_names -m32 -lstdc++ -pthread collect2 version 11.3.0 /opt/local/bin/ld -dynamic -arch ppc -macosx_version_min 10.5.0 -o lib/libjemalloc.2.dylib -ldylib1.10.5.o -L/opt/local/lib -L/opt/local/lib/gcc11/gcc/ppc-apple-darwin9/11.3.0 -L/opt/local/lib/gcc11/gcc/ppc-apple-darwin9/11.3.0/../../.. -v -install_name /opt/local/lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -headerpad_max_install_names -lstdc++ -dylib -lemutls_w -lgcc -lSystem -lef_ppc @(#)PROGRAM:ld PROJECT:ld64-97.17 configured to support archs: i386 x86_64 ppc ppc64 armv6 armv7 Library search paths: /opt/local/lib /opt/local/lib/gcc11/gcc/ppc-apple-darwin9/11.3.0 /opt/local/lib/gcc11 /usr/lib /usr/local/lib Framework search paths: /Library/Frameworks/ /System/Library/Frameworks/ Undefined symbols: "_malloc_default_purgeable_zone", referenced from: _je_zone_register in zone.pic.o _malloc_default_purgeable_zone$non_lazy_ptr in zone.pic.o (maybe you meant: _malloc_default_purgeable_zone$non_lazy_ptr) "__Unwind_Resume", referenced from: __ZL9handleOOMmb in jemalloc_cpp.pic.o ld: symbol(s) not found collect2: error: ld returned 1 exit status
Let me try using gcc10-bootstrap
, that should exclude any mess up with libgcc
as possible cause.
UPD: here is the failure with it:
36-249:Desktop svacchanda$ cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_jemalloc/jemalloc/work/jemalloc-5.3.0 36-249:jemalloc-5.3.0 svacchanda$ sudo /opt/local/libexec/gcc10-bootstrap/bin/gcc -Wl,-v -shared -Wl,-install_name,/opt/local/lib/libjemalloc.2.dylib -o lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -lstdc++ -pthread collect2 version 10.3.0 /opt/local/bin/ld -dynamic -dylib -arch ppc -macosx_version_min 10.5.0 -weak_reference_mismatches non-weak -o lib/libjemalloc.2.dylib -ldylib1.10.5.o -L/opt/local/lib -L/opt/local/libexec/gcc10-bootstrap/lib/gcc/powerpc-apple-darwin9.8.0/10.3.0 -L/opt/local/libexec/gcc10-bootstrap/lib/gcc/powerpc-apple-darwin9.8.0/10.3.0/../../.. -v -install_name /opt/local/lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -headerpad_max_install_names -lstdc++ -lemutls_w -lgcc -lSystem -lef_ppc @(#)PROGRAM:ld PROJECT:ld64-97.17 configured to support archs: i386 x86_64 ppc ppc64 armv6 armv7 Library search paths: /opt/local/lib /opt/local/libexec/gcc10-bootstrap/lib/gcc/powerpc-apple-darwin9.8.0/10.3.0 /opt/local/libexec/gcc10-bootstrap/lib /usr/lib /usr/local/lib Framework search paths: /Library/Frameworks/ /System/Library/Frameworks/ Undefined symbols: "_malloc_default_purgeable_zone", referenced from: _je_zone_register in zone.pic.o _malloc_default_purgeable_zone$non_lazy_ptr in zone.pic.o (maybe you meant: _malloc_default_purgeable_zone$non_lazy_ptr) "__Unwind_Resume", referenced from: __ZL9handleOOMmb in jemalloc_cpp.pic.o ld: symbol(s) not found collect2: error: ld returned 1 exit status
comment:6 Changed 19 months ago by barracuda156
Replying to kencu:
So it looks like paths are correct and libs are passed to the linker, and __Unwind_Resume
is here:
36-249:jemalloc-5.3.0 svacchanda$ nm -arch ppc -g /opt/local/libexec/gcc10-bootstrap/lib/libstdc++.6.dylib | grep _Unw U __Unwind_DeleteException U __Unwind_GetDataRelBase U __Unwind_GetIPInfo U __Unwind_GetLanguageSpecificData U __Unwind_GetRegionStart U __Unwind_GetTextRelBase U __Unwind_RaiseException U __Unwind_Resume U __Unwind_Resume_or_Rethrow U __Unwind_SetGR U __Unwind_SetIP
And here:
36-249:jemalloc-5.3.0 svacchanda$ nm -arch ppc -g /opt/local/libexec/gcc10-bootstrap/lib/libgcc_ehs.1.1.dylib | grep _Unw 00003db8 T __Unwind_Backtrace 00003d9c T __Unwind_DeleteException 000038c4 T __Unwind_FindEnclosingFunction 000057c8 T __Unwind_Find_FDE 00003bd0 T __Unwind_ForcedUnwind 000037f4 T __Unwind_GetCFA 000038f8 T __Unwind_GetDataRelBase 00003778 T __Unwind_GetGR 00003890 T __Unwind_GetIP 00003898 T __Unwind_GetIPInfo 000038b4 T __Unwind_GetLanguageSpecificData 000038bc T __Unwind_GetRegionStart 00003900 T __Unwind_GetTextRelBase 00003a0c T __Unwind_RaiseException 00003c68 T __Unwind_Resume 00003d00 T __Unwind_Resume_or_Rethrow 000037fc T __Unwind_SetGR 000038ac T __Unwind_SetIP
The latter seems to be linked to libgcc_s.1.dylib
:
36-249:jemalloc-5.3.0 svacchanda$ otool -Lv /opt/local/libexec/gcc10-bootstrap/lib/libgcc_s.1.dylib /opt/local/libexec/gcc10-bootstrap/lib/libgcc_s.1.dylib: /opt/local/libexec/gcc10-bootstrap/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) time stamp 1 Thu Jan 1 08:00:01 1970 /opt/local/libexec/gcc10-bootstrap/lib/libgcc_s.1.1.dylib (compatibility version 1.0.0, current version 1.1.0) time stamp 2 Thu Jan 1 08:00:02 1970 /opt/local/libexec/gcc10-bootstrap/lib/libgcc_ehs.1.1.dylib (compatibility version 1.0.0, current version 1.1.0) time stamp 2 Thu Jan 1 08:00:02 1970
I do not know what to do now :)
comment:7 follow-up: 10 Changed 19 months ago by kencu (Ken)
what is in gcc10-bootstrap is not relevant here, of course….
edit: apologies, I just reread you and it seems you switched to gcc10-bootstrap purposefully.
comment:8 Changed 19 months ago by kencu (Ken)
the unwinder symbols for newer libgcc versions are in libgcc_ehs, but I don’t see that library on your link line… perhaps try adding it manually to the link as a proof-of-concept.
see line 47+ here
https://fossies.org/linux/gcc/libgcc/config/t-slibgcc-darwin
comment:9 Changed 19 months ago by kencu (Ken)
I wonder if the root issue here might be that the C compiler instead of the C++ compiler has been called to do the link.
Will have to check that.
comment:10 Changed 19 months ago by barracuda156
Replying to kencu:
what is in gcc10-bootstrap is not relevant here, of course….
edit: apologies, I just reread you and it seems you switched to gcc10-bootstrap purposefully.
Yes, to rule out incorrect symlynks or w/e in libgcc
. (While I did not patch gcc
on 10.5.8, I had to reinstall it several times due to +universal
not working properly, so to be on a safe side I checked with bootstrap version of it. But same error anyway.)
comment:11 Changed 19 months ago by kencu (Ken)
OK, so I can reproduce this on 10.13 if I build jemalloc like this:
sudo port -v destroot jemalloc configure.compiler=macports-gcc-12 macosx_deployment_target=10.5
/opt/local/bin/gcc-mp-12 -shared -Wl,-install_name,/opt/local/lib/libjemalloc.2.dylib -o lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lstdc++ -pthread Undefined symbols for architecture x86_64: "__Unwind_Resume", referenced from: __ZL9handleOOMmb in jemalloc_cpp.pic.o ld: symbol(s) not found for architecture x86_64
let me see now....
comment:12 Changed 19 months ago by kencu (Ken)
using gcc to do the link fails manually:
$ MACOSX_DEPLOYMENT_TARGET='10.5' /opt/local/bin/gcc-mp-12 -shared -Wl,-install_name,/opt/local/lib/libjemalloc.2.dylib -o lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lstdc++ -pthread Undefined symbols for architecture x86_64: "__Unwind_Resume", referenced from: __ZL9handleOOMmb in jemalloc_cpp.pic.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status
but using g++ to do the link succeeds as it should:
$ MACOSX_DEPLOYMENT_TARGET='10.5' /opt/local/bin/g++-mp-12 -shared -Wl,-install_name,/opt/local/lib/libjemalloc.2.dylib -o lib/libjemalloc.2.dylib src/jemalloc.pic.o src/arena.pic.o src/background_thread.pic.o src/base.pic.o src/bin.pic.o src/bin_info.pic.o src/bitmap.pic.o src/buf_writer.pic.o src/cache_bin.pic.o src/ckh.pic.o src/counter.pic.o src/ctl.pic.o src/decay.pic.o src/div.pic.o src/ecache.pic.o src/edata.pic.o src/edata_cache.pic.o src/ehooks.pic.o src/emap.pic.o src/eset.pic.o src/exp_grow.pic.o src/extent.pic.o src/extent_dss.pic.o src/extent_mmap.pic.o src/fxp.pic.o src/san.pic.o src/san_bump.pic.o src/hook.pic.o src/hpa.pic.o src/hpa_hooks.pic.o src/hpdata.pic.o src/inspect.pic.o src/large.pic.o src/log.pic.o src/malloc_io.pic.o src/mutex.pic.o src/nstime.pic.o src/pa.pic.o src/pa_extra.pic.o src/pai.pic.o src/pac.pic.o src/pages.pic.o src/peak_event.pic.o src/prof.pic.o src/prof_data.pic.o src/prof_log.pic.o src/prof_recent.pic.o src/prof_stats.pic.o src/prof_sys.pic.o src/psset.pic.o src/rtree.pic.o src/safety_check.pic.o src/sc.pic.o src/sec.pic.o src/stats.pic.o src/sz.pic.o src/tcache.pic.o src/test_hooks.pic.o src/thread_event.pic.o src/ticker.pic.o src/tsd.pic.o src/witness.pic.o src/zone.pic.o src/jemalloc_cpp.pic.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lstdc++ -pthread $ ls lib/* lib/libjemalloc.2.dylib lib/libjemalloc_pic.a
and the difference is that when you use g++-mp-12 to do the link, it adds these two extra libraries automatically, that are not added when you use gcc-mp-12 to do the link:
-lgcc_s.1.1 -lgcc_s.10.5
So, as expected above, the issue is being caused by the build using the GCC C compiler instead of the GCC C++ compiler to link code that uses c++.
comment:13 Changed 19 months ago by kencu (Ken)
There are a number of builds in MacPorts that will show this issue -- an error when linking with the C compiler instead of the C++ compiler, when code is using c++. Most of these builds have mixed c and c++ code in them, like jemalloc has.
The error does not show up on newer systems, or systems that build with clang instead of gcc, or sometimes for other various reasons.
But using the C compiler to generate the link for c++ code will often fail at times, at least on some systems.
There is nothing wrong with GCC; this is not Iain's problem. The issue is with jemalloc, and their build should use $(CXX) instead of $(CC) as the link compiler.
comment:14 follow-up: 15 Changed 19 months ago by kencu (Ken)
try this patch:
--- Makefile.in.orig 2022-10-10 10:58:13.000000000 -0700 +++ Makefile.in 2022-10-10 10:59:54.000000000 -0700 @@ -513,7 +513,7 @@ $(objroot)lib/$(LIBJEMALLOC).$(SOREV) : $(if $(PIC_CFLAGS),$(C_PIC_OBJS),$(C_OBJS)) $(if $(PIC_CFLAGS),$(CPP_PIC_OBJS),$(CPP_OBJS)) @mkdir -p $(@D) - $(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS) + $(CXX) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS) $(objroot)lib/$(LIBJEMALLOC)_pic.$(A) : $(C_PIC_OBJS) $(CPP_PIC_OBJS) $(objroot)lib/$(LIBJEMALLOC).$(A) : $(C_OBJS) $(CPP_OBJS)
Changed 19 months ago by kencu (Ken)
Attachment: | patch-jemalloc-link-with-CXX.diff added |
---|
comment:15 Changed 19 months ago by barracuda156
Replying to kencu:
try this patch:
Thank you! This solves __Unwind_Resume
error (and likely gonna fix the build on 10.6). On 10.5.8 the second missing symbol prevents the completion:
Undefined symbols: "_malloc_default_purgeable_zone", referenced from: _je_zone_register in zone.pic.o _malloc_default_purgeable_zone$non_lazy_ptr in zone.pic.o (maybe you meant: _malloc_default_purgeable_zone$non_lazy_ptr) ld: symbol(s) not found collect2: error: ld returned 1 exit status make: *** [lib/libjemalloc.2.dylib] Error 1 make: *** Waiting for unfinished jobs....
comment:16 follow-up: 19 Changed 19 months ago by barracuda156
As for your patch above, can we submit it to upstream?
comment:17 Changed 19 months ago by kencu (Ken)
as malloc_default_purgeable_zone is only available on 10.6 and up, you need to build against the MacOSX10.6.sdk, at least.
The code already does a NULL check on that weak function, and has fallbacks for older systems, still, which is kind of a miracle.
https://github.com/jemalloc/jemalloc/blob/12cd13cd418512d9e7596921ccdb62e25a103f87/src/zone.c#L80
To make it build against an older SDK like the MacOSX10.5.sdk you will need to add #ifdefs to the src/zone.c file to avoid malloc_default_purgeable_zone instead.
That is certainly doable, but will require a bit of work for you to accomplish.
comment:18 Changed 19 months ago by kencu (Ken)
Funny, though -- I think this function should still be compileable and linkable if the function is declared weak. ie, because it is declared weak, the link should not be failing above.
I'll have to read a bit more sometime about why this is not working here.
For now, avoiding the function is the more obvious thing to do, at least until you (or I) can sort out why the weak function reference is failing to link...
comment:19 Changed 19 months ago by kencu (Ken)
Replying to barracuda156:
As for your patch above, can we submit it to upstream?
probably could, yes.
comment:20 Changed 19 months ago by kencu (Ken)
to use weak linking, where the symbol is not available at build time, with macOS, it seems you need to add this flag during linking:
-undefined dynamic_lookup
so the fix would be to add something like this when building on < 10.6:
configure.ldflags-append '-Wl,-undefined,dynamic_lookup'
comment:21 Changed 19 months ago by barracuda156
Next bunch of errors on 10.5.8:
:info:build src/pages.c: In function 'pages_huge_impl': :info:build src/pages.c:498:16: error: variable 'm' has initializer but incomplete type :info:build 498 | struct memcntl_mha m = {0}; :info:build | ^~~~~~~~~~~ :info:build src/pages.c:498:33: warning: excess elements in struct initializer :info:build 498 | struct memcntl_mha m = {0}; :info:build | ^ :info:build src/pages.c:498:33: note: (near initialization for 'm') :info:build src/pages.c:498:28: error: storage size of 'm' isn't known :info:build 498 | struct memcntl_mha m = {0}; :info:build | ^ :info:build src/pages.c:499:21: error: 'MHA_MAPSIZE_VA' undeclared (first use in this function) :info:build 499 | m.mha_cmd = MHA_MAPSIZE_VA; :info:build | ^~~~~~~~~~~~~~ :info:build src/pages.c:499:21: note: each undeclared identifier is reported only once for each function it appears in :info:build src/pages.c:501:17: warning: implicit declaration of function 'memcntl'; did you mean 'fcntl'? [-Wimplicit-function-declaration] :info:build 501 | return (memcntl(addr, size, MC_HAT_ADVISE, (caddr_t)&m, 0, 0) == 0); :info:build | ^~~~~~~ :info:build | fcntl :info:build src/pages.c:501:37: error: 'MC_HAT_ADVISE' undeclared (first use in this function) :info:build 501 | return (memcntl(addr, size, MC_HAT_ADVISE, (caddr_t)&m, 0, 0) == 0); :info:build | ^~~~~~~~~~~~~
Apparently the following macro detects availability wrongly:
ac_fn_c_check_func "$LINENO" "memcntl" "ac_cv_func_memcntl" if test "x$ac_cv_func_memcntl" = xyes; then : have_memcntl="1" else have_memcntl="0" fi if test "x$have_memcntl" = "x1" ; then $as_echo "#define JEMALLOC_HAVE_MEMCNTL " >>confdefs.h fi
And this code breaks down:
static bool pages_huge_impl(void *addr, size_t size, bool aligned) { if (aligned) { assert(HUGEPAGE_ADDR2BASE(addr) == addr); assert(HUGEPAGE_CEILING(size) == size); } #if defined(JEMALLOC_HAVE_MADVISE_HUGE) return (madvise(addr, size, MADV_HUGEPAGE) != 0); #elif defined(JEMALLOC_HAVE_MEMCNTL) struct memcntl_mha m = {0}; m.mha_cmd = MHA_MAPSIZE_VA; m.mha_pagesize = HUGEPAGE; return (memcntl(addr, size, MC_HAT_ADVISE, (caddr_t)&m, 0, 0) == 0); #else return true; #endif }
comment:22 Changed 19 months ago by barracuda156
And this fails too on 10.5.8:
:info:build include/jemalloc/internal/jemalloc_internal_inlines_a.h: In function 'malloc_cpuid_t malloc_getcpu()': :info:build include/jemalloc/internal/jemalloc_internal_inlines_a.h:16:32: error: 'sched_getcpu' was not declared in this scope :info:build 16 | return (malloc_cpuid_t)sched_getcpu(); :info:build | ^~~~~~~~~~~~
comment:23 Changed 16 months ago by kencu (Ken)
Owner: | kencu deleted |
---|
I see you've modified your system, which in your case is probably OK as by now you know what might need to be done. Let me just clarify a few points, though.
With all those things clarified, the way that I usually approach a problem like this first is to try the link manually.
Your failing link line is this:
it looks benign enough, ie it looks like it should work. So go into the directory where the link is being done, which I think is here:
and then try the link manually. It may well fail, but we can at least try it:
when it fails (it will probably fail), try adding some verbosity flags to the linker, which look like this
-Wl,-v
:ie:
what you are looking for here is to see if the libraries that you assume are being linked in are really being linked in, and what, if any, errors are being found by the linker in so doing.
In particular, you want to see that
libgcc_s.10.5.dylib
is actually being linked in on the link line.Once you get that far, you know that things should be working, and that all the requested libraries are really being linked in. So that narrows down the issue quite a bit.
If that all works fine, then what I have found usually causes the errors you see is that the deployment target is not actually making it through to the compiler and linker in all the stages. By default, these tools will usually assume a deployment target of 10.6 these days, in particular the linker, eg:
Your build is indeed setting
MACOSX_DEPLOYMENT_TARGET='10.5'
and that does usually work to put the compiler and linker into the proper mode, but environment variables don't always make it through to every stage of the build like you would like them to.Sometimes, you have to pass the deployment target as a configure argument instead. That looks like this:
and can be added to the cflags or cxxflags as required. Sometimes you also need to pass that to the linker, although the compiler will normally do that for you (you can see that with the -Wl,-v link argument again). The linker flag is slightly different, eg:
If you want to pass that directly to the linker when doing a manual link, you can add it to the gcc11 link line like this: