[PATCH] D89518: [windows-itanium] Add Windows Itanium How-To Guide

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 23:23:55 PDT 2020


mstorsjo added inline comments.


================
Comment at: llvm/docs/HowToBuildWindowsItaniumPrograms.rst:39
+
+link.exe (the MS linker) is unsuitable as it rejects the COMDATs produced by
+LLVM. It also doesn't support auto-importing which is currently required.
----------------
Did you look into why it produces such comdats? Because for msvc triple targets, it should work with link.exe.


================
Comment at: llvm/docs/HowToBuildWindowsItaniumPrograms.rst:53
+addresses are patched into the IAT). Therefore, the compiler must emit some code,
+that runs after IAT patching but before anything that might use the vtable pointers,
+and sets the vtable pointer to the address from the IAT. For the special case of
----------------
Actually - the code for patching it isn't emitted by either compiler or linker, it's done by the `_pei386_runtime_relocator` function in the mingw runtime. The linker just generates a list of fixups that the runtime later will need to process. If the runtime that processes this list isn't linked in, it won't work. Unfortunately, this can happen silently...

Have you checked this aspect, that it actually works as intended?

See https://github.com/mstorsjo/llvm-project/commit/lld-pseudo-relocs for a patch (not recently rebased, unfortunately) to lld that makes it force a reference to this function, if runtime fixups actually are needed. That would make it clear if it's needed, but missing.

Finally, the `_pei386_runtime_relocator` function also needs to be called. Currently in the mingw-w64 runtime, it's always called unconditionally by other startup code, but with a change like https://github.com/mstorsjo/mingw-w64/commit/pseudo-reloc-ctor, that object file would have a ctor that forces it to be called autonomously, if the object file is linked in. (Unfortunately, that change doesn't work with ld.bfd as it is right now, so it isn't upstreamed.)


================
Comment at: llvm/docs/HowToBuildWindowsItaniumPrograms.rst:57
+there is no declaration available to the compiler so this can't be done. To allow
+programs to link we currently rely on the -lldmingw switch in LLD to auto-import
+references to __cxxabiv1::__class_type_info pointers (see: https://reviews.llvm.org/D43184
----------------
Fwiw, since release 11, you can enable autoimporting alone without enabling the rest of the mingw specific quirks, with the `-autoimport` flag. Also see D89006 for a recent related fixup.


================
Comment at: llvm/docs/HowToBuildWindowsItaniumPrograms.rst:118
+
+Building ibc++abi:
+------------------
----------------
Typo, libc++abi


================
Comment at: llvm/docs/HowToBuildWindowsItaniumPrograms.rst:176
+
+* ``-DCMAKE_C_FLAGS="-Xlinker /force:multiple"``
+
----------------
Why is that needed? If it's the same thing I've run into at some point, you can add `-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF` to avoid the redundant symbols.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89518/new/

https://reviews.llvm.org/D89518



More information about the llvm-commits mailing list