I believe __cxa_guard_acquire is automatically compiled into the resulting assembly if you use static, since they are thread safe by C++11. They are not explicitly called by the code being compiled, rather they are inserted into the program by gcc when compiling. I doubt there is a way to get rid of them without a significant rewrite of the codebase you are compiling. The best you could probably do is insert -static-libgcc -static-libstdc++ into the compiler command line. Either that, or -fno-threadsafe-statics, but then the code would no longer conform to the C++ Standard
best regards, Julian On Thu, Oct 3, 2024 at 2:55 PM Michele Locati <mloc...@gmail.com> wrote: > > I'm compiling gettext and iconv for Windows with Cygwin and MinGW-w64 [1]. > > For the "shared" builds, I've seen that one executable requires > libstdc++-6.dll because it uses its two exported functions > __cxa_guard_acquire and __cxa_guard_release: > > $ dumpbin.exe /DEPENDENTS xgettext.exe /IMPORTS:libstdc++-6.dll > File Type: EXECUTABLE IMAGE > Section contains the following imports: > libstdc++-6.dll > 14004BEC8 Import Address Table > 14004B6C8 Import Name Table > 0 time date stamp > 0 Index of first forwarder reference > 16B5 __cxa_guard_acquire > 16B6 __cxa_guard_release > > Because the executable uses those two functions of libstdc++-6.dll, > and since libstdc++-6.dll requires libgcc_s_seh-1.dll and > libwinpthread-1.dll, I have to distribute 3 DLLs because of twose two > imported functions. > > In an effort to avoid that requirement, I tried to check if it's > possible to avoid the usage of two functions, but I'm not able to find > anything useful that contains "__cxa_guard_acquire": > > - in the directory where I compiled the package I only have: > $ grep -ri cxa_guard > grep: gettext-0.22.5a/build/gettext-tools/src/.libs/xgettext.exe: > binary file matches > grep: gettext-0.22.5a/build/gettext-tools/woe32dll/xgettext-c++xgettext.o: > binary file matches > > - in the whole /usr/x86_64-w64-mingw32 directory I have: > $ grep -ri cxa_guard > grep: sys-root/mingw/bin/libstdc++-6.dll: binary file matches > > So, I don't understand what are those two functions, what they do, why > they are used by my executable, and I don't know if I can avoid that > dependency. > > Anyone have a clue about that? > > Ciao, > Michele > > [1] https://github.com/mlocati/gettext-iconv-windows > > > _______________________________________________ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public