Closed revelator closed 3 years ago
yep the dll is broken :S i just linked to the static version of the library and it works with that.
Yeah, think I've seen this in #9626, but haven't had time to investigate it. Initial guess is it's from lack of --add-stdcall-alias
support, but not sure.
oh yeah that would explain it :S
yep same export gets reported as missing here, so that seems to be the problem.
It seems like --add-stdcall-alias
shouldn't even be needed now that --enable-stdcall-fixup
is available (https://reviews.llvm.org/D104532), but something must be going wrong, because it manages to link, but fail at runtime. @mstorsjo any thoughts? (quick recap: libusb exports stdcall-mangled names, but somehow we're getting runtime missing export errors on non-mangled names, which indeed do not exist).
oops, it looks like libusb regenerates its import lib from a shipped def file, but lets libtool do whatever magic it does to generate the dll, so that's how it can wind up being mismatched and link but not run.
from what i can glean of libusb-compat it seems to need undecorated exports from libusb eg. no @number so im experimenting with --kill-at.
Well I do previously hacks on some libs to get proper undecorated symbols. Look at https://github.com/msys2/MINGW-packages/blob/3429e73950f14cefa5efcbaa6a6dac8f6da92174/mingw-w64-vulkan-loader/PKGBUILD#L69
hmm not sure, --kill-at is allready used by dlltool but does not seem to undecorate the symbols from the def. might be better just rewriting this to use ld and some of the same options used in libusb-win32.
like this which fixed building it with clang ->
DLL_LDFLAGS = -s -shared \
-Wl,--kill-at \
-Wl,--out-implib,$(LIB_TARGET).a \
-Wl,--enable-stdcall-fixup
I think I've got something working. Bit more testing and I'll make a PR
great :) though i noticed something rather fubar clangs dlltool actually supports --add-stdcall-alias but the linker does not xD
I don't think llvm's dlltool does support that. At least it's not in its --help
output.
aye many options are not, but yeah it seems to do, atleast it does not complain about this flag but you can not use it with -Wl, because that would pass it onto the linker as well and that unfortunatly does not support it.
your fix works fine btw :)
not sure if this only happens with clang but libusb seems to have broken exports. mingw-w64-virt-viewer is broken because of this as it complains about these.