Skip to content

Commit 89521ab

Browse files
committed
[clang] [MinGW] Explicitly always pass the -fno-use-init-array
On MinGW targets, the .ctors section is always used for constructors. Make sure that all layers of code generation is aware of this, wherever it matters, by passing the -fno-use-init-array option, setting the TargetOptions field UseInitArray to false. This fixes llvm#55938.
1 parent 29b2082 commit 89521ab

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Driver/ToolChains/MinGW.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ void toolchains::MinGW::addClangTargetOptions(
709709
}
710710
}
711711

712+
CC1Args.push_back("-fno-use-init-array");
713+
712714
for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
713715
options::OPT_mconsole, options::OPT_mdll}) {
714716
if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))

clang/test/Driver/mingw.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@
7777
// CHECK_NO_SUBSYS-NOT: "--subsystem"
7878
// CHECK_SUBSYS_CONSOLE: "--subsystem" "console"
7979
// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows"
80+
81+
// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_NO_INIT_ARRAY %s
82+
// CHECK_NO_INIT_ARRAY: "-fno-use-init-array"

0 commit comments

Comments
 (0)