Bug 1380195 Ensure xz settings are compatible with mozglue XZStream.cpp r=glandium,nalexander

Ensure stream only has a single LZMA block.
Ensure that dictionary size is always 8 MiB.

MozReview-Commit-ID: A0CV6M3LIf9

--HG--
extra : rebase_source : e5e35a33dd34a9eebae46f94c1c0fabf74038946
This commit is contained in:
Brian Murray 2017-07-11 17:20:39 -07:00
parent 9b268f64a9
commit 0ee2f3a4f5

View File

@ -73,6 +73,12 @@ def package_fennec_apk(inputs=[], omni_ja=None, classes_dex=None,
cmd = [buildconfig.substs.get('XZ'), '-zkf',
mozpath.join(finder.base, p)]
# For now, the mozglue XZStream ELF loader can only support xz files
# with a single stream that contains a single block. In xz, there is no
# explicit option to set the max block count. Instead, we force xz to use
# single thread mode, which results in a single block.
cmd.extend(['--threads=1'])
bcj = None
if buildconfig.substs.get('MOZ_THUMB2'):
bcj = '--armthumb'
@ -82,7 +88,14 @@ def package_fennec_apk(inputs=[], omni_ja=None, classes_dex=None,
bcj = '--x86'
if bcj:
cmd.extend([bcj, '--lzma2'])
cmd.extend([bcj])
# We need to explicitly specify the LZMA filter chain to ensure consistent builds
# across platforms. Note that the dict size must be less then 16MiB per the hardcoded
# value in mozglue/linker/XZStream.cpp. This is the default LZMA filter chain for for
# xz-utils version 5.0. See:
# https://github.com/xz-mirror/xz/blob/v5.0.0/src/liblzma/lzma/lzma_encoder_presets.c
# https://github.com/xz-mirror/xz/blob/v5.0.0/src/liblzma/api/lzma/container.h#L31
cmd.extend(['--lzma2=dict=8MiB,lc=3,lp=0,pb=2,mode=normal,nice=64,mf=bt4,depth=0'])
print('xz-compressing %s with %s' % (p, ' '.join(cmd)))
subprocess.check_output(cmd)
os.rename(f.path + '.xz', f.path)