Bug 1549762 - Turn the linker inline asm into an assembly file. r=glandium
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 16 May 2019 01:02:00 +0000
changeset 535923 b03ccdee521a82535ab492562dd6dc8a334a6f17
parent 535922 97c7af33ac1db2daa8b55c9f4f7e14e342010ab7
child 535924 79ca43bd514a81906b8ac0ec4c8fcbcdc80f4870
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1549762
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549762 - Turn the linker inline asm into an assembly file. r=glandium Differential Revision: https://phabricator.services.mozilla.com/D31051
mozglue/linker/moz.build
mozglue/linker/tests/TestZip.cpp
mozglue/linker/tests/TestZipData.S
mozglue/linker/tests/moz.build
--- a/mozglue/linker/moz.build
+++ b/mozglue/linker/moz.build
@@ -16,27 +16,17 @@ SOURCES += [
 Library('linker')
 
 FINAL_LIBRARY = 'mozglue'
 
 DEFINES['IMPL_MFBT'] = True
 
 DisableStlWrapping()
 
-# Avoid building the linker tests if building with icecc since it doesn't deal
-# well with .incbin.
-#
-# A better solution would be to set ICECC=no in the environment before building
-# these objects to force the local build, but moz.build lacks such a capability
-# at the moment.
-#
-# TODO: Remove this when https://github.com/icecc/icecream/pull/463 is merged
-# and in a release.
-if not CONFIG['CXX_IS_ICECREAM']:
-    TEST_DIRS += ['tests']
+TEST_DIRS += ['tests']
 
 if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
     CXXFLAGS += ['-Wno-error=shadow']
 
 DEFINES['XZ_USE_CRC64'] = 1
 
 USE_LIBS += [
     'xz-embedded',
--- a/mozglue/linker/tests/TestZip.cpp
+++ b/mozglue/linker/tests/TestZip.cpp
@@ -7,63 +7,41 @@
 #include "Zip.h"
 #include "mozilla/RefPtr.h"
 
 #include "gtest/gtest.h"
 
 Logging Logging::Singleton;
 
 /**
- * ZIP_DATA(FOO, "foo") defines the variables FOO and FOO_SIZE.
- * The former contains the content of the "foo" file in the same directory
- * as this file, and FOO_SIZE its size.
- */
-/* clang-format off */
-#define ZIP_DATA(name, file)                          \
-  __asm__(".global " #name "\n"                       \
-          ".data\n"                                   \
-          ".balign 16\n"                              \
-          #name ":\n"                                 \
-          "  .incbin \"" SRCDIR "/" file "\"\n"       \
-          ".L" #name "_END:\n"                        \
-          "  .size " #name ", .L" #name "_END-" #name \
-          "\n"                                        \
-          ".global " #name "_SIZE\n"                  \
-          ".data\n"                                   \
-          ".balign 4\n"                               \
-          #name "_SIZE:\n"                            \
-          "  .int .L" #name "_END-" #name "\n");      \
-  extern const unsigned char name[];                  \
-  extern const unsigned int name##_SIZE
-/* clang-format on */
-
-/**
  * test.zip is a basic test zip file with a central directory. It contains
  * four entries, in the following order:
  * "foo", "bar", "baz", "qux".
  * The entries are going to be read out of order.
  */
-ZIP_DATA(TEST_ZIP, "test.zip");
+extern const unsigned char TEST_ZIP[];
+extern const unsigned int TEST_ZIP_SIZE;
 const char* test_entries[] = {"baz", "foo", "bar", "qux"};
 
 /**
  * no_central_dir.zip is a hand crafted test zip with no central directory
  * entries. The Zip reader is expected to be able to traverse these entries
  * if requested in order, without reading a central directory
  * - First entry is a file "a", STOREd.
  * - Second entry is a file "b", STOREd, using a data descriptor. CRC is
  *   unknown, but compressed and uncompressed sizes are known in the local
  *   file header.
  * - Third entry is a file "c", DEFLATEd, using a data descriptor. CRC,
  *   compressed and uncompressed sizes are known in the local file header.
  *   This is the kind of entry that can be found in a zip that went through
  *   zipalign if it had a data descriptor originally.
  * - Fourth entry is a file "d", STOREd.
  */
-ZIP_DATA(NO_CENTRAL_DIR_ZIP, "no_central_dir.zip");
+extern const unsigned char NO_CENTRAL_DIR_ZIP[];
+extern const unsigned int NO_CENTRAL_DIR_ZIP_SIZE;
 const char* no_central_dir_entries[] = {"a", "b", "c", "d"};
 
 TEST(Zip, TestZip)
 {
   Zip::Stream s;
   RefPtr<Zip> z = Zip::Create((void*)TEST_ZIP, TEST_ZIP_SIZE);
   for (auto& entry : test_entries) {
     ASSERT_TRUE(z->GetStream(entry, &s))
new file mode 100644
--- /dev/null
+++ b/mozglue/linker/tests/TestZipData.S
@@ -0,0 +1,17 @@
+.macro zip_data name, path
+  .global \name
+  .data
+  .balign 16
+  \name:
+  .incbin "\path"
+  .L\name\()_END:
+  .size \name, .L\name\()_END-\name
+  .global \name\()_SIZE
+  .data
+  .balign 4
+  \name\()_SIZE:
+  .int .L\name\()_END-\name
+.endm
+
+zip_data TEST_ZIP, "test.zip"
+zip_data NO_CENTRAL_DIR_ZIP, "no_central_dir.zip"
--- a/mozglue/linker/tests/moz.build
+++ b/mozglue/linker/tests/moz.build
@@ -6,14 +6,18 @@
 
 FINAL_LIBRARY = 'xul-gtest'
 
 UNIFIED_SOURCES += [
     '../Zip.cpp',
     'TestZip.cpp',
 ]
 
+SOURCES += [
+    'TestZipData.S',
+]
+
 LOCAL_INCLUDES += ['..']
 
 if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
     CXXFLAGS += ['-Wno-error=shadow']
 
-DEFINES['SRCDIR'] = '"%s"' % SRCDIR
+ASFLAGS += ['-I', SRCDIR]