On Thu Jan 23 20:01:19 2025 +0000, Gabriel Ivăncescu wrote:
Yeah, LTO is broken with ASM_GLOBAL_FUNC. GCC doesn't parse the asm, so it doesn't know they're defined. When importing a library with an API having same name, it will pull it from the library since it can't find it defined yet. Later, when it actually assembles and links the code (the real link stage, not LTO), it will find two definitions of the API: the ASM_GLOBAL_FUNC one and the one imported. The issue with winecrt0 is different. When importing a static library it looks to see if any imports are needed from one of its object files. But setjmp.o contains some ASM_GLOBAL_FUNCs so it won't import it because it can't "see" them, so it thinks it's not needed. That's why it gives undefined reference. I think it's OK to remove LTO for specific object files. But you used it way too much, it should only be needed for like 3-4 modules AFAIK, those with ASM_GLOBAL_FUNC only. The others can be fixed in the code.
To be fair, I mean ASM_GLOBAL_FUNC **exports** (or in static libraries, which are implicit exports). If the function is not exported, it's not necessary to disable LTO.