Skip to content

Commit a0dbcfa

Browse files
committed
Extend legacy_stdio_definitions.lib by _[v]snprintf
Wrt. ldc-developers/ldc#3212; these 2 legacy functions have slightly different semantics than standard [v]snprintf. Also enable optimizations for these printf/scanf functions (mostly forwarding one-liners); they are apparently all still emitted into the object file.
1 parent 8d930c1 commit a0dbcfa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

buildsdk.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ bool defWithStdcallMangling2implib(string defFile)
336336
return true;
337337
}
338338

339-
void c2lib(string outDir, string cFile)
339+
void c2lib(string outDir, string cFile, string clFlags = null)
340340
{
341341
const obj = buildPath(outDir, baseName(cFile).setExtension(".obj"));
342342
const lib = setExtension(obj, ".lib");
343-
cl(obj, quote(cFile));
343+
cl(obj, clFlags ? clFlags ~ " " ~ quote(cFile) : quote(cFile));
344344
runShell(`lib "/OUT:` ~ lib ~ `" ` ~ quote(obj));
345345
std.file.remove(obj);
346346
}
@@ -431,7 +431,7 @@ void buildOldnames(string outDir)
431431

432432
void buildLegacyStdioDefinitions(string outDir)
433433
{
434-
c2lib(outDir, "legacy_stdio_definitions.c");
434+
c2lib(outDir, "legacy_stdio_definitions.c", "/O2");
435435
}
436436

437437
// create empty uuid.lib (expected by dmd, but UUIDs already in druntime)

legacy_stdio_definitions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void __legacy_stdio_definitions()
1515
printf(NULL);
1616
scanf(NULL);
1717
snprintf(NULL, 0, NULL);
18+
_snprintf(NULL, 0, NULL);
1819
sprintf(NULL, NULL);
1920
sscanf(NULL, NULL);
2021
swprintf(NULL, 0, NULL);
@@ -26,6 +27,7 @@ void __legacy_stdio_definitions()
2627
vprintf(NULL, NULL);
2728
vscanf(NULL, NULL);
2829
vsnprintf(NULL, 0, NULL, NULL);
30+
_vsnprintf(NULL, 0, NULL, NULL);
2931
vsprintf(NULL, NULL, NULL);
3032
vsscanf(NULL, NULL, NULL);
3133
vswprintf(NULL, 0, NULL, NULL);
@@ -34,4 +36,4 @@ void __legacy_stdio_definitions()
3436
vwscanf(NULL, NULL);
3537
wprintf(NULL);
3638
wscanf(NULL);
37-
}
39+
}

0 commit comments

Comments
 (0)