Open gbaraldi opened 11 months ago
The call to clang looks something like
clang++-17 --target=i686-w64-mingw32 -isystem /usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++ -isystem /usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++/i686-w64-mingw32 -isystem /usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++/backward -isystem /usr/lib/gcc/i686-w64-mingw32/10-posix/include -isystem /usr/lib/gcc/i686-w64-mingw32
/10-posix/../../../../i686-w64-mingw32/include -L -L/usr/lib/gcc/i686-w64-mingw32/10-posix -L/usr/lib/gcc/i686-w64-mingw32/10-posix/../../../../i686-w64-mingw32/lib/../lib -L/usr/lib/gcc/i686-w64-mingw32/10-posix/../../../../i686-w64-mingw32/lib -stdlib=libstdc++ -L/usr/lib/gcc/i686-w64-mingw32/10-win32/ test.cpp -shared -v -o clang17.dl
l -O3
Paths might differ on gcc version and other things
GCC does have ABI issues too that has not been fixed yet: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105932 for an example.
Yes, but just to point out that in this case, this seems to be a clang bug, since it is clang that disagrees with msvc, while gcc uses the same ABI as clang for this particular C++ API.
In summary,
std::optional
when compiled from clang is returned from a function usingedx
andeax
, while gcc and msvc expect the selector bit to be on the stack.The setup is a bit annoying because one needs a clang + libstdc++ 32 bit mingw toolchain. But once one has that it's simple to see the difference.
clang assembly:
gcc assembly:
note the
sete %dl
vs themovb $0x0, 0x4(%eax)