Commit c00c874f authored by Amy Huang's avatar Amy Huang Committed by Commit Bot

clang build.py: change LLVM_ENABLE_ZLIB from ON to FORCE_ON

This uses the FORCE_ON option to enable zlib to ensure that clang
actually finds and uses zlib. Also moved this setting out of
base_cmake_args so that it is only used in the main clang build,
since there is another 32-bit build that can't use this zlib.

Also changed to remove and re-download the zlib source on
every build.

Change-Id: Ifceabc2ba06e4e4a56464f18de80610a0f043641
Bug: 1061189
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2118674
Commit-Queue: Amy Huang <akhuang@google.com>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753301}
parent e6126845
...@@ -236,31 +236,29 @@ def AddGnuWinToPath(): ...@@ -236,31 +236,29 @@ def AddGnuWinToPath():
def AddZlibToPath(): def AddZlibToPath():
"""Download and build zlib, and add to PATH.""" """Download and build zlib, and add to PATH."""
zlib_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'zlib-1.2.11') zlib_dir = os.path.join(LLVM_BUILD_TOOLS_DIR, 'zlib-1.2.11')
if not os.path.exists(zlib_dir): if os.path.exists(zlib_dir):
zip_name = 'zlib-1.2.11.tar.gz' RmTree(zlib_dir)
DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR) zip_name = 'zlib-1.2.11.tar.gz'
os.chdir(zlib_dir) DownloadAndUnpack(CDS_URL + '/tools/' + zip_name, LLVM_BUILD_TOOLS_DIR)
zlib_files = [ os.chdir(zlib_dir)
'adler32', 'compress', 'crc32', 'deflate', 'gzclose', 'gzlib', zlib_files = [
'gzread', 'gzwrite', 'inflate', 'infback', 'inftrees', 'inffast', 'adler32', 'compress', 'crc32', 'deflate', 'gzclose', 'gzlib', 'gzread',
'trees', 'uncompr', 'zutil' 'gzwrite', 'inflate', 'infback', 'inftrees', 'inffast', 'trees',
] 'uncompr', 'zutil'
cl_flags = [ ]
'/nologo', '/O2', '/DZLIB_DLL', '/c', '/D_CRT_SECURE_NO_DEPRECATE', cl_flags = [
'/D_CRT_NONSTDC_NO_DEPRECATE' '/nologo', '/O2', '/DZLIB_DLL', '/c', '/D_CRT_SECURE_NO_DEPRECATE',
] '/D_CRT_NONSTDC_NO_DEPRECATE'
]
try: RunCommand(
RunCommand(['cl.exe'] + [f + '.c' for f in zlib_files] + cl_flags, ['cl.exe'] + [f + '.c' for f in zlib_files] + cl_flags, msvc_arch='x64')
msvc_arch='x64') RunCommand(
RunCommand(['lib.exe'] + [f + '.obj' for f in zlib_files] + ['lib.exe'] + [f + '.obj'
['/nologo', '/out:zlib.lib'], msvc_arch='x64') for f in zlib_files] + ['/nologo', '/out:zlib.lib'],
# Remove the test directory so it isn't found when trying to find msvc_arch='x64')
# test.exe. # Remove the test directory so it isn't found when trying to find
shutil.rmtree('test') # test.exe.
except Exception as e: shutil.rmtree('test')
print('Failed to build zlib: ' + str(e))
sys.exit(1)
os.environ['PATH'] = zlib_dir + os.pathsep + os.environ.get('PATH', '') os.environ['PATH'] = zlib_dir + os.pathsep + os.environ.get('PATH', '')
return zlib_dir return zlib_dir
...@@ -487,7 +485,6 @@ def main(): ...@@ -487,7 +485,6 @@ def main():
# Require zlib compression. # Require zlib compression.
zlib_dir = AddZlibToPath() zlib_dir = AddZlibToPath()
base_cmake_args.append('-DLLVM_ENABLE_ZLIB=ON')
cflags.append('-I' + zlib_dir) cflags.append('-I' + zlib_dir)
cxxflags.append('-I' + zlib_dir) cxxflags.append('-I' + zlib_dir)
ldflags.append('-LIBPATH:' + zlib_dir) ldflags.append('-LIBPATH:' + zlib_dir)
...@@ -751,6 +748,8 @@ def main(): ...@@ -751,6 +748,8 @@ def main():
'-DCHROMIUM_TOOLS=%s' % ';'.join(chrome_tools)] '-DCHROMIUM_TOOLS=%s' % ';'.join(chrome_tools)]
if args.pgo: if args.pgo:
cmake_args.append('-DLLVM_PROFDATA_FILE=' + LLVM_PROFDATA_FILE) cmake_args.append('-DLLVM_PROFDATA_FILE=' + LLVM_PROFDATA_FILE)
if sys.platform == 'win32':
cmake_args.append('-DLLVM_ENABLE_ZLIB=FORCE_ON')
if sys.platform == 'darwin': if sys.platform == 'darwin':
cmake_args += ['-DCOMPILER_RT_ENABLE_IOS=ON', cmake_args += ['-DCOMPILER_RT_ENABLE_IOS=ON',
'-DSANITIZER_MIN_OSX_VERSION=10.7'] '-DSANITIZER_MIN_OSX_VERSION=10.7']
...@@ -793,6 +792,7 @@ def main(): ...@@ -793,6 +792,7 @@ def main():
# The bootstrap compiler produces 64-bit binaries by default. # The bootstrap compiler produces 64-bit binaries by default.
cflags += ['-m32'] cflags += ['-m32']
cxxflags += ['-m32'] cxxflags += ['-m32']
compiler_rt_args = base_cmake_args + [ compiler_rt_args = base_cmake_args + [
'-DCMAKE_C_FLAGS=' + ' '.join(cflags), '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
'-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
......
...@@ -41,7 +41,7 @@ import zipfile ...@@ -41,7 +41,7 @@ import zipfile
# Reverting problematic clang rolls is safe, though. # Reverting problematic clang rolls is safe, though.
CLANG_REVISION = 'a1762f9ceb9549b781b7418c7dbe23fe620648f6' CLANG_REVISION = 'a1762f9ceb9549b781b7418c7dbe23fe620648f6'
CLANG_SVN_REVISION = 'n345938' CLANG_SVN_REVISION = 'n345938'
CLANG_SUB_REVISION = 1 CLANG_SUB_REVISION = 2
PACKAGE_VERSION = '%s-%s-%s' % (CLANG_SVN_REVISION, CLANG_REVISION[:8], PACKAGE_VERSION = '%s-%s-%s' % (CLANG_SVN_REVISION, CLANG_REVISION[:8],
CLANG_SUB_REVISION) CLANG_SUB_REVISION)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment