The Halide project uses `#pragma comment(linker, "/STACK:...")` to set
the stack size high enough for our embedded compiler to run in end-user
programs on Windows.
Unfortunately, lld-link.exe breaks on this when embedded in a COFF
object, despite supporting the flag on the command line. MSVC's link.exe
supports this fine. This patch extends support for this to lld-link.exe
for better compatibility with MSVC projects.
Differential Revision: https://reviews.llvm.org/D99680
case OPT_section:
parseSection(arg->getValue());
break;
+ case OPT_stack:
+ parseNumbers(arg->getValue(), &config->stackReserve,
+ &config->stackCommit);
+ break;
case OPT_subsystem: {
bool gotVersion = false;
parseSubsystem(arg->getValue(), &config->subsystem,
--- /dev/null
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %s -o %t.obj
+# RUN: lld-link /out:%t.exe /entry:main %t.obj
+# RUN: llvm-readobj --file-headers %t.exe | FileCheck %s
+
+# CHECK: SizeOfStackReserve: 20480
+# CHECK: SizeOfStackCommit: 12288
+
+ .text
+ .globl main
+main:
+ mov $42, %eax
+ ret
+
+ .section .drectve,"yn"
+ .ascii " -stack:0x5000,0x3000"