Skip to content
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

build: fix MSVC UWP builds #15657

Closed
wants to merge 43 commits into from
Closed

build: fix MSVC UWP builds #15657

wants to merge 43 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Nov 28, 2024

The MSVC UWP job in CI did not actually enable UWP. Fix this and
the fallouts discovered after enabling it.

  • GHA/windows: make sure to enable UWP in MSVC vcpkg UWP job.
    Use the CMake options and C flags already used for mingw-w64, but use
    WINAPI_FAMILY_PC_APP instead of the deprecated WINAPI_FAMILY_APP.
    (The former is not supported by mingw-w64, so leave it there as-is.)
    Follow-up to cb22cfc GHA: add MSVC UWP job, expand jobs with more options #14077

  • GHA/windows: by default the MSVC UWP job became 2x-3x slower than
    others after actually enabling UWP. Most of it is caused by
    CMake/MSBuild automatically building full APPX containers for each
    .exe target. This includes 21 CMake feature detections. Each
    detection app is built into a 15MB APPX project, with code signing,
    logos, etc. Example:
    https://github.com/curl/curl/actions/runs/12056968170/job/33620610958
    Disable this overhead for curl build targets via custom
    CMAKE_VS_GLOBALS options. I've found no way to apply them to feature
    detection targets, so those remain slow.

  • cmake: automatically enable Unicode for UWP builds. It's required.
    Also stop enabling it manually in the existing CI job.

  • tests: fix getpid() use for Windows UWP:

    tests\server\util.c(281,21): warning C4013: 'getpid' undefined; assuming extern returning int
    

    Ref: https://github.com/curl/curl/actions/runs/12061215311/job/33632904249#step:11:38

  • src/tool_doswin: disable GetLoadedModulePaths() for UWP.
    mingw-w64 UWP was okay with this, but MS SDK headers are not.
    This makes --dump-module-paths return empty for UWP builds.

    src\tool_doswin.c(620,3): error C2065: 'MODULEENTRY32': undeclared identifier
    src\tool_doswin.c(626,11): warning C4013: 'CreateToolhelp32Snapshot' undefined; assuming extern returning int
    src\tool_doswin.c(626,36): error C2065: 'TH32CS_SNAPMODULE': undeclared identifier
    src\tool_doswin.c(632,7): warning C4013: 'Module32First' undefined; assuming extern returning int
    

    Ref: https://github.com/curl/curl/actions/runs/12055081933/job/33614629930#step:9:35

  • examples: fix websocket.c to include winsock2.h before windows.h
    to make it build with MSVC UWP:

    include\curl\curl.h(143,16): error C2061: syntax error: identifier 'curl_socket_t'
    include\curl\curl.h(143,16): error C2059: syntax error: ';'
    include\curl\curl.h(417,52): error C2146: syntax error: missing ')' before identifier 'curlfd'
    include\curl\curl.h(417,38): error C2081: 'curl_socket_t': name in formal parameter list illegal
    

    Ref: https://github.com/curl/curl/actions/runs/12055317910/job/33615644427#step:14:126

  • GHA/windows: silence linker warning with MSVC UWP builds:

    LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
    

    Ref: https://github.com/curl/curl/actions/runs/12055696808/job/33616629610#step:11:38

  • GHA/windows: set /INCREMENTAL:NO for all MSVC jobs to improve
    performance a little.

  • cmake: show UWP platform flag.

Ref: #15652

not supported by mingw-w64
Otherwise cmake doesn't set WINDOWS_STORE variable and UWP
logic is missed.
apparently mingw-w64 is okay with this, but the official SDK headers
are not:
```
src\tool_doswin.c(620,3): error C2065: 'MODULEENTRY32': undeclared identifier
src\tool_doswin.c(620,17): error C2146: syntax error: missing ';' before identifier 'mod'
src\tool_doswin.c(620,17): error C2065: 'mod': undeclared identifier
src\tool_doswin.c(620,23): error C2059: syntax error: '{'
src\tool_doswin.c(623,3): error C2065: 'mod': undeclared identifier
src\tool_doswin.c(623,7): error C2224: left of '.dwSize' must have struct/union type
src\tool_doswin.c(623,23): error C2065: 'MODULEENTRY32': undeclared identifier
src\tool_doswin.c(626,11): warning C4013: 'CreateToolhelp32Snapshot' undefined; assuming extern returning int
src\tool_doswin.c(626,36): error C2065: 'TH32CS_SNAPMODULE': undeclared identifier
src\tool_doswin.c(626,9): warning C4047: '=': 'HANDLE' differs in levels of indirection from 'int'
src\tool_doswin.c(632,7): warning C4013: 'Module32First' undefined; assuming extern returning int
src\tool_doswin.c(632,27): error C2065: 'mod': undeclared identifier
src\tool_doswin.c(642,24): error C2065: 'mod': undeclared identifier
src\tool_doswin.c(642,28): error C2224: left of '.szExePath' must have struct/union type
src\tool_doswin.c(642,42): error C2056: illegal expression
src\tool_doswin.c(642,17): error C2466: cannot allocate an array of constant size 0
src\tool_doswin.c(642,10): error C2133: 'buffer': unknown size
src\tool_doswin.c(643,40): error C2065: 'mod': undeclared identifier
src\tool_doswin.c(643,44): error C2224: left of '.szExePath' must have struct/union type
src\tool_doswin.c(643,55): warning C4047: 'function': 'LPCWCH' differs in levels of indirection from 'int'
src\tool_doswin.c(643,55): warning C4024: 'WideCharToMultiByte': different types for formal and actual parameter 3
src\tool_doswin.c(644,29): warning C4047: 'function': 'int' differs in levels of indirection from 'char [0]'
src\tool_doswin.c(644,29): warning C4024: 'WideCharToMultiByte': different types for formal and actual parameter 4
src\tool_doswin.c(644,37): warning C4034: sizeof returns 0
src\tool_doswin.c(644,53): warning C4047: 'function': 'int' differs in levels of indirection from 'void *'
src\tool_doswin.c(644,53): warning C4024: 'WideCharToMultiByte': different types for formal and actual parameter 6
src\tool_doswin.c(643,9): error C2198: 'int WideCharToMultiByte(UINT,DWORD,LPCWCH,int,LPSTR,int,LPCCH,LPBOOL)': too few arguments for call
src\tool_doswin.c(654,11): warning C4013: 'Module32Next' undefined; assuming extern returning int
src\tool_doswin.c(654,30): error C2065: 'mod': undeclared identifier
```
https://github.com/curl/curl/actions/runs/12055081933/job/33614629930#step:9:35
To fix msvc uwp builds.

