Skip to content

Commit 898525c

Browse files
committed
fix: use the default MSVC entry for plugins that define _DllMainCRTStartup
1 parent a4d4049 commit 898525c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

scripts/build_c.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,13 @@ def tool(name):
172172
*[f"{lib}.lib" for lib in LIBS],
173173
]
174174
if cfg["crt"] == "none":
175-
# Decorated on x86 like the mingw entry; the linker's own undecorated lookup misses C++ objects
176-
entry = "DllMain@12" if arch == "x86" else "DllMain"
177-
link += ["/NODEFAULTLIB", f"/ENTRY:{entry}"]
175+
link.append("/NODEFAULTLIB")
176+
# /Zl predefines _VC_NODEFAULTLIB, which Plugins use to rename DllMain to the linker's default entry
177+
if not any(
178+
"_DllMainCRTStartup" in Path(s).read_text(errors="ignore")
179+
for s in cfg["sources"]
180+
):
181+
link.append("/ENTRY:DllMain")
178182
else:
179183
# A Plugin defining its own _DllMainCRTStartup keeps libcmt's startup object,
180184
# and with it these defaultlib references, out of the link

0 commit comments

Comments
 (0)