Bug 1590624 - Define a __imp_ alias for _strdup for mingw-clang r=dmajor
authorTom Ritter <tom@mozilla.com>
Thu, 12 Dec 2019 06:38:37 +0000
changeset 506640 c2cffffd5ca6a115cc114bdd8a2a6c695c0ef087
parent 506639 df32eb1fdc8d5aa6c75cbf9a23d92b80507a83c2
child 506641 9debfec342dacb5c92d2a2d3966fda8e3c0ca29f
push id102972
push usertritter@mozilla.com
push dateThu, 12 Dec 2019 07:45:29 +0000
treeherderautoland@c2cffffd5ca6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1590624
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1590624 - Define a __imp_ alias for _strdup for mingw-clang r=dmajor This is affected by the same problem detailed in the comment. Differential Revision: https://phabricator.services.mozilla.com/D54532
memory/build/mozmemory_wrap.cpp
--- a/memory/build/mozmemory_wrap.cpp
+++ b/memory/build/mozmemory_wrap.cpp
@@ -116,25 +116,30 @@ char* strdup(const char* src)
     __attribute__((alias(MOZ_STRINGIFY(strdup_impl))));
 char* _strdup(const char* src)
     __attribute__((alias(MOZ_STRINGIFY(strdup_impl))));
 wchar_t* wcsdup(const wchar_t* src)
     __attribute__((alias(MOZ_STRINGIFY(wcsdup_impl))));
 wchar_t* _wcsdup(const wchar_t* src)
     __attribute__((alias(MOZ_STRINGIFY(wcsdup_impl))));
 
-// libc++.a contains references to __imp__aligned_malloc (because it
-// is declared dllimport in the headers.)
+// jemalloc has _aligned_malloc, and friends. libc++.a contains
+// references to __imp__aligned_malloc (and friends) because it
+// is declared dllimport in the headers.
 //
-// The linker sees jemalloc's _aligned_malloc symbol in your objects,
-// then libc++.a comes along and needs __imp__aligned_malloc, which
+// The linker sees jemalloc's _aligned_malloc symbol in our objects,
+// but then libc++.a comes along and needs __imp__aligned_malloc, which
 // pulls in those parts of libucrt.a (or libmsvcrt.a in practice),
 // which define both __imp__aligned_malloc and _aligned_malloc, and
-// this causes a conflict.
+// this causes a conflict.  (And repeat for each of the symbols defined
+// here.)
 //
 // The fix is to define not only an _aligned_malloc symbol (via an
 // alias), but also define the __imp__aligned_malloc pointer to it.
+// This prevents those parts of libucrt from being pulled in and causing
+// conflicts.
 // This is done with __MINGW_IMP_SYMBOL to handle x86/x64 differences.
 void (*__MINGW_IMP_SYMBOL(_aligned_free))(void*) = _aligned_free;
 void* (*__MINGW_IMP_SYMBOL(_aligned_malloc))(size_t, size_t) = _aligned_malloc;
+char* (*__MINGW_IMP_SYMBOL(_strdup))(const char* src) = _strdup;
 MOZ_END_EXTERN_C
 #  endif
 #endif  // XP_WIN