Bug 1650299 - Unify the inclusion of the ICU data file. r?froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 3 Jul 2020 04:28:39 +0000 (13:28 +0900)
committerMike Hommey <glandium@debian.org>
Mon, 9 Nov 2020 22:27:07 +0000 (22:27 +0000)
All the supported compilers support a GNU AS-like syntax, with only a
few details varying. It means we can use a single, simpler, way to
include the ICU data file, instead of 3 different ways, including one
that uses armasm64.exe, possibly wrapped with Wine.

Differential Revision: https://phabricator.services.mozilla.com/D82144

Gbp-Pq: Topic fixes
Gbp-Pq: Name Bug-1650299-Unify-the-inclusion-of-the-ICU-data-file.patch

config/external/icu/data/genicudata.py [deleted file]
config/external/icu/data/icudata.c [new file with mode: 0644]
config/external/icu/data/icudata.s [deleted file]
config/external/icu/data/icudata_gas.S [deleted file]
config/external/icu/data/moz.build
js/moz.configure

diff --git a/config/external/icu/data/genicudata.py b/config/external/icu/data/genicudata.py
deleted file mode 100644 (file)
index 50bc939..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from __future__ import absolute_import
-import buildconfig
-
-
-def main(output, data_file, data_symbol):
-    if buildconfig.substs.get('WINE'):
-        drive = 'z:'
-    else:
-        drive = ''
-    output.write('''    AREA |.rdata|,ALIGN=4,DATA,READONLY
-    EXPORT |{data_symbol}|[DATA]
-|{data_symbol}|
-    INCBIN {drive}{data_file}
-    END
-'''.format(data_file=data_file, data_symbol=data_symbol, drive=drive))
diff --git a/config/external/icu/data/icudata.c b/config/external/icu/data/icudata.c
new file mode 100644 (file)
index 0000000..7299ac9
--- /dev/null
@@ -0,0 +1,28 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifdef __APPLE__
+#  define RODATA ".data\n.const"
+#else
+#  define RODATA ".section .rodata"
+#endif
+
+#if defined(__APPLE__) || (defined(_WIN32) && defined(__i386__))
+#  define _PREFIXED(x) _##x
+#else
+#  define _PREFIXED(x) x
+#endif
+#define PREFIXED(x) _PREFIXED(x)
+
+#define DATA(sym, file) DATA2(sym, file)
+// clang-format off
+#define DATA2(sym, file)              \
+  __asm__(".global " #sym "\n"        \
+          RODATA "\n"                 \
+          ".balign 16\n"              \
+          #sym ":\n"                  \
+          "    .incbin " #file "\n")
+// clang-format on
+
+DATA(PREFIXED(ICU_DATA_SYMBOL), ICU_DATA_FILE);
diff --git a/config/external/icu/data/icudata.s b/config/external/icu/data/icudata.s
deleted file mode 100644 (file)
index a740f32..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-;; This Source Code Form is subject to the terms of the Mozilla Public
-;; License, v. 2.0. If a copy of the MPL was not distributed with this
-;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-%ifdef PREFIX
-    %define DATA_SYMBOL _ %+ ICU_DATA_SYMBOL
-%else
-    %define DATA_SYMBOL ICU_DATA_SYMBOL
-%endif
-
-%ifidn __OUTPUT_FORMAT__,elf
-    %define FORMAT_ELF 1
-%elifidn __OUTPUT_FORMAT__,elf32
-    %define FORMAT_ELF 1
-%elifidn __OUTPUT_FORMAT__,elf64
-    %define FORMAT_ELF 1
-%else
-    %define FORMAT_ELF 0
-%endif
-
-%if FORMAT_ELF
-    global DATA_SYMBOL:data hidden
-    ; This is needed for ELF, otherwise the GNU linker assumes the stack is executable by default.
-    [SECTION .note.GNU-stack noalloc noexec nowrite progbits]
-%else
-    global DATA_SYMBOL
-%endif
-
-SECTION .rodata align=16
-DATA_SYMBOL:
-        incbin ICU_DATA_FILE
diff --git a/config/external/icu/data/icudata_gas.S b/config/external/icu/data/icudata_gas.S
deleted file mode 100644 (file)
index 6c9abc8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
-#ifdef PREFIX
-#  define DATA_SYMBOL _##ICU_DATA_SYMBOL
-#else
-#  define DATA_SYMBOL ICU_DATA_SYMBOL
-#endif
-.global DATA_SYMBOL
-.data
-.balign 16
-DATA_SYMBOL:
-        .incbin ICU_DATA_FILE
index d4741a06685080668560d1389de0a8b1c94aef9a..023b4e9f49ea2a6ee1dc42f6c4b0bf9d9154faba 100644 (file)
@@ -8,29 +8,10 @@
 # JSAPI consumers don't have to deal with setting ICU's data path.
 Library('icudata')
 
-if CONFIG['OS_ARCH'] == 'WINNT':
-    if CONFIG['CPU_ARCH'] == 'x86':
-        ASFLAGS += ['-DPREFIX']
-elif CONFIG['OS_ARCH'] == 'Darwin':
-    ASFLAGS += ['-DPREFIX']
-
-data_symbol = 'icudt%s_dat' % CONFIG['MOZ_ICU_VERSION']
-asflags = [
-    '-I%s/config/external/icu/data/' % TOPSRCDIR,
-    '-DICU_DATA_FILE="%s"' % CONFIG['ICU_DATA_FILE'],
-    '-DICU_DATA_SYMBOL=%s' % data_symbol,
-]
 LOCAL_INCLUDES += ['.']
 
-if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64':
-    icudata = 'icudata.asm'
-    GeneratedFile(icudata, script='genicudata.py',
-                  inputs=[CONFIG['ICU_DATA_FILE']], flags=[data_symbol])
-    SOURCES += ['!%s' % icudata]
-elif CONFIG['HAVE_YASM']:
-    USE_YASM = True
-    SOURCES += ['icudata.s']
-    ASFLAGS += asflags
-elif CONFIG['GNU_AS']:
-    SOURCES += ['icudata_gas.S']
-    ASFLAGS += asflags
+DEFINES['ICU_DATA_FILE'] = '"icudt%sl.dat"' % CONFIG['MOZ_ICU_VERSION']
+DEFINES['ICU_DATA_SYMBOL'] = 'icudt%s_dat' % CONFIG['MOZ_ICU_VERSION']
+SOURCES += [
+    'icudata.c',
+]
index b1c9685733b03d3642f1ae2dc0125b2486ed48ad..4ac0bd8220fa7b2a97ba0479ec21b2712b6236c8 100644 (file)
@@ -760,13 +760,6 @@ def icu_version(build_env):
 
 set_config('MOZ_ICU_VERSION', icu_version)
 
-@depends(icu_version, target, when='--with-intl-api')
-def icu_data_file(version, target):
-    # target.endianness is always 'big' or 'little'
-    return 'icudt%s%s.dat' % (version, target.endianness[0])
-
-set_config('ICU_DATA_FILE', icu_data_file)
-
 # Source files that use ICU should have control over which parts of the ICU
 # namespace they want to use.
 set_define('U_USING_ICU_NAMESPACE', '0', when='--with-intl-api')