Closed Bug 1041322 Opened 10 years ago Closed 10 years ago

mozalloc cannot be built with static linking

Categories

(Core :: Memory Allocator, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: ehsan.akhgari, Unassigned)

References

Details

If I apply the following diff, mozalloc fails to link like below: diff --git a/config/config.mk b/config/config.mk index 17eed05..59fb6c0e 100644 --- a/config/config.mk +++ b/config/config.mk @@ -303,6 +303,8 @@ endif # NS_TRACE_MALLOC || MOZ_DMD endif # MOZ_DEBUG +USE_STATIC_LIBS = 1 + # We don't build a static CRT when building a custom CRT, # it appears to be broken. So don't link to jemalloc if # the Makefile wants static CRT linking. mozmake[1]: Entering directory 'c:/moz/src/obj-ff-dbg/memory/mozalloc' mozalloc.dll c:/moz/src/obj-ff-dbg/_virtualenv/Scripts/python.exe c:/moz/src/config/expandlibs_exec.py --depend .deps/mozalloc.dll.pp --target mozalloc.dll --uselist -- link -NOLOGO -DLL -OUT:mozalloc.dll -PDB:mozalloc.pdb -SUBSYSTEM:WINDOWS -MACHINE:X86 msvc_raise_wrappers.obj msvc_throw_wrapper.obj Unified_cpp_memory_mozalloc0.obj ./module.res -LARGEADDRESSAWARE -NXCOMPAT -DYNAMICBASE -SAFESEH -DEBUG -DEBUGTYPE:CV kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib Executing: link -NOLOGO -DLL -OUT:mozalloc.dll -PDB:mozalloc.pdb -SUBSYSTEM:WINDOWS -MACHINE:X86 @c:\moz\src\obj-ff-dbg\memory\mozalloc\tmpkdb2gy.list module.res -LARGEADDRESSAWARE -NXCOMPAT -DYNAMICBASE -SAFESEH -DEBUG -DEBUGTYPE:CV kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib c:\moz\src\obj-ff-dbg\memory\mozalloc\tmpkdb2gy.list: msvc_raise_wrappers.obj msvc_throw_wrapper.obj Unified_cpp_memory_mozalloc0.obj Creating library mozalloc.lib and object mozalloc.exp Unified_cpp_memory_mozalloc0.obj : error LNK2019: unresolved external symbol _posix_memalign referenced in function "public: bool __thiscall mozilla::VolatileBuffer::Init(unsigned int,unsigned int)" (?Init@VolatileBuffer@mozilla@@QAE_NII@Z) Unified_cpp_memory_mozalloc0.obj : error LNK2019: unresolved external symbol _malloc_usable_size referenced in function _moz_malloc_usable_size mozalloc.dll : fatal error LNK1120: 2 unresolved externals c:/moz/src/config/rules.mk:872: recipe for target 'mozalloc.dll' failed glandium, any ideas how to resolve this? I know that this may not be a supported build configuration but ASAN requires statically linking against the CRT runtime, so even a hack to get past this point is hugely appreciated.
Flags: needinfo?(mh+mozilla)
USE_STATIC_LIBS empties MOZ_GLUE_LDFLAGS. That's what breaks your build.
Flags: needinfo?(mh+mozilla)
(In reply to Mike Hommey [:glandium] from comment #1) > USE_STATIC_LIBS empties MOZ_GLUE_LDFLAGS. That's what breaks your build. Thanks, I moved that line after where we empty MOZ_GLUE_LDFLAGS and got past that error. I also had to add --disable-jemalloc in my mozconfig, and had to nuke out the places in configure.in where we set MOZ_MEMORY and MOZ_MEMORY_WINDOWS in configure.in, and got to a point where we fail to link libxul with: 25:44.82 MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj) 25:44.82 25:44.82 MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) 25:44.82 25:44.83 MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj) 25:44.83 25:44.83 Creating library xul.lib and object xul.exp 25:44.83 25:44.83 LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 25:44.83 25:44.83 xul.dll : fatal error LNK1169: one or more multiply defined symbols found Which seems to suggest that we are mixing -MT and -MD... :( Do you know any way to find out where this is happening? I have disabled ICU with --without-intl-api, and have fixed js/src/ctypes/libffi/msvcc.sh so far...
Flags: needinfo?(mh+mozilla)
Ah, it's NSPR. Filed bug 1043082.
OK, I finally got to a build linking statically against the CRT. I'll file different bugs for adding support for that.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(mh+mozilla)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.