[all-commits] [llvm/llvm-project] a2b8c4: [clang] [MinGW] Explicitly always pass the -fno-us...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Mon Oct 9 23:56:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a2b8c49c1839076b540c542c024fcfe2361a3e47
      https://github.com/llvm/llvm-project/commit/a2b8c49c1839076b540c542c024fcfe2361a3e47
  Author: Martin Storsjö <martin at martin.st>
  Date:   2023-10-10 (Tue, 10 Oct 2023)

  Changed paths:
    M clang/lib/Driver/ToolChains/MinGW.cpp
    M clang/test/Driver/mingw.cpp

  Log Message:
  -----------
  [clang] [MinGW] Explicitly always pass the -fno-use-init-array (#68571)

On MinGW targets, the .ctors section is always used for constructors.

When using the .ctors section, the constructors need to be emitted in
reverse order to get them execute in the right order. (Constructors with
a specific priority are sorted separately by the linker later.) In LLVM,
in CodeGen/AsmPrinter/AsmPrinter.cpp, there's code that reverses them
before writing them out, executed when using the .ctors section. This
logic is done whenever TM.Options.UseInitArray is set to false. Thus,
make sure to set UseInitArray to false for this target.

This fixes https://github.com/llvm/llvm-project/issues/55938.




More information about the All-commits mailing list