New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl.rc: embed manifest for correct Windows version detection #1221
Conversation
Borland C from how many years ago and do you have a link to the bug. I'm skeptical it would make a difference in behavior where the stringification macros reside. How is defining _STR in curlver different? Are you sure it didn't just pick up a trailing carriage return? My first thought for old versions of Borland C is just skip the whole thing #ifndef OLD_BORLAND_C Also does this have the potential to conflict with the EMBED_MANIFEST directive in winbuild? |
It's a Borland C from ~1999. General internet search didn't reveal any results, but it's not unusual to find unreferenced weird errors in this software. Here's a reference to my own minimal example: vszakats/hb@e3e9b26. The PP seems to work okay with similar minimal examples and also in large projects using stringification extensively. It's probably a personal preference, but I'd prefer not to create and maintain extra code specifically for this old compiler. As for I've updated the PR with such logic. (untested on WinBuild though) |
Looks like Makefile.b32 for Borland C doesn't make use of |
Is there anyone with any objections or concerns regarding this patch? |
It should be tested for projects/ to make sure it doesn't interfere with anything and winbuild/ to make sure that switch to disable it works when an alternative manifest is provided. I haven't had a chance to do that, so if you can do that and it comes out fine then |
@jay I'm barely running Windows these days, and only mingw as a C compiler on it, so I'm going to rely on your tests regarding MSVC. [ I've made successful and working builds using (the initial iteration of) this patch using MSYS2/mingw: https://ci.appveyor.com/project/vszakats/harbour-deps/build/1.0.973 ] |
This became a non-issue when using MSYS2/MINGW after the required |
To add one thought to this: This only became a non-issue when using MSYS2/MinGW (or Cygwin), because these build environments (in their more recent versions) automatically add a default manifest. Other build environments (likely meaning the vast majority of build environments) don't feature the above hack, so the manifest will still be missing and making this issue still relevant. |
Reworked this to be opt-in and enabled it in It's possible to enable this in other build-systems, but first it has to be ensured that no other manifest is being linked/enabled throughout the build process. I can see that CMake/MSVC does create one (seemingly without the relevant |
Test binaries: Above tests are SCHANNEL-enabled (they require
It'd be interesting to see a test with this patch, using [0] e.g.
|
@bagder Would you mind double-checking if these settings are enabled on AppVeyor CI for curl? It looks like each PR update is being held in the job queue, even those that are overridden by a newer push. This puts CI under a strain when pushing multiple updates/fixups to a PR in quick succession and creates delays for all queued jobs. |
I've enabled the embedded manifest for all CMake builds on Windows. For MSVC this required to have the default manifest options removed. This is done by adding |
They were not, but are now. Thanks! |
see: #2591 (comment) |
Thanks @fcharlie! |
@vszakats even without confirmation on this for winbuild, I think it is fine to proceed to merge this PR once the things you've tested works. I suspect we have enough users of the winbuild setup to get told if that is broken in some ways even if nobody steps up and confirm it working right now. |
* enable it in `src/Makefile.m32` * enable it in `winbuild/MakefileBuild.vc` if a custom manifest is _not_ enabled via the existing `EMBED_MANIFEST` option * enable it for all Windows CMake builds (also disable the built-in minimal manifest, added by CMake by default.) One minor caveat. For other build systems, add the `-DCURL_EMBED_MANIFEST` option to the list of RC (Resource Compiler) flags to enable the manifest included in `src/curl.rc`. This may require to disable whatever automatic or other means in which way another manifest is added to `curl.exe`. Notice that Borland C doesn't support this method due to a long-pending resource compiler bug. Watcom C may also not handle it correctly when the `-zm` `wrc` option is used (this option may be unnecessary though) and regardless of options in certain earlier revisions of the 2.0 beta version. Ref: #1221 Ref: #2591
@bagder Thanks! I think we're all set at this point. I've now pushed to master. |
Thanks a lot @vszakats ! |
Include a Windows Manifest in
curl.exe
.The method used here doesn't need additional toolchain-dependent trickery with separate manifest file or with linking a manifest file, but it's instead supplying the manifest content as part of the existing
curl.rc
file. The end result will be the same only slightly more compact, due to omitted newlines and comments, plus it doesn't require rolling yet another instance of the curl version number.Reasoning
Including the
supportedOS Id
manifest bits is required forVerifyVersionInfo()
andGetVersionEx()
to return correct OS version above Windows 8. In source codesrc/vtls/schannel.c
there is logic that depends on detecting Windows 8.1 to enable ALPN and this won't work as expected without a manifest.Potential issues
configure
,winbuild
andVisual Studio
ones), though possibly something to double-check by maintainers of those build systems.There is one known side-effect when building using MSYS2/Cygwin toolchains, where these toolchains recently started shipping with default manifests that in turn may trigger a binutils bug with builds supplying their own manifests, that in turn may confuse certain tools that manipulate PE files directly. It doesn't seem like something critical though.[this has been fixed since then]_STR()
will trigger a bug invery oldBorland/Embarcadero C compilers (e.g. 5.5, others not tested, but possibly affected) where the resource compiler may insert invalid bytes (e.g.\x01
) at the end of the resulting strings. Consequently, newer Windows versions (e.g. 10) may reject running executables having such values in their manifest version IDs. If this is a concern, I suggest doing the stringification insidecurl/curlver.h
to avoid the problem. This would mean to define 3 new global version macros over the existing ones. (Manifest Version ID must follow the format of<num>.<num>.<num>.<num>
, so existingLIBCURL_VERSION
value isn't usable because it may contain"-DEV"
.)-zm
option code-path in version 1.9 (though that option might not be necessary after all), and certain, earlier revisions of the 2.0 beta had another related issue.