fix: port POSIX-only files to Windows for HIP builds#366
Closed
Sprize1 wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 13 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/src/server/server_main.cpp">
<violation number="1" location="server/src/server/server_main.cpp:37">
P1: Windows setenv shim ignores overwrite=0 parameter, silently overwriting existing environment variables on Windows instead of preserving them as POSIX requires.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| #include <vector> | ||
|
|
||
| #ifdef _WIN32 | ||
| #define setenv(name, value, overwrite) _putenv_s(name, value) |
Contributor
There was a problem hiding this comment.
P1: Windows setenv shim ignores overwrite=0 parameter, silently overwriting existing environment variables on Windows instead of preserving them as POSIX requires.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/src/server/server_main.cpp, line 37:
<comment>Windows setenv shim ignores overwrite=0 parameter, silently overwriting existing environment variables on Windows instead of preserving them as POSIX requires.</comment>
<file context>
@@ -33,6 +33,11 @@
#include <vector>
+#ifdef _WIN32
+#define setenv(name, value, overwrite) _putenv_s(name, value)
+#define unsetenv(name) _putenv_s(name, "")
+#endif
</file context>
easel
pushed a commit
to easel/lucebox-hub
that referenced
this pull request
Jun 10, 2026
- Replace raw mmap/munmap with GgufMmap (cross-platform RAII) in gemma4_loader, laguna_backend, qwen35moe_backend, test_dflash - Replace dirent.h/stat with std::filesystem in disk_prefix_cache, model_card - Add Windows implementations for write_exact_fd/read_exact_fd in io_utils.h - Guard open_dflash_floor_log POSIX path with _WIN32 in qwen35_backend - Replace mkstemps with std::filesystem temp dir in daemon_loop - Port http_server socket/POSIX layer to Winsock2 (winsock2.h, WSAPoll, closesocket, ioctlsocket helpers) - Guard unistd.h in http_server.h, add setenv fallback in server_main - Make pthread link conditional (NOT WIN32), add ws2_32 on Windows, set BUILD_SHARED_LIBS=OFF for ggml symbol visibility - All Windows-only code behind #if defined(_WIN32), no functional change on Linux/macOS Tested: dflash_server.exe + test_dflash.exe build cleanly on Windows 11 + ROCm 7.1 HIP + gfx1102 (RX 7600 XT). Co-Authored-By: Claude Code <noreply@anthropic.com>
634a173 to
0514c95
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The HIP backend fails to compile on Windows native because several source files use POSIX-only APIs (mmap, dirent, mkstemps, readlink, POSIX sockets) without Windows fallbacks.
Solution
Add cross-platform support behind
#if defined(_WIN32), using:GgufMmap(existing project RAII class) instead of raw mmapstd::filesysteminstead of dirent/stat_putenv_sinstead of setenv_write/_readin io_utilsws2_32+BUILD_SHARED_LIBS=OFFin CMakeListsFiles changed (13)
gemma4_loader.cpplaguna_backend.cppqwen35moe_backend.cppqwen35_backend.cppio_utils.h_write/_readon Windowsdaemon_loop.cppdisk_prefix_cache.cppmodel_card.cppserver_main.cpp_putenv_shttp_server.cpphttp_server.hCMakeLists.txtNo functional change on Linux/macOS
All Windows-specific code is behind
#if defined(_WIN32). POSIX paths are unchanged.Tested
dflash_server.exebuilds cleanly (91 MB)test_dflash.exebuilds cleanly (89 MB)🤖 Generated with Claude Code