Repository navigation
Split/fuse xlocinfo.h to fix unintentional export in format.cpp - #1927
Conversation
In xwctomb.cpp, need to reorder functions. Also,provides wmemcmp(), not .
Casey Carter (CaseyCarter)
left a comment
There was a problem hiding this comment.
Looks great - thanks for picking this up.
|
Before this change we had both |
Correct - with header guards differing by one crucial underscore 🙀 Lines 6 to 8 in cb37189 Lines 6 to 8 in cb37189
No, it's eventually included by Standard headers; one path is: Line 16 in cb37189 Line 13 in cb37189 Line 11 in cb37189 At this time, I believe everything in |
|
Thanks for fixing this bug in which some STL developer - who we won't name and shame here - added an unintentional export to the import library. (Hint: it was me.) |
This affects separately compiled code, but shouldn't modify the DLL's export surface or break ABI in any other way. The second degree of caution is warranted.
In certain modules scenarios (both Standard Library Header Units, and experimental C++23 modules), compiling EXEs dragging in
format.objwould display "Creating librarymeow.liband objectmeow.exp", and the resulting EXE would export_Init_locks::operator=. This was definitely unintentional.The problem was that
format.cpp, injected into the import lib, was includingxlocinfo.h. I am not 100% certain of the exact chain of events, but it appears that in certain cases, this would drag in_Init_locks, which we don't need or want here.Separately,
xlocinfo.hwas problematic for deduplicated Standard Library Header Units, because building bothandwants to createxlocinfo.objby default. No other STL headers have the same name like this.The fix to both of these problems is to split
xlocinfo.h's contents. I'm adding a minimal header__msvc_xlocinfo_types.hpp(qualifying as a "core" header), which defines just the_Collvec,_Ctypevec, and_Cvtvecstructs, which have no further dependencies. The rest ofxlocinfo.his then fused intoxlocinfo.format.cppneeds only_Cvtvec, but by adding the two other structs into the mini-header, we can change all of thesrcfiles to include just that mini-header (they don't need the formerxlocinfo.h's function declarations to provide their function definitions).No DLL-exported functions are being modified here. This modifies
format.objin the import lib, which is effectively statically linked, so there's no compatibility concern.Additional notes:
srcfiles were already includingyvals.h(which provides our export macros), sometimes viaawint.hpp, butxmbtowc.cppandxwctomb.cppneed to explicitly include it.xwcscoll.cppwas includingforwmemcmp()but that's incorrect - it needs to include. (The VSO-661721 thing about needing to includebeforeapplies to header files only, not source files like this one.)xwctomb.cppneeds to define_Getcvt()and_Wcrtomb()before calling them, so their definitions are being reordered here. There are no other changes (and these aren't something like the initial declarations of virtual functions where the order matters).