Greetings, I was trying to build a newer emulators/wine, but building (both GCC and Clang) fails with ../../tools/winegcc/winegcc -o acledit.dll.so --wine-objdir ../.. -m64 -fPIC -fasynchronous-unwind-tables \ -shared acledit.spec -mno-cygwin main.o -lossaudio -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib /usr/bin/ld: ../../dlls/msvcrt/libmsvcrt.a(msvcrt.8whYEF.o): in function `memcpy': (.text+0x0): undefined reference to `__wine$func$msvcrt$988$memcpy' /usr/bin/ld: ../../dlls/msvcrt/libmsvcrt.a(msvcrt.WS6T26.o): in function `memset': (.text+0x0): undefined reference to `__wine$func$msvcrt$992$memset' /usr/bin/ld: ../../dlls/msvcrt/libmsvcrt.a(msvcrt.ktRscb.o): in function `strcmp': (.text+0x0): undefined reference to `__wine$func$msvcrt$1036$strcmp' /usr/bin/ld: ../../dlls/msvcrt/libmsvcrt.a(msvcrt.KEaDAr.o): in function `strlen': (.text+0x0): undefined reference to `__wine$func$msvcrt$1044$strlen' /usr/bin/ld: ../../dlls/msvcrt/libmsvcrt.a(msvcrt.6jUV5d.o): in function `strncmp': (.text+0x0): undefined reference to `__wine$func$msvcrt$1047$strncmp' clang: error: linker command failed with exit code 1 (use -v to see invocation) winegcc: clang failed I investigated the matter further, and it turned out the package builds correctly with USE_CWRAPPERS=no. That's because the classic wrappers reorder -lLIBNAME options to the end of the option list: [*] /tmp/pkgsrc/adam/wine/work/.wrapper/bin/clang /tmp/pkgsrc/adam/wine/work/.wrapper/bin/clang -m64 -m64 -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -shared -Wl,-Bsymbolic -Wl,-z,max-page-size=0x1000 -Wl,-z,defs -Wl,-init,__wine_spec_init,-fini,__wine_spec_fini -o acledit.dll.so -L../../dlls -L../../libs/wine -L/usr/lib -L/usr/pkg/lib acledit.dll-nqEiVb.spec.o main.o -lossaudio ../../dlls/winecrt0/libwinecrt0.a ../../dlls/msvcrt/libmsvcrt.a -lwine -lm -lc <.> /usr/bin/clang -m64 -m64 -Wl,-R/usr/pkg/lib -shared -Wl,-Bsymbolic -Wl,-z -Wl,max-page-size=0x1000 -Wl,-z -Wl,defs -Wl,-init -Wl,__wine_spec_init -Wl,-fini -Wl,__wine_spec_fini -o acledit.dll.so -L../../dlls -L../../libs/wine -L/tmp/pkgsrc/adam/wine/work/.buildlink/lib acledit.dll-nqEiVb.spec.o main.o ../../dlls/winecrt0/libwinecrt0.a ../../dlls/msvcrt/libmsvcrt.a -Qunused-arguments -fcommon -fstack-protector -I/tmp/pkgsrc/adam/wine/work/.buildlink/include -lossaudio -lwine -lm -lc Cwrappers keep -l intact. Here the offending -lossaudio is somewhere in the middle. [*] cc -m64 -m64 -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib -shared -Wl,-Bsymbolic -Wl,-z,max-page-size=0x1000 -Wl,-z,defs -Wl,-init,__wine_spec_init,-fini,__wine_spec_fini -o acledit.dll.so -L../../dlls -L../../libs/wine -L/usr/lib -L/usr/pkg/lib acledit.dll-ynFs83.spec.o main.o -lossaudio ../../dlls/winecrt0/libwinecrt0.a ../../dlls/msvcrt/libmsvcrt.a -lwine -lm -lc <.> /usr/bin/clang -Qunused-arguments -fcommon -m64 -m64 -Wl,-rpath,/usr/pkg/lib -shared -Wl,-Bsymbolic -Wl,-z -Wl,max-page-size=0x1000 -Wl,-z -Wl,defs -Wl,-init -Wl,__wine_spec_init -Wl,-fini -Wl,__wine_spec_fini -o acledit.dll.so -L../../dlls -L../../libs/wine -L/tmp/pkgsrc/adam/wine/work/.buildlink/lib acledit.dll-ynFs83.spec.o main.o -lossaudio ../../dlls/winecrt0/libwinecrt0.a ../../dlls/msvcrt/libmsvcrt.a -lwine -lm -lc -Qunused-arguments -fstack-protector -I/tmp/pkgsrc/adam/wine/work/.buildlink/include To fix the problem, I propose adding -l option re-ordering to cwrappers, as seen in the attached patch. To fix it in Wine seems problematic, because Wine uses its own tools (winegcc and winebuild) to wrap the compiler and linker. Adding the options re-ordering to Cwrappers would be consistent with the regular wrapping. The patch also includes syncing compiler options with mk/wrapper/transform-gcc (and fixing a typo: -fexpensive-options -> -fexpensive-optimizations), which is not needed to fix the problem described above. With this patch applied, I have re-built most of my packages on NetBSD and Darwin without problems. Ok to commit? Kind regards, Adam
Attachment:
cwrappers.patch
Description: Binary data