Skip to content
Commit 44d9b490 authored by Adenilson Cavalcanti's avatar Adenilson Cavalcanti Committed by Copybara-Service
Browse files

[zlib][build] Add basic CMake buildsystem

Currently Chromium zlib builds using GN and requires build scripts coming
from Chromium source tree (a huge source code checkout).

The idea is to allow to build standalone so no need for a full
checkout plus permit to actually replace the default system zlib in a Linux
system by Chromium zlib.

To checkout and build:
a) git clone https://chromium.googlesource.com/chromium/src/third_party/zlib/ chromium-zlib
b) cd chromium-zlib && mkdir build && cd build
c) cmake -DENABLE_SIMD_OPTIMIZATIONS=1 -DCMAKE_BUILD_TYPE=RELEASE ..
d) make -j
e) sudo make install

A regular app linked with the system zlib will immediately benefit if chromium
zlib is installed with no need to relink as long it is a match for zlib version
(latest release is 1.2.13).

On Ubuntu 22.04 using system zlib 1.2.13, and zlib_bench built with:
g++ -std=c++14 -O3 ../contrib/bench/zlib_bench.cc $(pkg-config --cflags --libs zlib)

a) System zlib:
adenilson@hp:~/chromium/src/third_party/zlib/out$ ldd ./a.out | grep libz
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f24845db000)

adenilson@hp:~/chromium/src/third_party/zlib/out$ ./a.out gzip ~/corpus/flex/*
/home/adenilson/corpus/flex/baddata1.snappy :
GZIP: [b 1M] bytes  27512 ->  22920 83.31% comp  52.7 ( 52.8) MB/s uncomp 207.4 (207.9) MB/s
/home/adenilson/corpus/flex/geo.protodata :
GZIP: [b 1M] bytes 118588 ->  15143 12.77% comp 118.8 (120.1) MB/s uncomp 635.2 (640.6) MB/s
/home/adenilson/corpus/flex/html_x_4     :
GZIP: [b 1M] bytes 409600 ->  53299 13.01% comp  82.7 ( 83.0) MB/s uncomp 568.4 (569.5) MB/s

Now after installing Chromium zlib (no need for rebuild or relink):

b) Chromium zlib:
adenilson@hp:~/chromium/src/third_party/zlib/out$ ldd ./a.out | grep libz
	libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f585ef13000)
adenilson@hp:~/chromium/src/third_party/zlib/out$ ./a.out gzip ~/corpus/flex/*
/home/adenilson/corpus/flex/baddata1.snappy :
GZIP: [b 1M] bytes  27512 ->  22920 83.31% comp  61.8 ( 61.9) MB/s uncomp 428.0 (430.3) MB/s
/home/adenilson/corpus/flex/geo.protodata :
GZIP: [b 1M] bytes 118588 ->  15124 12.75% comp 150.8 (151.4) MB/s uncomp 2121.2 (2135.2) MB/s
/home/adenilson/corpus/flex/html_x_4     :
GZIP: [b 1M] bytes 409600 ->  53285 13.01% comp 102.5 (103.2) MB/s uncomp 1331.6 (1347.5) MB/s

Bug: 1381000
Change-Id: I6a7346076252802a3c866c56e561ebcf5905ccc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4192965


Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Reviewed-by: default avatarChris Blume <cblume@chromium.org>
Commit-Queue: Adenilson Cavalcanti <cavalcantii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1097405}
NOKEYCHECK=True
GitOrigin-RevId: 4b596aee1626fe595a13c50366ff59b0aad84f61
parent dca2b915
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment