Skip to content

Commit 6c8f662

Browse files
committed
Initial x64 conversion
1 parent 9452d61 commit 6c8f662

File tree

10 files changed

+80
-41
lines changed

10 files changed

+80
-41
lines changed

.cargo/config.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[build]
22
target-dir = "_build"
33

4-
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
5-
rustflags = ["-Ctarget-feature=+sse2"]
4+
# FUCK YOU TO PEOPLE WITH OLD CPUS
5+
rustflags = ["-Ctarget-cpu=x86-64-v2"]
66

7-
target = "i686-pc-windows-msvc"
7+
target = "x86_64-pc-windows-msvc"
88

99
[env]
10-
CFLAGS_i686_pc_windows_msvc = "/Zi /FS"
11-
CXXFLAGS_i686_pc_windows_msvc = "/Zi /FS"
10+
CFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
11+
CXXFLAGS_x86_64_pc_windows_msvc = "/Zi /FS"
1212

1313
SRCWRTIMER_ROOT_DIR = { value = ".", relative = true }
1414

15-
[target.i686-pc-windows-msvc]
15+
[target.x86_64-pc-windows-msvc]
1616
rustflags = [
17-
# 2025... we can rely on CPUs to be using SSE2... not that it will likely change much in codegen...
18-
"-Ctarget-feature=+sse2",
17+
# FUCK YOU TO PEOPLE WITH OLD CPUS
18+
"-Ctarget-cpu=x86-64-v2",
1919
# TODO: Do we want static crt on Windows? I can't remember if there was a reason for this...
2020
"-Ctarget-feature=+crt-static",
2121
# Yeah, we want frame pointers...

.github/workflows/build-everything.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Setup SourcePawn Compiler
4141
uses: rumblefrog/setup-sp@v1.2.4
4242
with:
43-
version: '1.12.7177' ### UPDATE Makefile.toml whenever this is updated.
43+
version: '1.12.7183' ### UPDATE Makefile.toml whenever this is updated.
4444
- name: Setup Zig
4545
uses: mlugg/setup-zig@v1
4646
with:

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rust-analyzer.cargo.target": "i686-pc-windows-msvc",
2+
"rust-analyzer.cargo.target": "x86_64-pc-windows-msvc",
33
"rust-analyzer.cargo.extraArgs": ["--release"],
44
"rust-analyzer.check.allTargets": false,
55
"rust-analyzer.checkOnSave.allTargets": false,

Makefile.toml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ ZIGEXT = { source = "${OS}", default_value = "tar.xz", mapping = {"Windows_NT" =
9090
CARGO_ZIGBUILD_ZIG_PATH = { source = "${CI}", default_value = "${EXTERNALDIR}/zig-${HOSTOSPLAIN}/zig", mapping = {"true" = "zig"} }
9191
HOSTZIGTOOLCHAIN = { source = "${OS}", default_value = "x86_64-linux", mapping = {"Windows_NT" = "x86_64-windows"} }
9292

93-
MMSOURCEVER="1.11" # Not always instep with SM versions.
93+
MMBRANCH="master" # Not always instep with SM versions.
9494
SMSHORTVER="1.12" ### UPDATE .github/workflows/build-everything.yml whenever this is updated.
95-
SMBINVER="sourcemod-1.12.0-git7177-${HOSTOSPLAIN}" ### UPDATE .github/workflows/build-everything.yml whenever this is updated.
95+
SMBINVER="sourcemod-1.12.0-git7183-${HOSTOSPLAIN}" ### UPDATE .github/workflows/build-everything.yml whenever this is updated.
9696
SMBINEXT = { source = "${OS}", default_value = "tar.gz", mapping = {"Windows_NT" = "zip"} }
9797
SPCOMP = { source = "${OS}", default_value = "spcomp64", mapping = {"Windows_NT" = "spcomp"} }
9898

@@ -202,19 +202,19 @@ do_everything
202202
[tasks.copy-extensions]
203203
script_runner = "@duckscript"
204204
script = '''
205-
extdir = set "${PACKAGEDIR}/srcwrtimer/addons/sourcemod/extensions"
205+
extdir = set "${PACKAGEDIR}/srcwrtimer/addons/sourcemod/extensions/x64"
206206
builddir = set "${CARGO_MAKE_WORKING_DIRECTORY}/_build"
207207
208208
fn copy_ext
209209
rm "${extdir}/${1}.ext.dll"
210210
rm "${extdir}/${1}.pdb"
211211
rm "${extdir}/${1}.ext.so"
212-
if is_path_exists "${builddir}/i686-pc-windows-msvc/release/${1}.dll"
213-
cp "${builddir}/i686-pc-windows-msvc/release/${1}.dll" "${extdir}/${1}.ext.dll"
214-
cp "${builddir}/i686-pc-windows-msvc/release/${1}.pdb" "${extdir}/${1}.pdb"
212+
if is_path_exists "${builddir}/x86_64-pc-windows-msvc/release/${1}.dll"
213+
cp "${builddir}/x86_64-pc-windows-msvc/release/${1}.dll" "${extdir}/${1}.ext.dll"
214+
cp "${builddir}/x86_64-pc-windows-msvc/release/${1}.pdb" "${extdir}/${1}.pdb"
215215
end
216-
if is_path_exists "${builddir}/i686-unknown-linux-gnu/release/lib${1}.so"
217-
cp "${builddir}/i686-unknown-linux-gnu/release/lib${1}.so" "${extdir}/${1}.ext.so"
216+
if is_path_exists "${builddir}/x86_64-unknown-linux-gnu/release/lib${1}.so"
217+
cp "${builddir}/x86_64-unknown-linux-gnu/release/lib${1}.so" "${extdir}/${1}.ext.so"
218218
end
219219
end
220220
@@ -293,19 +293,19 @@ dependencies = [
293293
[tasks.linux]
294294
toolchain = "nightly"
295295
command = "cargo"
296-
args = ["zigbuild", "--release", "--target", "i686-unknown-linux-gnu.2.26"]
296+
args = ["zigbuild", "--release", "--target", "x86_64-unknown-linux-gnu.2.26"]
297297

298298
[tasks.msvc]
299299
toolchain = "nightly"
300300
command = "cargo"
301301
#env = { "CARGO_LOG" = "cargo::core::compiler::fingerprint=info" }
302-
args = ["build", "--release", "--target", "i686-pc-windows-msvc"]
302+
args = ["build", "--release", "--target", "x86_64-pc-windows-msvc"]
303303

304304
# TODO: xwin not quite worky...
305305
[tasks.msvc.linux]
306306
toolchain = "nightly"
307307
command = "cargo"
308-
args = ["xwin", "build", "--xwin-arch", "x86", "--release", "--target", "i686-pc-windows-msvc"]
308+
args = ["xwin", "build", "--xwin-arch", "x86_64", "--release", "--target", "x86_64-pc-windows-msvc"]
309309

310310
################################################################################
311311
## asdf
@@ -314,12 +314,12 @@ args = ["xwin", "build", "--xwin-arch", "x86", "--release", "--target", "i686-pc
314314
[tasks.rustup-linux]
315315
toolchain = "nightly"
316316
command = "rustup"
317-
args = ["target", "add", "i686-unknown-linux-gnu"]
317+
args = ["target", "add", "x86_64-unknown-linux-gnu"]
318318

319319
[tasks.rustup-msvc]
320320
toolchain = "nightly"
321321
command = "rustup"
322-
args = ["target", "add", "i686-pc-windows-msvc"]
322+
args = ["target", "add", "x86_64-pc-windows-msvc"]
323323

324324
################################################################################
325325
## asdf
@@ -334,7 +334,7 @@ args = ["clone", "-b", "${SMSHORTVER}-dev", "--recursive", "https://github.com/a
334334
[tasks.clone-mm]
335335
condition = { files_not_exist = ["${EXTERNALDIR}/alliedmodders/mmsource"] }
336336
command = "git"
337-
args = ["clone", "https://github.com/alliedmodders/metamod-source", "${EXTERNALDIR}/alliedmodders/mmsource", "-b", "${MMSOURCEVER}-dev"]
337+
args = ["clone", "https://github.com/alliedmodders/metamod-source", "${EXTERNALDIR}/alliedmodders/mmsource", "-b", "${MMBRANCH}"]
338338

339339

340340
# TODO: Add update-hl2sdk which does `git remote update` for the proxy repo and then `git pull` in -css
@@ -346,8 +346,17 @@ args = ["clone", "--mirror", "https://github.com/alliedmodders/hl2sdk", "${EXTER
346346

347347
[tasks.clone-hl2sdk-css]
348348
condition = { files_not_exist = ["${EXTERNALDIR}/alliedmodders/hl2sdk-css"] }
349-
command = "git"
350-
args = ["clone", "${EXTERNALDIR}/alliedmodders/hl2sdk-proxy-repo", "${EXTERNALDIR}/alliedmodders/hl2sdk-css", "-b", "css"]
349+
#command = "git"
350+
#args = ["clone", "${EXTERNALDIR}/alliedmodders/hl2sdk-proxy-repo", "${EXTERNALDIR}/alliedmodders/hl2sdk-css", "-b", "css"]
351+
script_runner = "@duckscript"
352+
script = '''
353+
fn do_everything
354+
exec git clone "${EXTERNALDIR}/alliedmodders/hl2sdk-proxy-repo" "${EXTERNALDIR}/alliedmodders/hl2sdk-css" -b css
355+
cd "${EXTERNALDIR}/alliedmodders/hl2sdk-css/"
356+
exec git apply --whitespace=fix ../../../extshared_build_helper/src/c++23-for-hl2sdk-css-1.patch
357+
end
358+
do_everything
359+
'''
351360

352361

353362
[tasks.clone-alliedmodders]

closestpos-rs/src/natives_closestpos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static cell_t N_ClosestPos_ClosestPos(IPluginContext* ctx, const cell_t* params)
9898
return ctx->ThrowNativeError("count must be 1 or greater (given %d)", count);
9999
}
100100

101-
count = Zmin(count, (cell_t)size-startidx);
101+
count = Zmin(count, (cell_t)(size-startidx));
102102
}
103103

104104
std::vector<Point> data((size_t)count);

closestpos/src/natives_replay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static cell_t N_ClosestPos_ClosestPos(IPluginContext* ctx, const cell_t* params)
126126
return ctx->ThrowNativeError("count must be 1 or greater (given %d)", count);
127127
}
128128

129-
count = Zmin(count, (cell_t)size-startidx);
129+
count = Zmin(count, (cell_t)(size-startidx));
130130
}
131131

132132
std::vector<Point> *data = new std::vector<Point>(count);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/public/tier1/utlsymbol.h b/public/tier1/utlsymbol.h
2+
index d55afdc7..38c36e88 100644
3+
--- a/public/tier1/utlsymbol.h
4+
+++ b/public/tier1/utlsymbol.h
5+
@@ -105,7 +105,7 @@ public:
6+
7+
inline bool HasElement( const char* pStr ) const
8+
{
9+
- return Find( pStr ) != UTL_INVAL_SYMBOL;
10+
+ return Find( pStr ) != CUtlSymbol(UTL_INVAL_SYMBOL);
11+
}
12+
13+
// Remove all symbols in the table.

extshared_build_helper/src/lib.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,25 @@ pub fn smext_hl2sdk_for_good_games(build: &mut cc::Build, sdk_name: &str, sdk_id
150150
.define("SOURCE_ENGINE", sdk_id.to_string().as_str());
151151

152152
if !target_windows {
153-
build.define("NO_HOOK_MALLOC", None).define("NO_MALLOC_OVERRIDE", None);
153+
build
154+
.define("NO_HOOK_MALLOC", None)
155+
.define("NO_MALLOC_OVERRIDE", None)
156+
.define("LINUX", None);
154157
}
155158

156159
if like_msvc {
157-
//build.define("", None);
160+
build.define("COMPILER_MSVC", "1").define("COMPILER_MSVC64", "1");
161+
} else {
162+
build.define("COMPILER_GCC", "1");
158163
}
159164

160165
let (lib_folder, links) = if target_windows {
161-
(format!("{}/lib/public", sdk_path), vec![
166+
(format!("{sdk_path}/lib/public/x64"), vec![
162167
"tier0", "tier1", "vstdlib", "mathlib",
163168
])
164169
} else {
165170
(
166-
format!("{}/lib/linux", sdk_path),
171+
format!("{sdk_path}/lib/public/linux64"),
167172
// vec!["tier1_i486", "mathlib_i486"] // ??????
168173
vec![],
169174
)
@@ -207,12 +212,20 @@ pub fn link_sm_detours(mainbuild: &mut cc::Build) {
207212

208213
if like_msvc {
209214
detours
215+
.define("COMPILER_MSVC", "1")
216+
.define("COMPILER_MSVC64", "1")
210217
.flag("/std:c++latest") // /std:c++23 doesn't exist yet!! crazy! TODO: periodically check this https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
211218
.flag("/permissive-")
212219
// C++ stack unwinding & extern "C" don't throw...
213220
.flag("/EHsc");
214221
} else {
215-
detours.flag("-std=c++23");
222+
detours
223+
.define("COMPILER_GCC", "1")
224+
.flag("-std=c++23")
225+
.define("LINUX", None)
226+
.flag("-Wno-unknown-pragmas")
227+
.flag("-Wno-dangling-else")
228+
.flag("-Wno-deprecated-volatile");
216229
}
217230

218231
detours.compile("safetyhook_and_shit");
@@ -275,8 +288,11 @@ pub fn smext_build() -> cc::Build {
275288
// println!("cargo::rustc-link-arg=/OUT:_build\\i686-pc-windows-msvc\\release\\{}.ext.dll", std::env::var("CARGO_PKG_NAME").unwrap());
276289

277290
build
291+
.define("COMPILER_MSVC", "1")
292+
.define("COMPILER_MSVC64", "1")
278293
.flag("/std:c++latest") // /std:c++23 doesn't exist yet!! crazy! TODO: periodically check this https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
279294
// We also set /Zi and /FS in .cargo/config.toml with some cc-crate target-specific environment variables
295+
.flag("/d2archSSE42") // sse4.2!
280296
.flag("/Zi") // debug info things https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format
281297
.flag("/FS") // force synchronous pdb writes https://learn.microsoft.com/en-us/cpp/build/reference/fs-force-synchronous-pdb-writes
282298
.flag("/wd4100") // disable warning C4100: unreferenced formal parameter
@@ -286,13 +302,14 @@ pub fn smext_build() -> cc::Build {
286302
.flag("/Oy-");
287303
} else {
288304
build
289-
.define("stricmp", "strcasecmp")
290-
.define("_stricmp", "strcasecmp")
291305
.define("HAVE_STDINT_H", None)
292306
.define("GNUC", None)
293-
.flag("-m32")
294-
.flag("-msse")
307+
.define("COMPILER_GCC", "1")
308+
.flag("-mcpu=x86_64_v2")
295309
.flag("-std=c++23")
310+
.flag("-Wno-unknown-pragmas")
311+
.flag("-Wno-dangling-else")
312+
.flag("-Wno-deprecated-volatile")
296313
.flag("-Wno-non-virtual-dtor")
297314
.flag("-Wno-overloaded-virtual")
298315
.flag("-Wno-implicit-exception-spec-mismatch")
@@ -317,12 +334,12 @@ pub fn smext_build() -> cc::Build {
317334
build
318335
.define("_CRT_SECURE_NO_WARNINGS", None)
319336
.define("WIN32", None)
337+
.define("WIN64", None)
320338
.define("_WINDOWS", None);
321339
} else {
322340
build
323-
.define("_vsnprintf", "vsnprintf")
324-
.define("_snprintf", "snprintf")
325341
.define("_LINUX", None)
342+
.define("LINUX", None)
326343
.define("GetSMExtAPI", "GetSMExtAPIxxx")
327344
.define("POSIX", None);
328345
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
channel = "nightly"
44
#profile = "default" # TODO: release?
55
# Might break things when building on Linux...
6-
#host = "i686-pc-windows-msvc"
6+
#host = "x86_64-pc-windows-msvc"

srcwrjson/src/natives_json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static cell_t N_SRCWRJSON_GetHandles(IPluginContext* ctx, const cell_t* params)
144144
if (auto search = HandleGroups.find(groupname); search != HandleGroups.end())
145145
{
146146
const auto& group = search->second;
147-
memcpy(handles, group.data(), Zmin((unsigned)count, group.size()) * sizeof(Handle_t));
147+
memcpy(handles, group.data(), Zmin((size_t)count, group.size()) * sizeof(Handle_t));
148148
return 1;
149149
}
150150

0 commit comments

Comments
 (0)