Bug 1457295 Trick clang+lld+lto into ordering NSModules correctly also r?glandium draft
authorTom Ritter <tom@mozilla.com>
Fri, 27 Apr 2018 09:29:37 -0500
changeset 790166 1bdf332d4ea5e95384aa5d065c5b9900104c7168
parent 789921 62a225fe5eced07b9ea95163bf5eb6f947440a9a
child 791100 70468922e0d7dd08437af54b0452917390bf9436
push id108438
push userbmo:tom@mozilla.com
push dateTue, 01 May 2018 15:38:57 +0000
reviewersglandium
bugs1457295
milestone61.0a1
Bug 1457295 Trick clang+lld+lto into ordering NSModules correctly also r?glandium MozReview-Commit-ID: 4JgOOVhA3YU
toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
--- a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
+++ b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
@@ -4,13 +4,18 @@
  * on Windows. Somehow, placing the object last is not enough with PGO/LTCG. */
 #ifdef _MSC_VER
 /* Sections on Windows are in two parts, separated with $. When linking,
  * sections with the same first part are all grouped, and ordered
  * alphabetically with the second part as sort key. */
 #  pragma section(".kPStaticModules$Z", read)
 #  undef NSMODULE_SECTION
 #  define NSMODULE_SECTION __declspec(allocate(".kPStaticModules$Z"), dllexport)
+#elif MOZ_LTO
+/* Clang+lld with LTO does not order modules correctly either, but fortunately
+ * the same trick works. */
+#  undef NSMODULE_SECTION
+#  define NSMODULE_SECTION __attribute__((section(".kPStaticModules$Z"), visibility("default")))
 #endif
 /* This could be null, but this needs a dummy value to ensure it actually ends
  * up in the same section as other NSMODULE_DEFNs, instead of being moved to a
  * separate readonly section. */
 NSMODULE_DEFN(end_kPStaticModules) = (mozilla::Module*)&NSMODULE_NAME(end_kPStaticModules);