Open lwthiker opened 2 years ago
nice future
Hi,
Thanks for this, and for the recent switch to an autotools-based system. I managed to build the Firefox variant of this (curl-impersonate-ff.exe and libcurl-impersonate-ff-4.dll) on 64-bit Windows 11 with MSYS 2. The way I did it has some problems, though:
not at all suited for automation somewhat true currently
for the life of me, I could not build NSS statically, so this relies on a bunch of DLLs in the same folder
relies on MSYS-provided libraries, and NSS to be built with its packaging
I wonder if it would be easier to build everything with MSVC/VS. I might try at some point, but I doubt I'll be successful. In any case, I hope this helps someone while waiting for something better to come along.
I've updated the instructions and placed them here: https://github.com/qwerty12/subliminal/wiki/Building-curl-impersonate-Firefox-for-Windows-x64
@qwerty12 Thank you for the thorough work and documentation. What parts are not suited for automation? If it's changing the patches, then of course we can upload patches that will fit both Linux and Windows (maybe by checking the host OS)
I appear to have been exaggerating. By automation, I tend to mean in the CI/GitHub Actions sense, but I guess that could also mean someone running a script after preparing the MSYS environment. My steps as I've written them aren't really automation friendly but, as you say, there's nothing stopping the existing patches etc. from being integrated with your work and adapting anything else.
Only one pressing issue comes to mind:
in MSYS2, the initial upgrade requires you to close MSYS2 and start it again
this might not always be the case with a newer shipped base from the MSYS2 team
MSYS2 might not even be needed in the CI sense: the MinGW toolchains can be found in some Linux distros. I believe the curl-for-win project does that. Though cross-compiling NSS doesn't sound fun...
Not really an issue, but something to be aware of: nsinstall.exe
needs to be present in a folder in $PATH
, or the NSPR & NSS build scripts fail. Mozilla provide a binary here but because it has "install.exe" in the filename and lacks a manifest telling Windows it's UAC-aware, Windows thinks it's an installer and asks for elevation interactively
the MSYS2 team work around that by putting a manifest next to the binary
export __COMPAT_LAYER=RunAsInvoker
also works
From what I can see, for building NSPR in MSYS2, all of the patches are needed.
For NSS, I think nss-build.patch is the most important one. I don't know if every change in there is needed, but I do know L54 and L91 are required changes. L43 too, so it can find MSYS2's libraries. Not sure if the other modifications (patched nss-config
and pkg-config
definition) are absolutely needed for cURL's build process to find NSS, though I had them applied as part of using MSYS2's PKGBUILDs to install NSS and NSPR.
EDIT: I can't get NSS to build with MSVC, even when using the MozillaBuild environment. At this point, I'm just going to suck it up and stick with dynamically-linked cURL built in MSYS 2. Right, after seeing Has the time come to drop NSS?, I'm definitely going to cut my losses and stick with what I have currently.
Regarding statically linking with NSS, I found this reference in Mozilla's application-services code. It shows the needed static libraries and their order according to os and arch. I'll try this as well for the macOS version (to support M1 processors).
@lwthiker is there a progress regarding building firefox version for windows?
If you're unable to build nss there is a "solution". We can just use prebuilt libraries downloaded using this method: https://github.com/mozilla/application-services/blob/main/libs/build-nss-desktop.sh#L71
@avently There is no progress unfortunately, my windows knowledge is extremely lacking and this seems like quite some work in order to make it part of the regular build process. It is still in the project's priorities though. Any external help in this regard would be highly appreciated as well.
Write a script to build
curl-impersonate
natively on Windows. This will probably require building each of the dependencies (boringssl, nghttp2, brotli & curl) on Windows.