From 2bae70ad5ec4bcc73c7fe5a272d192aed0075d3a Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 3 Jul 2020 13:28:39 +0900 Subject: [PATCH] Bug 1650299 - Unify the inclusion of the ICU data file. r?froydnj 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 | 21 ----------------- config/external/icu/data/icudata.c | 28 +++++++++++++++++++++++ config/external/icu/data/icudata.s | 31 -------------------------- config/external/icu/data/icudata_gas.S | 17 -------------- config/external/icu/data/moz.build | 29 +++++------------------- js/moz.configure | 7 ------ 6 files changed, 33 insertions(+), 100 deletions(-) delete mode 100644 config/external/icu/data/genicudata.py create mode 100644 config/external/icu/data/icudata.c delete mode 100644 config/external/icu/data/icudata.s delete mode 100644 config/external/icu/data/icudata_gas.S diff --git a/config/external/icu/data/genicudata.py b/config/external/icu/data/genicudata.py deleted file mode 100644 index 50bc93988af..00000000000 --- a/config/external/icu/data/genicudata.py +++ /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 index 00000000000..7299ac9f6bc --- /dev/null +++ b/config/external/icu/data/icudata.c @@ -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 index a740f3260b1..00000000000 --- a/config/external/icu/data/icudata.s +++ /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 index 6c9abc822c6..00000000000 --- a/config/external/icu/data/icudata_gas.S +++ /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 diff --git a/config/external/icu/data/moz.build b/config/external/icu/data/moz.build index d4741a06685..023b4e9f49e 100644 --- a/config/external/icu/data/moz.build +++ b/config/external/icu/data/moz.build @@ -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', +] diff --git a/js/moz.configure b/js/moz.configure index b1c9685733b..4ac0bd8220f 100644 --- a/js/moz.configure +++ b/js/moz.configure @@ -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') -- 2.30.2