Mark Mentovai 3d6f7bcf90 Enable x86 optimizations for zlib
These were intended to be enabled previously, but GYP uses “ia32” and
“x64” for x86 and x86_64, and zlib.gyp erroneously used “x86” and
“amd64” instead.

In order to make this work, gcc and clang need -mpclmul to enable the
pclmul extension used by crc_folding.c. The optimized code will only be
used if, at runtime, SSE2, SSE4.2, and PCLMULQDQ support is detected.

Change-Id: Ic709cd2a6c38892083c44c4004573a64b3581eb5
Reviewed-on: https://chromium-review.googlesource.com/553337
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-06-28 20:20:36 +00:00

148 lines
4.3 KiB
Python

# Copyright 2017 The Crashpad Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{
'variables': {
'conditions': [
# Use the system zlib by default where available, as it is on most
# platforms. Windows does not have a system zlib, so use “embedded” which
# directs the build to use the source code in the zlib subdirectory.
['OS!="win"', {
'zlib_source%': 'system',
}, {
'zlib_source%': 'embedded',
}],
],
},
'targets': [
{
'target_name': 'zlib',
'conditions': [
['zlib_source=="system"', {
'type': 'none',
'direct_dependent_settings': {
'defines': [
'CRASHPAD_ZLIB_SOURCE_SYSTEM',
],
},
'link_settings': {
'conditions': [
['OS=="mac"', {
'libraries': [
'$(SDKROOT)/usr/lib/libz.dylib',
],
}, {
'libraries': [
'-lz',
],
}],
],
},
}],
['zlib_source=="embedded"', {
'type': 'static_library',
'include_dirs': [
'zlib',
],
'defines': [
'CRASHPAD_ZLIB_SOURCE_EMBEDDED',
'HAVE_STDARG_H',
],
'direct_dependent_settings': {
'include_dirs': [
'zlib',
],
'defines': [
'CRASHPAD_ZLIB_SOURCE_EMBEDDED',
],
},
'sources': [
'zlib/adler32.c',
'zlib/compress.c',
'zlib/crc32.c',
'zlib/crc32.h',
'zlib/crc_folding.c',
'zlib/deflate.c',
'zlib/deflate.h',
'zlib/fill_window_sse.c',
'zlib/gzclose.c',
'zlib/gzguts.h',
'zlib/gzlib.c',
'zlib/gzread.c',
'zlib/gzwrite.c',
'zlib/infback.c',
'zlib/inffast.c',
'zlib/inffast.h',
'zlib/inffixed.h',
'zlib/inflate.c',
'zlib/inflate.h',
'zlib/inftrees.c',
'zlib/inftrees.h',
'zlib/names.h',
'zlib/simd_stub.c',
'zlib/trees.c',
'zlib/trees.h',
'zlib/uncompr.c',
'zlib/x86.c',
'zlib/x86.h',
'zlib/zconf.h',
'zlib/zlib.h',
'zlib/zutil.c',
'zlib/zutil.h',
'zlib_crashpad.h',
],
'conditions': [
['target_arch=="ia32" or target_arch=="x64"', {
'sources!': [
'zlib/simd_stub.c',
],
'cflags': [
'-msse4.2',
'-mpclmul',
],
'xcode_settings': {
'OTHER_CFLAGS': [
'-msse4.2',
'-mpclmul',
],
},
}, {
'sources!': [
'zlib/crc_folding.c',
'zlib/fill_window_sse.c',
'zlib/x86.c',
'zlib/x86.h',
],
}],
['OS!="win"', {
'defines': [
'HAVE_HIDDEN',
'HAVE_UNISTD_H',
],
}, {
'msvs_disabled_warnings': [
4131, # uses old-style declarator
4244, # conversion from 't1' to 't2', possible loss of data
4245, # conversion from 't1' to 't2', signed/unsigned mismatch
4267, # conversion from 'size_t' to 't', possible loss of data
4324, # structure was padded due to alignment specifier
],
}],
],
}],
],
},
],
}