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
+++ /dev/null
-# -*- 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))
--- /dev/null
+/* 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);
+++ /dev/null
-;; 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
+++ /dev/null
-# 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
# 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',
+]
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')