On Sun, 15 Feb 2026, Kirill Makurin wrote:

Pali Rohár <[email protected]> wrote:
By observing this behavior, my idea was that it is because of library
linking order, which is hardcoded in gcc spec file.

I feel like adding --start-group/--end-group around mingw-w64's -l flags in gcc 
spec should be a good solution.

This would be my preference as well. Sure, even if that was done, we couldn't probably rely on it immediately - but by making such a change, we could at least consider relying on it at some point in the future.

FWIW, when linking with LLD rather than GNU ld, then it works as if --start-group was used implicitly anywhere; LLD (and link.exe) always looks through all mentioned static libraries for symbols, even ones only mentioned before the current one.

But if it's too annoying to do, that's unfortunate.

Earlier, we've worked around similar issues by repeating the relevant libraries more times - see e.g. https://github.com/gcc-mirror/gcc/commit/850533ab160ef40eccfd039e1e3b138cf26e76b8. And when looking at the final list of libraries passed to the linker, with e.g. "gcc -v test.c -o test.exe", there's lots of repetitions of things. But repeating things more times to fix things when we move things around between the libraries also feels unsustainable.


// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to