Open DanilaBerezin opened 11 months ago
yeah i been seing the same is actually a really old bug that goes way back to the original mingw that ld's search path also includes the msys or msys2 paths. there was a trick i remember to force it to only search the mingw-w64-* paths ill try to look it up.
@revelator damn didn't know that. But yeah it would be really sick to see the workaround
if i remember correctly there is an option in configure to do it, otherwise it was a bit more hacky as you needed to export the search paths in the correct format before building. not sure but i think its behaviour is a remnant from back in the days where the posix tools were part of the compiler itself like in djgpp and the windows port based on it.
found it you need to create a linker script containing the search paths eg. SEARCH_DIR("=/mingw32/i686-w64-mingw32/lib"); SEARCH_DIR("=/mingw32/lib"); then build binutils with gcc -Wl,-T,<path/tolinkerscript>
the = before the path is because our tools use the sysroot option otherwise it would just be SEARCH_DIR("/mingw32/i686-w64-mingw32/lib"); SEARCH_DIR("/mingw32/lib");
found it you need to create a linker script containing the search paths eg. SEARCH_DIR("=/mingw32/i686-w64-mingw32/lib"); SEARCH_DIR("=/mingw32/lib"); then build binutils with gcc -Wl,-T,<path/tolinkerscript>
the = before the path is because our tools use the sysroot option otherwise it would just be SEARCH_DIR("/mingw32/i686-w64-mingw32/lib"); SEARCH_DIR("/mingw32/lib");
Nice! I'll take a look at it at some point. But I might not have a lot of time.
might even be enough adding SEARCH_DIR("=$(MINGW_PREFIX)/lib"); seeing as we dont use the cross prefixed compiler path anymore eg. all system libraries are now located in "$(MINGW_PREFIX)/lib" only the linker scripts still reside in "$(MINGW_PREFIX)/$(MINGW_CHOST)/lib"
Description / Steps to reproduce the issue
ld --verbose | grep SEARCH_DIR
and press enterSimilar issues may exist in the other environments, but I haven't tested them.
Expected behavior
Ideally, the command should output the following:
SEARCH_DIR("=/mingw64/x86_64-w64-mingw32/lib"); SEARCH_DIR("=/mingw64/lib");
Since these are the actual search paths for ld in the mingw-w64 environment.Actual behavior
The following is what is output by the command:
SEARCH_DIR("=/mingw64/x86_64-w64-mingw32/lib"); SEARCH_DIR("=/mingw64/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
Verification
Windows Version
MINGW64_NT-10.0-19045
MINGW environments affected
Are you willing to submit a PR?
I can, but I don't know much about ld so it would take me a while.