Skip to content

Commit e8ed3d9

Browse files
committed
Workaround msvc 14.51 bad codegen by keep lua unoptimized
1 parent cff0d43 commit e8ed3d9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ xxhash-rust = { git = "https://github.com/dontpanic92/xxhash-rust", branch = "ya
4040
# harmless "patch was not used" warning on other hosts. Keep it for LoongArch.
4141
cty = { git = "https://github.com/amazingfate/cty", branch = "loongarch" }
4242

43+
# Workaround: build the `lua50-32-sys` C library (Lua 5.0.3) unoptimized.
44+
#
45+
# Root cause: MSVC toolset 14.51.36231 (VS 18 / 2026) has a code-generation
46+
# bug that miscompiles Lua 5.0.3 at `/O2` on x86_64 — it corrupts a `Table`'s
47+
# `array`/`sizearray` pair, so the very first `luaopen_base` faults with an
48+
# access violation (hit when constructing a Lua VM, e.g. PAL5/SWD5 story
49+
# directors, in a *release* build). Verified A/B: lua built with toolset 14.44
50+
# at `/O2` runs fine; only 14.51 crashes. Debug (`-O0`) is unaffected.
51+
#
52+
# Disabling optimization for just this (tiny, perf-irrelevant) crate sidesteps
53+
# the bug independently of which MSVC toolset compiles it, keeping release
54+
# builds working on CI and any machine. The override is global because Cargo
55+
# profile overrides cannot be gated by target.
56+
[profile.release.package.lua50-32-sys]
57+
opt-level = 0
58+
4359
[profile.release-with-symbol]
4460
inherits = "release"
4561
debug = true

0 commit comments

Comments
 (0)