logicomacorp / WaveSabre

Official WaveSabre repository
MIT License
246 stars 34 forks source link

Generate msvcrt_old.lib #44

Closed kusma closed 4 years ago

kusma commented 4 years ago

Here's something that I think in principle is kinda neat, but the implementation isn't perfect.

So, instead of storing msvcrt_old.lib in the repo, we can store the export-table, and re-create the import lib when compiling. This should allow us to target both x86 and x64 without any magical binary blobs in the repo, which is neat.

But, for some reason, some symbols are missing, and I can't off the top of my head understand why. I'm guessing these are involved in something more complicated than what I currently grasp, so further digging should be done. We might be missing other symbols, which can lead to obscure issues down the road.

Anyway, I thought I'd post it here, in the hopes that someone else knows linking better than me, and points out what the problem is.

kusma commented 4 years ago

OK, I think this approach is better. What I did was instead dump the symbols using DUMPBIN /LINKERMEMBER, and removing obviously bogus symbols instead.

This should result in a complete set of symbols.

yupferris commented 4 years ago

Actually one thing while we're at it - we may not actually want to call it msvcrt_old.lib and instead just msvcrt.lib. Admittedly I'm not sure why I renamed it in the first place.

This would require updates in the dependent projects ofc.

kusma commented 4 years ago

So, I tried renaming it msvcrt.lib, and that actually didn't work for me. I didn't really look into it deeper, so maybe it was something else.

It should also be noted that recent versions of visual studio ship with msvcrt.lib as well. Some googling tells me that this version still links to MSVCRT.dll, but later versions of MSVCRT.dll actually contains more symbols that a production could accidentally use, causing it to not work on older Windows versions.

Oh, and just for the curious: here's what triggered me to try this approach. Their solution doesn't seem to be complete, though.

kusma commented 4 years ago

Just thought I'd let you know, I've renamed to msvcrt.lib in the new version that I'll push out once x64 support has landed. It turns out, it worked fine. Not sure what went wrong last time, but lots of stuff was a bit janky at that point, so I'm not going to obsess about it ;)

kusma commented 4 years ago

OK, so I've updated this, but there's still a few things I need to look more into

Edit: all of these are fixed now, and I think this is good to go.

kusma commented 4 years ago

@yupferris: humble ping?