{"author":"Viktor Szakats","author_email":"commit@vsz.me","author_time":1736503442,"commit_time":1740142594,"committer":"Viktor Szakats","committer_email":"commit@vsz.me","hash":"2a292c39846107228201674d686be5b3ed96674d","message":"build: add Windows CE / CeGCC support, with CI jobs\n\nMake it possible to build curl for Windows CE using the CeGCC toolchain.\nWith both CMake and autotools, including tests and examples, also in CI.\nThe build configuration is the default one with Schannel enabled. No\n3rd-party dependencies have been tested.\n\nAlso revive old code to make Schannel build with Windows CE, including\ncertificate verification.\n\nBuilds have been throughougly tested. But, I've made no functional tests\nfor this PR. Some parts (esp. file operations, like truncate and seek)\nare stubbed out and likely broken as a result. Test servers build, but\nthey do not work on Windows CE. This patch substitutes `fstat()` calls\nwith `stat()`, which operate on filenames, not file handles. This may or\nmay not work and/or may not be secure.\n\nAbout CeGCC: I used the latest available macOS binary build v0.59.1\nr1397 from 2009, in native `mingw32ce` build mode. CeGCC is in effect\nMinGW + GCC 4.4.0 + old/classic-mingw Windows headers. It targets\nWindows CE v3.0 according to its `_WIN32_WCE` value. It means this PR\nrestores portions of old/classic-mingw support. It makes the Windows CE\ncodepath compatible with GCC 4.4.0. It also adds workaround for CMake,\nwhich cannot identify and configure this toolchain out of the box.\n\nNotes:\n- CMake doesn't recognize CeGCC/mingw32ce, necessitating tricks as seen\n  with Amiga and MS-DOS.\n- CMake doesn't set `MINGW` for mingw32ce. Set it and `MINGW32CE`\n  manually as a helper variable, in addition to `WINCE` which CMake sets\n  based on `CMAKE_SYSTEM_NAME`.\n- CMake fails to create an implib for `libcurl.dll`, due to not\n  recognizing the platform as a Windowsy one. This patch adds the\n  necessary workaround to make it work.\n- headers shipping with CeGCC miss some things curl needs for Schannel\n  support. Fixed by restoring and renovating code previously deleted\n  old-mingw code.\n- it's sometime non-trivial to figure out if a fallout is WinCE,\n  mingw32ce, old-mingw, or GCC version-specific.\n- WinCE is always Unicode. With exceptions: no `wmain`,\n  `GetProcAddress()`.\n- `_fileno()` is said to convert from `FILE *` to `void *` which is\n  a Win32 file `HANDLE`. (This patch doesn't use this, but with further\n  effort it probably could be.)\n  https://stackoverflow.com/questions/3989545/how-do-i-get-the-file-handle-from-the-fopen-file-structure\n- WinCE has no signals, current directory, stdio/CRT file handles, no\n  `_get_osfhandle()`, no `errno`, no `errno.h`. Some of this stuff is\n  standard C89, yet missing from this platform. Microsoft expects\n  Windows CE apps to use Win32 file API and `FILE *` exclusively.\n- revived CeGCC here (not tested for this PR):\n  https://building.enlyze.com/posts/a-new-windows-ce-x86-compiler-in-2024/\n\nOn `UNDER_CE` vs. `_WIN32_WCE`: (This patch settled on `UNDER_CE`)\n\n- A custom VS2008 WinCE toolchain does not set any of these.\n  The compiler binaries don't contain these strings, and has no compiler\n  option for targeting WinCE, hinting that a vanilla toolchain isn't\n  setting any of them either.\n- `UNDER_CE` is automatically defined by the CeGCC compiler.\n  https://cegcc.sourceforge.net/docs/details.html\n- `UNDER_CE` is similar to `_WIN32`, except it's not set automatically\n  by all compilers. It's not supposed to have any value, like a version.\n  (Though e.g. OpenSSL sets it to a version)\n- `_WIN32_WCE` is the CE counterpart of the non-CE `_WIN32_WINNT` macro.\n  That does return the targeted Windows CE version.\n- `_WIN32_WCE` is not defined by compilers, and relies on a header\n  setting it to a default, or the build to set it to the desired target\n  version. This is also how `_WIN32_WINNT` works.\n- `_WIN32_WCE` default is set by `windef.h` in CeGCC.\n- `_WIN32_WCE` isn't set to a default by MSVC Windows CE headers (the\n  ones I checked at least).\n- CMake sets `_WIN32_WCE=<ver>`, `UNDER_CE`, `WINCE` for MSVC WinCE.\n- `_WIN32_WCE` seems more popular in other projects, including CeGCC\n  itself. `zlib` is a notable exception amongst curl dependencies,\n  which uses `UNDER_CE`.\n- Since `_WIN32_WCE` needs \"certain\" headers to have it defined, it's\n  undefined depending on headers included beforehand.\n- `curl/curl.h` re-uses `_WIN32_WCE`'s as a self-guard, relying on\n  its not-(necessarily)-defined-by-default property:\n  https://github.com/curl/curl/blob/25b445e4796bcbf9f842de686a8c384b30f6c2a2/include/curl/curl.h#L77\n\nToolchain downloads:\n- Windows:\n  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_cygwin1.7_r1399.tar.bz2\n- macOS Intel:\n  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_snowleopard_r1397.tar.bz2\n\nCloses #15975\n","parents":["93958499f250da599368de40bc2ba742832fb189"],"tree_hash":"06316d51dfd1e507a46a3d71dcd62a5fa4fd49b1"}