aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-16 10:52:45 +0100
committerGitHub Enterprise <[email protected]>2026-03-16 10:52:45 +0100
commit79e10a165cf09dc2cc120b3a226c51f87c235f20 (patch)
treecf51b07e097904044b4bf65bc3fe0ad14134074f /src
parentLinux build improvements (#843) (diff)
downloadzen-79e10a165cf09dc2cc120b3a226c51f87c235f20.tar.xz
zen-79e10a165cf09dc2cc120b3a226c51f87c235f20.zip
Enable cross compilation of Windows targets on Linux (#839)
This PR makes it *possible* to do a Windows build on Linux via `clang-cl`. It doesn't actually change any build process. No policy change, just mechanics and some code fixes to clear clang compilation. The code fixes are mainly related to #include file name casing, to match the on-disk casing of the SDK files (via xwin).
Diffstat (limited to 'src')
-rw-r--r--src/transports/winsock/xmake.lua2
-rw-r--r--src/zen/cmds/service_cmd.cpp4
-rw-r--r--src/zen/xmake.lua6
-rw-r--r--src/zen/zen.rc2
-rw-r--r--src/zenbase/include/zenbase/zenbase.h19
-rw-r--r--src/zencore-test/targetver.h2
-rw-r--r--src/zencore/callstack.cpp2
-rw-r--r--src/zencore/filesystem.cpp2
-rw-r--r--src/zencore/include/zencore/string.h3
-rw-r--r--src/zencore/memtrack/callstacktrace.cpp16
-rw-r--r--src/zencore/process.cpp4
-rw-r--r--src/zenhorde/hordetransportaes.cpp2
-rw-r--r--src/zenhttp/servers/httpplugin.cpp2
-rw-r--r--src/zenhttp/servers/httpsys.cpp2
-rw-r--r--src/zenserver/storage/vfs/vfsservice.cpp2
-rw-r--r--src/zenserver/targetver.h2
-rw-r--r--src/zenserver/xmake.lua10
-rw-r--r--src/zenserver/zenserver.rc2
18 files changed, 57 insertions, 27 deletions
diff --git a/src/transports/winsock/xmake.lua b/src/transports/winsock/xmake.lua
index c14283546..cdba75885 100644
--- a/src/transports/winsock/xmake.lua
+++ b/src/transports/winsock/xmake.lua
@@ -5,7 +5,7 @@ target("winsock")
set_group("transports")
add_headerfiles("**.h")
add_files("**.cpp")
- add_links("Ws2_32")
+ add_links("ws2_32")
add_includedirs(".")
set_symbols("debug")
add_deps("zenbase", "transport-sdk")
diff --git a/src/zen/cmds/service_cmd.cpp b/src/zen/cmds/service_cmd.cpp
index a781dc340..3347f1afe 100644
--- a/src/zen/cmds/service_cmd.cpp
+++ b/src/zen/cmds/service_cmd.cpp
@@ -12,8 +12,8 @@
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
# include <shellapi.h>
-# include <Shlwapi.h>
-# pragma comment(lib, "Shlwapi.lib")
+# include <shlwapi.h>
+# pragma comment(lib, "shlwapi.lib")
#endif
#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
diff --git a/src/zen/xmake.lua b/src/zen/xmake.lua
index 4c134404a..df249ade4 100644
--- a/src/zen/xmake.lua
+++ b/src/zen/xmake.lua
@@ -14,8 +14,10 @@ target("zen")
if is_plat("windows") then
add_files("zen.rc")
- add_ldflags("/subsystem:console,5.02")
- add_ldflags("/LTCG")
+ add_ldflags("/subsystem:console,5.02", {force = true})
+ if not (get_config("toolchain") or ""):find("clang") then
+ add_ldflags("/LTCG")
+ end
end
if is_plat("macosx") then
diff --git a/src/zen/zen.rc b/src/zen/zen.rc
index 0617681a7..3adf25b72 100644
--- a/src/zen/zen.rc
+++ b/src/zen/zen.rc
@@ -7,7 +7,7 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
-101 ICON "..\\zen.ico"
+101 ICON "../zen.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION ZEN_CFG_VERSION_MAJOR,ZEN_CFG_VERSION_MINOR,ZEN_CFG_VERSION_ALTER,0
diff --git a/src/zenbase/include/zenbase/zenbase.h b/src/zenbase/include/zenbase/zenbase.h
index 2aec1f314..1d5051c5b 100644
--- a/src/zenbase/include/zenbase/zenbase.h
+++ b/src/zenbase/include/zenbase/zenbase.h
@@ -211,7 +211,24 @@ char (&ZenArrayCountHelper(const T (&)[N]))[N + 1];
# define ZEN_EXE_SUFFIX_LITERAL ""
#endif
-#define ZEN_UNUSED(...) ((void)__VA_ARGS__)
+#if ZEN_COMPILER_CLANG
+// Clang warns about the comma operator in ((void)a, b) with -Wunused-value.
+// Use a fold expression via a helper to suppress each argument individually.
+namespace zen::detail {
+inline void
+unused_impl()
+{
+}
+template<typename... T>
+inline void
+unused_impl(T&&...)
+{
+}
+} // namespace zen::detail
+# define ZEN_UNUSED(...) ::zen::detail::unused_impl(__VA_ARGS__)
+#else
+# define ZEN_UNUSED(...) ((void)__VA_ARGS__)
+#endif
//////////////////////////////////////////////////////////////////////////
diff --git a/src/zencore-test/targetver.h b/src/zencore-test/targetver.h
index d432d6993..4805141de 100644
--- a/src/zencore-test/targetver.h
+++ b/src/zencore-test/targetver.h
@@ -7,4 +7,4 @@
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-#include <SDKDDKVer.h>
+#include <sdkddkver.h>
diff --git a/src/zencore/callstack.cpp b/src/zencore/callstack.cpp
index ee0b0625a..a16bb3f13 100644
--- a/src/zencore/callstack.cpp
+++ b/src/zencore/callstack.cpp
@@ -6,7 +6,7 @@
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
-# include <Dbghelp.h>
+# include <DbgHelp.h>
#endif
#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index e557b376c..0d361801f 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -17,7 +17,7 @@
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
-# include <ShlObj.h>
+# include <shlobj.h>
# pragma comment(lib, "shell32.lib")
# pragma comment(lib, "ole32.lib")
#endif
diff --git a/src/zencore/include/zencore/string.h b/src/zencore/include/zencore/string.h
index 7b46f0e38..60293a313 100644
--- a/src/zencore/include/zencore/string.h
+++ b/src/zencore/include/zencore/string.h
@@ -333,7 +333,8 @@ public:
#if defined(__clang__) && !defined(__APPLE__) && !defined(_MSC_VER)
/* UE Toolchain Clang has different types for int64_t and long long so an override is
- needed here. Without it, Clang can't disambiguate integer overloads */
+ needed here. Without it, Clang can't disambiguate integer overloads.
+ On MSVC ABI (including clang-cl), int64_t is long long so no separate overload is needed. */
inline StringBuilderImpl& operator<<(long long n)
{
IntNum Str(n);
diff --git a/src/zencore/memtrack/callstacktrace.cpp b/src/zencore/memtrack/callstacktrace.cpp
index 013c51535..ccbea1282 100644
--- a/src/zencore/memtrack/callstacktrace.cpp
+++ b/src/zencore/memtrack/callstacktrace.cpp
@@ -193,8 +193,12 @@ private:
std::atomic_uint32_t CallstackIdCounter{1}; // 0 is reserved for "unknown callstack"
};
+} // namespace zen
+
# if UE_CALLSTACK_TRACE_USE_UNWIND_TABLES
+namespace zen {
+
/*
* Windows' x64 binaries contain a ".pdata" section that describes the location
* and size of its functions and details on how to unwind them. The unwind
@@ -908,10 +912,12 @@ FBacktracer::GetBacktraceId(void* AddressOfReturnAddress)
// queue (i.e. the processing thread has caught up processing).
return CallstackTracer.AddCallstack(BacktraceEntry);
}
-}
+} // namespace zen
# else // UE_CALLSTACK_TRACE_USE_UNWIND_TABLES
+namespace zen {
+
////////////////////////////////////////////////////////////////////////////////
class FBacktracer
{
@@ -921,8 +927,8 @@ public:
static FBacktracer* Get();
inline uint32_t GetBacktraceId(void* AddressOfReturnAddress);
uint32_t GetBacktraceId(uint64_t ReturnAddress);
- void AddModule(uintptr_t Base, const char16_t* Name) {}
- void RemoveModule(uintptr_t Base) {}
+ void AddModule(uintptr_t /*Base*/, const char16_t* /*Name*/) {}
+ void RemoveModule(uintptr_t /*Base*/) {}
private:
static FBacktracer* Instance;
@@ -963,6 +969,7 @@ FBacktracer::GetBacktraceId(void* AddressOfReturnAddress)
uint32_t
FBacktracer::GetBacktraceId(uint64_t ReturnAddress)
{
+ ZEN_UNUSED(ReturnAddress);
# if !UE_BUILD_SHIPPING
uint64_t StackFrames[256];
int32_t NumStackFrames = FPlatformStackWalk::CaptureStackBackTrace(StackFrames, UE_ARRAY_COUNT(StackFrames));
@@ -1006,7 +1013,8 @@ FBacktracer::GetBacktraceId(uint64_t ReturnAddress)
return 0;
}
-}
+
+} // namespace zen
# endif // UE_CALLSTACK_TRACE_USE_UNWIND_TABLES
diff --git a/src/zencore/process.cpp b/src/zencore/process.cpp
index 852678ffe..080607f13 100644
--- a/src/zencore/process.cpp
+++ b/src/zencore/process.cpp
@@ -21,8 +21,8 @@ ZEN_THIRD_PARTY_INCLUDES_START
# include <Psapi.h>
# include <shellapi.h>
-# include <Shlobj.h>
-# include <TlHelp32.h>
+# include <shlobj.h>
+# include <tlhelp32.h>
#else
# include <fcntl.h>
# include <pthread.h>
diff --git a/src/zenhorde/hordetransportaes.cpp b/src/zenhorde/hordetransportaes.cpp
index 986dd3705..505b6bde7 100644
--- a/src/zenhorde/hordetransportaes.cpp
+++ b/src/zenhorde/hordetransportaes.cpp
@@ -12,7 +12,7 @@
#if ZEN_PLATFORM_WINDOWS
# include <zencore/windows.h>
# include <bcrypt.h>
-# pragma comment(lib, "Bcrypt.lib")
+# pragma comment(lib, "bcrypt.lib")
#else
ZEN_THIRD_PARTY_INCLUDES_START
# include <openssl/evp.h>
diff --git a/src/zenhttp/servers/httpplugin.cpp b/src/zenhttp/servers/httpplugin.cpp
index a1bb719c8..31b0315d4 100644
--- a/src/zenhttp/servers/httpplugin.cpp
+++ b/src/zenhttp/servers/httpplugin.cpp
@@ -147,7 +147,7 @@ public:
HttpPluginServerRequest& operator=(const HttpPluginServerRequest&) = delete;
// As this is plugin transport connection used for specialized connections we assume it is not a machine local connection
- bool IsLocalMachineRequest() const override { return false; }
+ virtual bool IsLocalMachineRequest() const override { return false; }
virtual std::string_view GetAuthorizationHeader() const override;
virtual Oid ParseSessionId() const override;
virtual uint32_t ParseRequestId() const override;
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp
index 4d6a53696..f8fb1c9be 100644
--- a/src/zenhttp/servers/httpsys.cpp
+++ b/src/zenhttp/servers/httpsys.cpp
@@ -1173,7 +1173,7 @@ HttpSysServer::RegisterHttpUrls(int BasePort)
{
Result = HttpAddUrlToUrlGroup(m_HttpUrlGroupId, WildcardUrlPath.c_str(), HTTP_URL_CONTEXT(0), 0);
- if ((Result == ERROR_SHARING_VIOLATION))
+ if (Result == ERROR_SHARING_VIOLATION)
{
ZEN_INFO("Desired port {} is in use (HttpAddUrlToUrlGroup returned: {}), retrying",
EffectivePort,
diff --git a/src/zenserver/storage/vfs/vfsservice.cpp b/src/zenserver/storage/vfs/vfsservice.cpp
index 863ec348a..f418c4131 100644
--- a/src/zenserver/storage/vfs/vfsservice.cpp
+++ b/src/zenserver/storage/vfs/vfsservice.cpp
@@ -62,7 +62,7 @@ GetContentAsCbObject(HttpServerRequest& HttpReq, CbObject& Cb)
// echo {"method": "mount", "params": {"path": "d:\\VFS_ROOT"}} | curl.exe http://localhost:8558/vfs --data-binary @-
// echo {"method": "unmount"} | curl.exe http://localhost:8558/vfs --data-binary @-
-VfsService::VfsService(HttpStatusService& StatusService, VfsServiceImpl* ServiceImpl) : m_StatusService(StatusService), m_Impl(ServiceImpl)
+VfsService::VfsService(HttpStatusService& StatusService, VfsServiceImpl* ServiceImpl) : m_Impl(ServiceImpl), m_StatusService(StatusService)
{
m_Router.RegisterRoute(
"info",
diff --git a/src/zenserver/targetver.h b/src/zenserver/targetver.h
index d432d6993..4805141de 100644
--- a/src/zenserver/targetver.h
+++ b/src/zenserver/targetver.h
@@ -7,4 +7,4 @@
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-#include <SDKDDKVer.h>
+#include <sdkddkver.h>
diff --git a/src/zenserver/xmake.lua b/src/zenserver/xmake.lua
index 52889fff5..6b29dadfb 100644
--- a/src/zenserver/xmake.lua
+++ b/src/zenserver/xmake.lua
@@ -60,13 +60,15 @@ target("zenserver")
end
if is_plat("windows") then
- add_ldflags("/subsystem:console,5.02")
- add_ldflags("/MANIFEST:EMBED")
- add_ldflags("/LTCG")
+ add_ldflags("/subsystem:console,5.02", {force = true})
+ add_ldflags("/MANIFEST:EMBED", {force = true})
+ if not (get_config("toolchain") or ""):find("clang") then
+ add_ldflags("/LTCG")
+ end
add_files("zenserver.rc")
add_cxxflags("/bigobj")
add_links("delayimp", "projectedfslib")
- add_ldflags("/delayload:ProjectedFSLib.dll")
+ add_ldflags("/delayload:ProjectedFSLib.dll", {force = true})
else
remove_files("windows/**")
end
diff --git a/src/zenserver/zenserver.rc b/src/zenserver/zenserver.rc
index f353bd9cc..abe1acf71 100644
--- a/src/zenserver/zenserver.rc
+++ b/src/zenserver/zenserver.rc
@@ -28,7 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDI_ICON1 ICON "..\\zen.ico"
+IDI_ICON1 ICON "../zen.ico"
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////