# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/arm.gni")
import("//build/config/compiler/compiler.gni")
# TODO([email protected]): Optimizations temporarily disabled for
# Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
use_arm_neon_optimizations = (target_cpu == "arm" || target_cpu == "arm64") &&
arm_use_neon && !(is_win && !is_clang)
# TODO(crbug.com/1341436) For Windows, to assemble lzma_sdk's assembly files,
# ml64.exe needs to be utilized as llvm-ml cannot yet assemble it. Once llvm-ml
# is able to assemble lzma_sdk assembly files, remove this.
# LzmaDecOpt.asm only works on x64 and not x86.
# https://sourceforge.net/p/sevenzip/discussion/45797/thread/768932e9dd/?limit=25#0d6c
# If enable_lzma_opt is enabled, disable_llvm_ml should be enabled as well.
enable_lzma_opt = host_os == "win" && target_cpu == "x64" && !is_msan
if (enable_lzma_opt) {
assert(disable_llvm_ml)
}
config("lzma_sdk_config") {
include_dirs = [
".",
"./C",
]
if (enable_lzma_opt) {
include_dirs += [ "./Asm/x86" ]
}
}
# Must be in a config for -Wno-self-assign because of how GN orders flags
# (otherwise -Wall will appear after this, and turn it back on).
config("lzma_build_config") {
defines = [
"_7ZIP_ST",
"_7Z_NO_METHODS_FILTERS",
"_LZMA_PROB32",
]
if (enable_lzma_opt) {
defines += [ "_LZMA_DEC_OPT" ]
}
cflags = []
if (is_clang) {
# Upstream uses self-assignment to avoid warnings.
cflags += [ "-Wno-self-assign" ]
}
if (use_arm_neon_optimizations) {
if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
}
if (target_cpu == "arm" && arm_version >= 8) {
if (is_clang) {
cflags += [
"-march=armv8-a",
"-Xclang",
"-target-feature",
"-Xclang",
"+crc",
"-Xclang",
"-target-feature",
"-Xclang",
"+crypto",
]
} else {
cflags += [ "-march=armv8-a+crc+crypto" ]
}
}
}
}
static_library("lzma_sdk") {
sources = [
"C/7z.h",
"C/7zAlloc.c",
"C/7zAlloc.h",
"C/7zArcIn.c",
"C/7zBuf.c",
"C/7zBuf.h",
"C/7zCrc.c",
"C/7zCrc.h",
"C/7zCrcOpt.c",
"C/7zDec.c",
"C/7zFile.c",
"C/7zFile.h",
"C/7zStream.c",
"C/7zTypes.h",
"C/Alloc.c",
"C/Alloc.h",
"C/Bcj2.c",
"C/Bcj2.h",
"C/Bra.c",
"C/Bra.h",
"C/Bra86.c",
"C/Compiler.h",
"C/CpuArch.c",
"C/CpuArch.h",
"C/Delta.c",
"C/Delta.h",
"C/DllSecur.c",
"C/DllSecur.h",
"C/LzFind.c",
"C/LzFind.h",
"C/LzHash.h",
"C/Lzma2Dec.c",
"C/Lzma2Dec.h",
"C/LzmaDec.c",
"C/LzmaDec.h",
"C/LzmaEnc.c",
"C/LzmaEnc.h",
"C/LzmaLib.c",
"C/LzmaLib.h",
"C/Precomp.h",
]
if (enable_lzma_opt) {
sources += [
"Asm/x86/7zCrcOpt.asm",
"Asm/x86/LzmaDecOpt.asm",
]
sources -= [ "C/7zCrcOpt.c" ]
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
# Must be after no_chromium_code for warning flags to be ordered correctly.
":lzma_build_config",
]
public_configs = [ ":lzma_sdk_config" ]
}
static_library("lzma_sdk_xz") {
sources = [
"C/BraIA64.c",
"C/RotateDefs.h",
"C/Sha256.c",
"C/Sha256.h",
"C/Xz.c",
"C/Xz.h",
"C/XzCrc64.c",
"C/XzCrc64.h",
"C/XzCrc64Opt.c",
"C/XzDec.c",
"C/XzIn.c",
]
# TODO(crbug.com/1338627): Enable ARM optimizations
if (target_cpu == "x86" || target_cpu == "x64") {
sources += [ "C/Sha256Opt.c" ]
}
if (enable_lzma_opt) {
sources += [
"Asm/x86/Sha256Opt.asm",
"Asm/x86/XzCrc64Opt.asm",
]
sources -= [
"C/Sha256Opt.c",
"C/XzCrc64Opt.c",
]
}
deps = [ ":lzma_sdk" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
# Must be after no_chromium_code for warning flags to be ordered correctly.
":lzma_build_config",
]
public_configs = [ ":lzma_sdk_config" ]
}