Skip to content

Commit 62023b6

Browse files
committed
Improve newish clang/zig support
1 parent f5db016 commit 62023b6

File tree

6 files changed

+62
-3
lines changed

6 files changed

+62
-3
lines changed

Makefile.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ SRCWRTIMER_ROOT_DIR="${CARGO_MAKE_WORKING_DIRECTORY}"
8181
EXTERNALDIR="${SRCWRTIMER_ROOT_DIR}/_external"
8282
PACKAGEDIR="${CARGO_MAKE_WORKING_DIRECTORY}/_package"
8383

84-
# Problem with master (as of 2024-09-30):
84+
# Problem with 0.14.0 (as of 2024-09-30 (and still as of 2025-03-06)):
8585
# `zig: error: version '.2.26' in target triple 'x86-unknown-linux-gnu.2.26' is invalid`
86+
# (also when using '.2.29')
8687
# Probably related: https://github.com/ziglang/zig/issues/16630
8788
# Back to "0.13.0" for now...
8889
ZIGDLVER="0.13.0" ### UPDATE .github/workflows/build-everything.yml whenever this is updated.
@@ -364,6 +365,7 @@ fn do_everything
364365
exec git clone "${EXTERNALDIR}/alliedmodders/hl2sdk-proxy-repo" "${EXTERNALDIR}/alliedmodders/hl2sdk-css" -b css
365366
cd "${EXTERNALDIR}/alliedmodders/hl2sdk-css/"
366367
exec git apply --whitespace=fix ../../../extshared_build_helper/src/c++23-for-hl2sdk-css-1.patch
368+
exec git apply --whitespace=fix ../../../extshared_build_helper/src/0001-Fix-non-const-reference-cannot-bind-to-bit-field-err.patch
367369
end
368370
do_everything
369371
'''

extshared/src/extension.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const char *MyExtension::GetExtensionAuthor()
179179

180180
const char *MyExtension::GetExtensionDateString()
181181
{
182-
return SMEXT_CONF_DATESTRING;
182+
return rust_conf_datestring();
183183
}
184184

185185
const char *MyExtension::GetExtensionDescription()

extshared/src/rust_exports.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ void rust_sdk_on_all_loaded();
1414
void rust_on_core_map_start(void* edict_list, int edict_count, int client_max);
1515
void rust_on_core_map_end();
1616
const char* rust_conf_name();
17+
const char* rust_conf_datestring();
1718
const char* rust_conf_description();
1819
const char* rust_conf_version();
1920
const char* rust_conf_author();

extshared/src/smext_conf_boilerplate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ macro_rules! smext_conf_boilerplate_extension_info {
4242
concat!(env!("CARGO_PKG_AUTHORS"), "\0").as_ptr()
4343
}
4444
#[unsafe(no_mangle)]
45+
pub extern "C" fn rust_conf_datestring() -> *const u8 {
46+
concat!(env!("VERGEN_BUILD_DATE"), "\0").as_ptr()
47+
}
48+
#[unsafe(no_mangle)]
4549
pub extern "C" fn rust_conf_url() -> *const u8 {
4650
concat!(
4751
env!("CARGO_PKG_HOMEPAGE"),

extshared/src/smsdk_config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#define SMEXT_CONF_URL "https://github.com/srcwr/srcwrtimer (THIS ISN'T USED)"
1212
#define SMEXT_CONF_LOGTAG "SRCWR (THIS ISN'T USED)"
1313
#define SMEXT_CONF_LICENSE "GPL-3.0-or-later (THIS ISN'T USED)"
14-
#define SMEXT_CONF_DATESTRING __DATE__
14+
//#define SMEXT_CONF_DATESTRING __DATE__
15+
#define SMEXT_CONF_DATESTRING "UNKNOWN (THIS ISN'T USED)"
1516

1617
#ifndef SOURCE_ENGINE
1718
#define META_NO_HL2SDK
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From f3db078d94224f4bebd9c7a8615a277e55b92efe Mon Sep 17 00:00:00 2001
2+
From: rtldg <[email protected]>
3+
Date: Thu, 6 Mar 2025 08:14:39 +0000
4+
Subject: [PATCH] Fix 'non-const reference cannot bind to bit-field' error with
5+
newer clang versions
6+
7+
This specifically shows up when trying to use zig 0.14.0 (llvm 19.1.7) to cross-compile to Linux.
8+
9+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/CDetour/detours.cpp:1:
10+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/CDetour/detours.h:36:
11+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/smsdk_ext.h:100:
12+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/mmsource/core/ISmmPlugin.h:39:
13+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/mmsource/core/ISmmAPI.h:47:
14+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/eiface.h:16:
15+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/convar.h:21:
16+
In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlvector.h:25:
17+
H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlblockmemory.h:141:10: error: non-const reference cannot bind to bit-field 'm_nIndexShift'
18+
141 | V_swap( m_nIndexShift, mem.m_nIndexShift );
19+
| ^~~~~~~~~~~~~
20+
H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlblockmemory.h:111:6: note: bit-field is declared here
21+
111 | int m_nIndexShift : 5;
22+
| ^
23+
H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/mathlib/mathlib.h:717:29: note: passing argument to parameter 'x' here
24+
717 | FORCEINLINE void V_swap( T& x, T& y )
25+
| ^ ^
26+
---
27+
public/tier1/utlblockmemory.h | 8 ++++++--
28+
1 file changed, 6 insertions(+), 2 deletions(-)
29+
30+
diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h
31+
index 8d86c59e..4782e235 100644
32+
--- a/public/tier1/utlblockmemory.h
33+
+++ b/public/tier1/utlblockmemory.h
34+
@@ -137,8 +137,12 @@ void CUtlBlockMemory<T,I>::Swap( CUtlBlockMemory< T, I > &mem )
35+
{
36+
V_swap( m_pMemory, mem.m_pMemory );
37+
V_swap( m_nBlocks, mem.m_nBlocks );
38+
- V_swap( m_nIndexMask, mem.m_nIndexMask );
39+
- V_swap( m_nIndexShift, mem.m_nIndexShift );
40+
+ int tmp = m_nIndexMask;
41+
+ m_nIndexMask = mem.m_nIndexMask;
42+
+ mem.m_nIndexMask = tmp;
43+
+ tmp = m_nIndexShift;
44+
+ m_nIndexShift = mem.m_nIndexShift;
45+
+ mem.m_nIndexShift = tmp;
46+
}
47+
48+
49+
--
50+
2.47.1.windows.1
51+

0 commit comments

Comments
 (0)