@@ -93,7 +93,29 @@ fn main() {
9393 . env ( "AR" , & ar)
9494 . env ( "RANLIB" , format ! ( "{} s" , ar. display( ) ) ) ;
9595
96- if target. contains ( "ios" ) {
96+ if target. contains ( "windows" ) {
97+ // A bit of history here, this used to be --enable-lazy-lock added in
98+ // #14006 which was filed with jemalloc in jemalloc/jemalloc#83 which
99+ // was also reported to MinGW:
100+ //
101+ // http://sourceforge.net/p/mingw-w64/bugs/395/
102+ //
103+ // When updating jemalloc to 4.0, however, it was found that binaries
104+ // would exit with the status code STATUS_RESOURCE_NOT_OWNED indicating
105+ // that a thread was unlocking a mutex it never locked. Disabling this
106+ // "lazy lock" option seems to fix the issue, but it was enabled by
107+ // default for MinGW targets in 13473c7 for jemalloc.
108+ //
109+ // As a result of all that, force disabling lazy lock on Windows, and
110+ // after reading some code it at least *appears* that the initialization
111+ // of mutexes is otherwise ok in jemalloc, so shouldn't cause problems
112+ // hopefully...
113+ //
114+ // tl;dr: make windows behave like other platforms by disabling lazy
115+ // locking, but requires passing an option due to a historical
116+ // default with jemalloc.
117+ cmd. arg ( "--disable-lazy-lock" ) ;
118+ } else if target. contains ( "ios" ) {
97119 cmd. arg ( "--disable-tls" ) ;
98120 } else if target. contains ( "android" ) {
99121 // We force android to have prefixed symbols because apparently
0 commit comments