```
curl\include\curl\curl.h(143,16): error C2061: syntax error: identifier 'curl_socket_t' [D:\a\curl\curl\bld\docs\examples\curl-example-websocket.vcxproj]
curl\include\curl\curl.h(143,16): error C2059: syntax error: ';' [D:\a\curl\curl\bld\docs\examples\curl-example-websocket.vcxproj]
curl\include\curl\curl.h(417,52): error C2146: syntax error: missing ')' before identifier 'curlfd' [D:\a\curl\curl\bld\docs\examples\curl-example-websocket.vcxproj]
curl\include\curl\curl.h(417,38): error C2081: 'curl_socket_t': name in formal parameter list illegal [D:\a\curl\curl\bld\docs\examples\curl-example-websocket.vcxproj]
```
https://github.com/curl/curl/actions/runs/12055317910/job/33615644427#step:14:126
```
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
```
https://github.com/curl/curl/actions/runs/12055696808/job/33616629610#step:11:38
This reverts commit 12416ed84d9650b85b793889591fc98e36a21a14.

WindowsAppContainer=false/true controls _CopyOutOfDateSourceItemsToOutputDirectory
```
         Creating directory "D:\a\curl\curl\bld\src\curl\curl.dir".
         Creating directory "D:\a\curl\curl\bld\src\curl\curl.dir".
         Copying file from "D:\a\curl\curl\bld\src\curl.dir\Logo.png" to "D:\a\curl\curl\bld\src\curl\curl.dir\Logo.png".
         Copying file from "D:\a\curl\curl\bld\src\curl.dir\SmallLogo.png" to "D:\a\curl\curl\bld\src\curl\curl.dir\SmallLogo.png".
         Copying file from "D:\a\curl\curl\bld\src\curl.dir\StoreLogo.png" to "D:\a\curl\curl\bld\src\curl\curl.dir\StoreLogo.png".
         Copying file from "D:\a\curl\curl\bld\src\curl.dir\SmallLogo44x44.png" to "D:\a\curl\curl\bld\src\curl\curl.dir\SmallLogo44x44.png".
         Copying file from "D:\a\curl\curl\bld\src\curl.dir\SplashScreen.png" to "D:\a\curl\curl\bld\src\curl\curl.dir\SplashScreen.png".
    10>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage\Microsoft.AppXPackage.Targets(1361,5): warning APPX1503: The project contains 1 item(s) that represent the app manifest: D:\a\curl\curl\bld\src\curl.dir\package.appxManifest. App manifests that are not used to produce an app package will be ignored. [D:\a\curl\curl\bld\src\curl.vcxproj]
       ComputeProcessXamlFiles:
         (Out) ProcessedXamlFiles ==
       CustomOutputGroupForPackaging:
         (Out) Project='curl' ProcessedXamlFiles ==
         (Out) XamlPackagingRootFolder == D:\a\curl\curl\bld\src\\
         (Out) ProcessedXamlFilesFullPath ==
         (Out) Project='curl' CustomOutputGroupForPackagingOutput ==
       _GenerateProjectPriFileCore:
         C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\MakePri.exe New -ProjectRoot D:\a\curl\curl\bld\src\ -ConfigXml curl.dir\Debug\priconfig.xml -OutputFile D:\a\curl\curl\bld\src\curl.dir\resources.pri -IndexName curl -Verbose -Overwrite
```
@vszakats vszakats added build Windows Windows-specific labels Nov 28, 2024
@github-actions github-actions bot added cmdline tool CI Continuous Integration labels Nov 28, 2024
@github-actions github-actions bot added the tests label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build CI Continuous Integration cmdline tool tests Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

1 participant