-
PDFium 라이브러리 삽질기 - 1Linux 2019. 12. 10. 14:36
PDFium 라이브러리 삽질기 - 1
정적 라이브러리로 빌드하기
작성일자: 2019년 12월 6일
최종수정: 2019년 12월 13일
작성자: N3
0. 개요
PDFium 은 Google 이 Chromium 에서 사용하는 것으로, Google 이 오픈소스로 공개하면서 널리 알려진 라이브러리다.
이 글은 CentOS 7 의 Mapserver 및 GDAL 에서 GeoPDF 를 출력하기 위해 PDFium 을 사용하기 위한 삽질기다.
PDFium은 C++로 작성되었으며, C 인터페이스 또한 제공하고 있다.
라이센스는 BSD 3-clause 라이센스다.
// Copyright 2014 PDFium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
왜 POPPLER 가 아닌 PDFium 인가?
1. 빌드 준비
PDFium 을 빌드하려면, Chromium 의 빌드 도구가 필요하며, 빌드 과정도 비슷하다.- 빌드 및 다운로드 폴더 생성
$ mkdir PDFium
$ cd PDFium
- google depot_tools 다운로드
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
depot_tools 에는 PDFium 의 소스를 내려받고, 빌드하기 위한 파이썬 도구들이 들어있다.
대표적인 스크립트로는 gclient, gn, ninja 가 있다. 이 스크립트들은 git 소스를 내려받고, 빌드를 위한 환경을 생성하고, 빌드하기 위한 옵션들을 생성해는 도구들이다.
- depot_tools 폴더를 PATH에 추가한다.
$ cd depot_tools
$ export $DEPOT_TOOLS=`pwd`
$ export PATH=$PATH:$DEPOT_TOOLS
$ cd ..
- PDFium 소스 내려받기
git 으로 내려받는 것이 아니라, 앞에서 다운로드한 gclient 를 사용해서 소스를 내려받는다.$ gclient config –-unmanaged https://pdfium.googlesource.com/pdfium.git
$ gclient sync -–verbose
$ ls
depot_tools pdfium
$ ls pdfium
git 으로 내려받는 것과 달리 gclient sync 로 내려받은 파일의 차이가 있다는 것을 알 수 있다.
$ git clone https://pdfium.googlesource.com/pdfium.git
git 으로 내려받은 소스에는 build 폴더와 빌드를 위한 스크립트가 없다는 것을 확인할 수 있다.
2. 빌드하기
PDFium( 또는 Chromium)을 빌드하기 위해 필요한 모든 것을 설치하는 스크립트로 install-build-deps.sh 이 있다.[respiro@localhost PDFium]$ cd pdfium
[respiro@localhost pdfium]$ ls
AUTHORS LICENSE README.md build_overrides constants fpdfsdk navbar.md samples third_party xfa
BUILD.gn OWNERS base buildtools core fxbarcode pdfium.gni skia tools
DEPS PRESUBMIT.py build codereview.settings docs fxjs public testing v8
[respiro@localhost pdfium]$ ./build/install-build-deps.sh
which: no lsb_release in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/respiro/.local/bin:/home/respiro/bin:/home/respiro/rpmbuild/SOURCES/PDFium/depot_tools)
ERROR: lsb_release not found in $PATH
기본 빌드 스크립트들이 모두 데비안을 위한 스크립트다.
"\tUbuntu 14.04 LTS (trusty with EoL April 2022)\n" \
"\tUbuntu 16.04 LTS (xenial with EoL April 2024)\n" \
"\tUbuntu 18.04 LTS (bionic with EoL April 2028)\n" \
"\tUbuntu 19.04 (disco)\n" \
"\tDebian 8 (jessie) or later" >&2
위 스크립트가 지원하는 배포판들이다. 일단 스크립트를 무시하고, 아규먼트 파일을 만들고 생성해 본다.
$ gn args out/First
# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
pdf_is_standalone = true # non-embedded 빌드 설정is_debug = true # 디버깅pdf_enable_xfa = true # XFA 지원pdf_enable_v8 = true # 자바스크립트 v8 지원pdf_use_skia = false # skia 백엔드 제거pdf_use_skia_paths = false # skia 백엔드 제거is_component_build = false # 컴포넌트 빌드 제거 (must be false)clang_use_chrome_plugins = false # 크롬 플러그인 false.아규먼트 파일을 저장한다.
$ cd out/First
$ ls
args.gn build.ninja build.ninja.d obj toolchain.ninja
조금 전 생성한 args.gn 과 소스파일의 BUILD.gn 파일을 이용해서 build.ninja등의 파일을 생성해서 ninja 빌드를 할 수 있도록 한다.
아규먼트 파일이 이미 있다면, args 옵션 대신에 gen 옵션을 사용할 수 있다.
$ mkdir -p out/First
$ cp args.gn out/First
$ gn gen out/First
ninja 는 일종의 래퍼 스크립트다.
$ ninja pdfium
[3/2765] CXX obj/buildtools/third_party/libc++/libc++/debug.o
FAILED: obj/buildtools/third_party/libc++/libc++/debug.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/buildtools/third_party/libc++/libc++/debug.o.d -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__\(\(__visibility__\(\"default\"\)\)\) -DLIBCXX_BUILDING_LIBCXXABI -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"373424-64a362e7-2\" -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -DCR_LIBCXX_REVISION=361348 -DCR_SYSROOT_HASH=e7c53f04bd88d29d075bfd1f62b073aeb69cbe09 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -I../.. -Igen -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers -m64 -march=x86-64 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -ggnu-pubnames -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -fstrict-aliasing -fPIC -Werror -Wall -Wno-unused-variable -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-reorder-init-list -Wno-final-dtor-non-final-class -Wno-sizeof-array-div -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++14 -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_amd64-sysroot -fvisibility-inlines-hidden -fexceptions -frtti -c ../../buildtools/third_party/libc++/trunk/src/debug.cpp -o obj/buildtools/third_party/libc++/libc++/debug.o
../../third_party/llvm-build/Release+Asserts/bin/clang++: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/respiro/rpmbuild/SOURCES/PDFium/pdfium/third_party/llvm-build/Release+Asserts/bin/../lib/libstdc++.so.6)
[4/2765] CXX obj/buildtools/third_party/libc++/libc++/hash.o
third_party 의 clang++ 을 사용해서 빌드하고, 오류가 발생하는 것을 볼 수 있다.
toolchain.ninja 파일에 빌드에 사용하는 도구를 명시하고 있다.
third_party 의 폴더에는 llvm, clang 등의 도구가 더 들어 있다. 물론, CentOS 7 에서는 사용할 수 없다.
./clang: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/respiro/rpmbuild/SOURCES/PDFium/pdfium/third_party/llvm-build/Release+Asserts/bin/../lib/libstdc++.so.6)
생성한 ninja 파일에서 사용하는 clang 빌드 옵션이 CentOS 7 의 clang 3.9 버전보다 더 높은 사양을 요구한다.
CentOS 7 의 glibc 는 2.17 이다. CentOS 8 로 업그레이드해야한다. 그렇게 하기에는 시스템에서 옮겨야 할 것이 많으므로, 차라리 clang 과 llvm 을 먼저 업그레이드한다.
llvm 및 clang 업데이트 (불필요한 삽질)
CentOS 8, fedora29 또는 rhel8 의 llvm, clang, lld 의 소스 rpm 을 가져와서 다시 빌드한다.
SPEC 파일에서 python3 를 다음과 같이 수정한다. CentOS 7의 경우 python3 는 python34 또는 python36 이다.
BuildRequires: python%{python3_pkgversion}-sphinx
..
BuildRequires: python%{python3_pkgversion}-devel
make -O <== 에서 옵션 -O를 삭제한다.
$ rpmbuild -ba llvm.spec
또는 Fedora29 의 llvm-7.0.1-4 소스를 사용해도 된다.
fc29 의 llvm 은 ninja 로 빌드하기 때문에, 오히려 아래의 pdfium 을 빌드하기 위해 ninja 를 먼저 접해보는 것도 좋을 수 있다.
ninja 빌드 속도가 그렇게 빠르지는 않다.
$ time rpmbuild --rebuild llvm-7.0.1-3.el7.src.rpm
real 21m33.500s
user 205m20.212s
sys 26m7.622s
$ time rpmbuild --rebuild llvm-7.0.1-4.el7.src.rpm
real 22m35.076suser 222m45.459ssys 28m35.379sllvm 과 lld 를 빌드 후 업데이트 한 후에, clang 을 빌드하고 설치한다.
clang 의 경우 spec 파일에 다음을 추가한다.
내부의 python 코드는 python3 에서 동작하지만, file=sys.stderr
CentOS7 의 python 은 디폴트로 python2 이며 rpm 패키징도 대부분 python2 코드기반으로 충돌한다.
패키징시 아래를 추가해서 python byte compile이 실패해도 패키징 오류가 나지 않도록 한다.
%global _python_bytecompile_errors_terminate_build 0
%global _pkgdocdir /usr/share/doc/clang
...
# Fix compat
mkdir -p %{_datadir}/clang/
install -p -m644 tools/clang-format/clang-format.py %{buildroot}%{_datadir}/clang/
install -p -m644 tools/clang-format/clang-format-diff.py %{buildroot}%{_datadir}/clang/
...이제 toolchain.ninja 의 clang++ 의 경로를 바꾸거나, pdfium/third_party/llvm-build/Release+Asserts/bin/ 폴더의 실행파일들을 새로 빌드한 도구들로 변경해준다. 전자를 변경하면, 테스트 아규먼트 옵션 생성시 계속 수정해야 하기 때문에, third_party 의 clang 및 llvm 도구들의 경로를 수정한다.
$ cd ../../third_party/llvm-build/Release+Asserts/bin
$ ls
clang clang++ clang-cl ld.lld lld lld-link llvm-ar llvm-objcopy llvm-pdbutil llvm-symbolizer llvm-undname
$ rm -f llvm* lld clang
$ ln -s /usr/bin/llvm-ar .
$ ln -s /usr/bin/llvm-objcopy .
$ ln -s /usr/bin/llvm-pdbutil .
$ ln -s /usr/bin/llvm-symbolizer .
$ ln -s /usr/bin/llvm-undname .
$ ln -s /usr/bin/lld .
$ ln -s /usr/bin/clang .
다시 빌드해 본다.
$ cd ~/PDFium/out/First
$ ninja pdfium
...
error: unknown warning option '-Wno-implicit-int-float-conversion'; did you mean '-Wno-float-overflow-conversion'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-c99-designator'; did you mean '-Wno-gnu-designator'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-reorder-init-list' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-final-dtor-non-final-class'; did you mean '-Wno-abstract-final-class'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-sizeof-array-div'; did you mean '-Wno-sizeof-array-decay'? [-Werror,-Wunknown-warning-option]
...gcc 7.2 이상의 버전에서 사용하는 옵션들이 보인다.
- is_clang = false
처음에 만든 args.gn 아규먼트 옵션 중에 clang 을 사용하지 않도록 하는 옵션이 있다는 것을 알게 되었다.
is_clang = false
옵션을 추가하고 다시 빌드해 본다.
g++: error: unrecognized command line option ‘-std=gnu++14’
gnu++14 옵션은 gcc 4.9(5.0) 이상에서 지원하는 옵션이다. CentOS 7 의 기본 gcc 4.8.5 다.
내용 추가
PDFium is transitioning to C++14, but still supports C++11 compatibility for the duration of the transition period. Prefer to use only C++11 features, though technically C++14 is allowed in code that is only built when V8, XFA, or Skia is turned on.
일단. v8, xfa, skia 관련 옵션은 모두 끄고 테스트한다.
use_cxx11 = true
is_clang = false
is_cfi = false
c++11 을 사용하기 위해서는 is_cfi 를 끄고 사용해야 한다. 잘 안된다.
아래처럼 그냥 scl 툴을 설치해서 해결한다.
- CentOS 7 에서 gcc 7 / gcc 8 빌드 환경 구축하기 [feat. SCL 저장소]
# yum install centos-release-scl# yum install devtoolset-7-gcc-c++# yum install devtoolset-8-gcc-c++$ scl enable devtoolset-7 bash$ gcc --versiongcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)Copyright (C) 2017 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.gcc 8 개발 환경을 사용하려면,
$ scl -l
devtoolset-7
devtoolset-8
llvm-toolset-7
$ scl enable devtoolset-8 bash
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
다시 빌드해 본다.
../../build/linux/debian_sid_amd64-sysroot/usr/include/features.h:424:12: fatal error: sys/cdefs.h: 그런 파일이나 디렉터리가 없습니다
# include <sys/cdefs.h>
리눅스 헤더들도 데비안스러운 것들을 끌고 오고 있다.
- use_sysroot = false
헤메다가 아래 옵션을 발견했다. args.gn 에 다음 옵션을 추가한다.
use_sysroot = false
다시 빌드한다.
$ cd out/first
$ ninja pdfium
[1003/1003] STAMP obj/pdfium.stamp
다시 빌드한다.
$ ninja
[536/536] LINK ./zlib_bench
다시 빌드한다.
$ ninja
ninja: no work to do.
뭔가 컴파일을 하지만, 라이브러리가 생성되지 않는다.
뭔가 빠진 아규먼트들을 더 찾아서 이것저것 추가해 본다.
pdf_is_standalone = true # Set for a non-embedded build.
pdf_is_complete_lib=true
pdf_enable_xfa = false # XFA support enabled.
pdf_enable_v8 = false # Javascript support enabled.
pdf_use_skia = false # Avoid skia backend experiment.
pdf_use_skia_paths = false # Avoid other skia backend experiment.
pdf_bundle_freetype = true
clang_use_chrome_plugins = false
use_goma = false
use_custom_libcxx=false
use_sysroot = false
is_component_build = false
is_debug = true # Enable debugging features.
is_clang = false # Avoid dependency hell.
[respiro@localhost first]$ ninja pdfium
[1/1] Regenerating ninja files
[942/942] AR obj/libpdfium.a
드디서 obj 폴더아래에 libpdfium.a 를 만들었다.
3. 링크 테스트
간단한 컴파일 테스트를 해 본다.
pdf_hello.c
#include <stdio.h>
#include <fpdfview.h>
int main() {
FPDF_InitLibrary();
FPDF_DestroyLibrary();
printf("PDFium hello.\n");
return 0;
}
Makefile
PDFIUM= ../pdfium
INC_DIR= -I ${PDFIUM}/public
LIB_DIR= -L ${PDFIUM}/out/first/obj
PDF_LIBS= -lpdfium
STD_LIBS= -lpthread -lm -lc -lstdc++
default:
rm -f pdf_hello
gcc -o first first.c ${INC_DIR} ${LIB_DIR} ${PDF_LIBS} ${STD_LIBS}
테스트
[respiro@localhost test]$ make
rm -f pdf_hello
gcc -o pdf_hello pdf_hello.c -I ../pdfium/public -L ../pdfium/out/first/obj -lpdfium -lpthread -lm -lc -lstdc++
$ ./first
PDFium hello.
4. 시스템 라이브러리로 링크하기
소스를 살펴보면, third_party 폴더에 외부 라이브러리들이 있다.
third_party/BUILD.gn 파일을 보면 다음의 옵션을 사용해서 시스템의 라이브러리들을 사용할 수 있도록 되어 있다.
use_system_zlib = true
use_system_libpng = true
use_system_lcms2 = true
use_system_libjpeg = true
use_libjpeg_turbo = true
use_system_libopenjpeg2 = true
openjpeg 의 경우, 2.3 이상의 버전이 시스템에 설치된 경우가 아니라면, 임베드된 openjpeg 코드를 사용한다.
jpeg 의 경우, use_system_libjpeg과 use_libjpeg_turbo 를 모두 활성화해서 CentOS7 의 jpeg turbo 라이브러리를 링크하도록 한다.
임베드된 소스는 turbo_jpeg 이므로 시스템 라이브러리와 상관없이 use_libjpeg_turbo = true 로 항상 설정한다.
일단 시스템의 zlib 을 사용하도록 하고 다른 옵션은 막거나 제거해서 아규먼트를 수정해서 테스트 해본다.
앞에서 만든 테스트용 Makefile 을 실행해본다.
gcc -o pdf_hello pdf_hello.c -I ../pdfium/public -L ../pdfium/out/second/obj -lpdfium -lpthread -lm -lc -lstdc++
../pdfium/out/second/obj/libpdfium.a(flatemodule.o): In function `fxcodec::(anonymous namespace)::FlateCompress(unsigned char*, unsigned long*, unsigned char const*, unsigned int)':
/home/respiro/rpmbuild/SOURCES/PDFium/pdfium/out/second/../../core/fxcodec/flate/flatemodule.cpp:62: undefined reference to `compress'
../pdfium/out/second/obj/libpdfium.a(flatemodule.o): In function `fxcodec::(anonymous namespace)::FlateInit()':
/home/respiro/rpmbuild/SOURCES/PDFium/pdfium/out/second/../../core/fxcodec/flate/flatemodule.cpp:69: undefined reference to `inflateInit_'
../pdfium/out/second/obj/libpdfium.a(flatemodule.o): In function `fxcodec::(anonymous namespace)::FlateOutput(z_stream_s*, unsigned char*, unsigned int)':
/home/respiro/rpmbuild/SOURCES/PDFium/pdfium/out/second/../../core/fxcodec/flate/flatemodule.cpp:84: undefined reference to `inflate'
../pdfium/out/second/obj/libpdfium.a(flatemodule.o): In function `fxcodec::(anonymous namespace)::FlateEnd(z_stream_s*)':
/home/respiro/rpmbuild/SOURCES/PDFium/pdfium/out/second/../../core/fxcodec/flate/flatemodule.cpp:101: undefined reference to `inflateEnd'
collect2: error: ld returned 1 exit status
zlib 링크에 문제가 있음을 알 수 있다.
Makefile 에 시스템의 libz 를 링크하도록 추가한다.
STD_LIBS= -lpthread -lm -lc -lstdc++ -lz
다시 빌드하면 테스트 파일이 정상 동작함을 알 수 있다.
이런 식으로 앞에서 주석으로 처리한 다른 시스템 라이브러리들을 링크할 수 있다.
CentOS 7 에서는 다음의 패키지를 설치해서 사용할 수 있다.
# yum install libpng-devel zlib-devel openjpeg2-devel lcms2-devel libjpeg-turbo-devel
STD_LIBS= -lpthread -lm -lc -lstdc++ -lz -ljpeg -lopenjp2 -llcms2 -lpng
다음 삽질은 공유 라이브러리와 gdal 라이브러리 빌드를 위한 삽질이 된다.
추가 삽질뒤에 찾은 옵션이다. tiff 와 icu 라이브러리를 시스템 라이브러리로 사용하는 옵션은 아직 찾지 못했다.
use_system_freetype = true
pdf_bundle_freetype = false
freetype 을 시스템 라이브러리로 사용하기 위해서는 third_party/freetype 을 사용하지 않도록 pdf_bundle_freetype 을 사용하지 않도록 해야 한다.
PDFIUM= ../pdfium
INC_DIR= -I ${PDFIUM}/public
LIB_DIR= -L ${PDFIUM}/out/first/obj
PDF_LIBS= -lpdfium
STD_LIBS= -lpthread -lm -lc -lstdc++-lz -ljpeg -lopenjp2 -llcms2 -lpng -lfreetype
default:
rm -f pdf_hello
gcc -o first first.c ${INC_DIR} ${LIB_DIR} ${PDF_LIBS} ${STD_LIBS}
5. 아규먼트 목록 출력하기
앞서 사용한 아규먼트들의 목록을 보려면, 다음과 같이 한다.
$ cd pdfium
$ gn args out/first --list
action_pool_depth
Current value (from the default) = -1
From //build/toolchain/BUILD.gn:10
Pool for non goma tasks.
android_full_debug
Current value (from the default) = false
From //build/config/compiler/BUILD.gn:53
Normally, Android builds are lightly optimized, even for debug builds, to
keep binary size down. Setting this flag to true disables such optimization
archive_seed_corpus
Current value (from the default) = true
From //build/config/sanitizers/sanitizers.gni:117
When true, seed corpora archives are built.
asan_globals
Current value (from the default) = true
From //build/config/sanitizers/sanitizers.gni:166
Detect overflow/underflow for global objects.
Mac: http://crbug.com/352073
asan_use_blacklist
Current value (from the default) = true
From //build/config/sanitizers/sanitizers.gni:109
Use blacklists from tools/memory/asan when compiling with asan.
auto_profile_path
Current value (from the default) = ""
From //build/config/compiler/BUILD.gn:89
AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
optimization that GCC supports. It used by ChromeOS in their official
builds. To use it, set auto_profile_path to the path to a file containing
the needed gcov profiling data.
binutils_path
Current value (from the default) = "../../third_party/binutils/Linux_x64/Release/bin"
From //build/config/compiler/BUILD.gn:62
cast_is_debug
Current value (from the default) = false
From //build/config/chromecast_build.gni:16
If true, IS_CAST_DEBUG_BUILD() will evaluate to 1 in version.h. Otherwise,
it will evaluate to 0. Overriding this when is_debug=false is useful for
doing engineering builds.
cc_wrapperCurrent value (from the default) = ""From //build/toolchain/cc_wrapper.gni:36Set to "ccache", "icecc" or "distcc". Probably doesn't work on windows.chrome_pgo_phaseCurrent value (from the default) = 0From //build/config/compiler/pgo/pgo.gni:13Specify the current PGO phase.Here's the different values that can be used:0 : Means that PGO is turned off.1 : Used during the PGI (instrumentation) phase.2 : Used during the PGO (optimization) phase.TODO(sebmarchand): Add support for the PGU (update) phase.chromecast_brandingCurrent value (from the default) = "public"From //build/config/chromecast_build.gni:20chromecast_branding is used to include or exclude Google-branded components.Set it to "public" for a Chromium build.chromeos_afdo_platformCurrent value (from the default) = "silvermont"From //build/config/compiler/BUILD.gn:111This configuration is used to select a default profile in Chrome OS based onthe microarchitectures we are using. This is only used ifclang_use_default_sample_profile is true and clang_sample_profile_path isempty.clang_base_pathCurrent value (from the default) = "//third_party/llvm-build/Release+Asserts"From //build/config/clang/clang.gni:14clang_emit_debug_info_for_profilingCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:114Emit debug information for profiling wile building with clang.clang_sample_profile_pathCurrent value (from the default) = ""From //build/config/compiler/BUILD.gn:96Path to an AFDO profile to use while building with clang, if any. Emptyimplies none.clang_use_chrome_pluginsCurrent value = falseFrom //out/first/args.gn:12Overridden from the default = falseFrom //build/config/clang/clang.gni:12Indicates if the build should use the Chrome-specific plugins for enforcingcoding guidelines, etc. Only used when compiling with Clang.clang_use_default_sample_profileCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:104Some configurations have default sample profiles. If this is true andclang_sample_profile_path is empty, we'll fall back to the default.We currently only have default profiles for Chromium in-tree, so we disablethis by default for all downstream projects, since these profiles are likelynonsensical for said projects.compiler_timingCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:117Turn this on to have the compiler output extra timing information.concurrent_linksCurrent value (from the default) = -1From //build/toolchain/concurrent_links.gni:19Limit the number of concurrent links; we often want to run fewerlinks at once than we do compiles, because linking is memory-intensive.The default to use varies by platform and by the amount of memoryavailable, so we call out to a script to get the right value.coverage_instrumentation_input_fileCurrent value (from the default) = ""From //build/config/coverage/coverage.gni:29The path to the coverage instrumentation input file should be a source rootabsolute path (e.g. //out/Release/coverage_instrumentation_input.txt), andthe file consists of multiple lines where each line represents a path to asource file, and the paths must be relative to the root build directory.e.g. ../../base/task/post_task.cc for build directory 'out/Release'.NOTE that this arg will be non-op if use_clang_coverage is false.current_cpuCurrent value (from the default) = ""(Internally set; try `gn help current_cpu`.)current_osCurrent value (from the default) = ""(Internally set; try `gn help current_os`.)custom_toolchainCurrent value (from the default) = ""From //build/config/BUILDCONFIG.gn:144Allows the path to a custom target toolchain to be injected as a singleargument, and set as the default toolchain.dcheck_always_onCurrent value (from the default) = falseFrom //build/config/dcheck_always_on.gni:14Set to true to enable dcheck in Release builds.dcheck_is_configurableCurrent value (from the default) = falseFrom //build/config/dcheck_always_on.gni:9Enables DCHECKs to be built-in, but to default to being non-fatal/log-only.DCHECKS can then be set as fatal/non-fatal via the DCheckIsFatal feature.See crbug.com/596231 for details on how this is used.disable_libfuzzerCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:92Helper variable for testing builds with disabled libfuzzer.Not for client use.enable_callgrindCurrent value (from the default) = falseFrom //pdfium.gni:57Enable callgrind for performance profilingenable_cast_rendererCurrent value (from the default) = falseFrom //build/config/chromecast_build.gni:46True to enable the cast renderer. It is enabled by default for non-androidbuilds.enable_full_stack_frames_for_profilingCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:70Compile in such a way as to make it possible for the profiler to unwind fullstack frames. Setting this flag has a large effect on the performance of thegenerated code than just setting profiling, but gives the profiler moreinformation to analyze.Requires profiling to be set to true.enable_iterator_debuggingCurrent value (from the default) = falseFrom //build/config/BUILD.gn:40When set (the default) enables C++ iterator debugging in debug builds.Iterator debugging is always off in release builds (technically, this flagaffects the "debug" config, which is always available but applied bydefault only in debug builds).Iterator debugging is generally useful for catching bugs. But it canintroduce extra locking to check the state of an iterator against the stateof the current object. For iterator- and thread-heavy code, this cansignificantly slow execution - two orders of magnitude slowdown has beenseen (crbug.com/903553) and iterator debugging also slows builds by makinggeneration of snapshot_blob.bin take ~40-60 s longer. Therefore thisdefaults to off.enable_precompiled_headersCurrent value (from the default) = trueFrom //build/config/pch.gni:11Precompiled header file support is by default available,but for distributed build system uses (like goma) or whendoing official builds.enable_profilingCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:48Compile in such a way as to enable profiling of the generated code. Forexample, don't omit the frame pointer and leave in symbols.enable_resource_whitelist_generationCurrent value (from the default) = falseFrom //build/toolchain/gcc_toolchain.gni:27fatal_linker_warningsCurrent value (from the default) = trueFrom //build/config/compiler/BUILD.gn:78Enable fatal linker warnings. Building Chromium with certain versionsof binutils can cause linker warning.forbid_non_component_debug_buildsCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:89Whether an error should be raised on attempts to make debug builds withis_component_build=false. Very large debug symbols can have unwanted sideeffects so this is enforced by default for chromium.force_local_build_idCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:139By default only the binaries in official builds get build IDs.full_wpo_on_officialCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:183gcc_target_rpathCurrent value (from the default) = ""From //build/config/gcc/BUILD.gn:19When non empty, overrides the target rpath value. This allows a user tomake a Chromium build where binaries and shared libraries are meant to beinstalled into separate directories, like /usr/bin/chromium and/usr/lib/chromium for instance. It is useful when a build system thatgenerates a whole target root filesystem (like Yocto) is used on top of gn,especially when cross-compiling.Note: this gn arg is similar to gyp target_rpath generator flag.generate_linker_mapCurrent value (from the default) = falseFrom //build/toolchain/toolchain.gni:26Used for binary size analysis.generate_order_filesCurrent value (from the default) = falseFrom //build/config/chrome_build.gni:17Turn this on to generate order files. Seehttps://chromium.googlesource.com/chromium/src/+/master/docs/win_order_files.mdgold_pathCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:74When we are going to use gold we need to find it.This is initialized below, after use_gold might have been overridden.goma_dirCurrent value (from the default) = "/home/respiro/goma"From //build/toolchain/goma.gni:26Absolute directory containing the gomacc binary.has_gomacc_pathCurrent value (from the default) = falseFrom //build/toolchain/goma.gni:14This flag is for ChromeOS compiler wrapper.By passing gomacc path via GOMACC_PATH environment variable, ChromeOS'compiler wrapper invokes gomacc inside it.host_byteorderCurrent value (from the default) = "undefined"From //build/config/host_byteorder.gni:9host_cpuCurrent value (from the default) = "x64"(Internally set; try `gn help host_cpu`.)host_osCurrent value (from the default) = "linux"(Internally set; try `gn help host_os`.)host_pkg_configCurrent value (from the default) = ""From //build/config/linux/pkg_config.gni:36A optional pkg-config wrapper to use for tools built on the host.host_toolchainCurrent value (from the default) = ""From //build/config/BUILDCONFIG.gn:148This should not normally be set as a build argument. It's here so thatevery toolchain can pass through the "global" value via toolchain_args().hwasan_platformCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:21Specify whether to target the platform's copy of the HWASan runtime,rather than one bundled with the application.icu_use_data_fileCurrent value (from the default) = trueFrom //third_party/icu/config.gni:8Tells icu to load an external data file rather than rely on the icudatabeing linked directly into the binary.ignore_elf32_limitationsCurrent value (from the default) = falseFrom //build_overrides/build.gni:42Android 32-bit non-component, non-clang builds cannot have symbol_level=2due to 4GiB file size limit, see https://crbug.com/648948.Set this flag to true to skip the assertion.init_stack_varsCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:145Initialize all local variables with a pattern. This flag will fill uninitializedfloating-point types (and 32-bit pointers) with 0xFF and the rest with 0xAA.This allows to make behavior of uninitialized memory bugs consistent, easier torecognize when debugging and often just to crash immediately.ios_deployment_targetCurrent value (from the default) = "12.0"From //build/config/ios/ios_sdk_overrides.gni:10Version of iOS that we're targeting.is_asanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:12Compile for Address Sanitizer to find memory bugs.is_cast_audio_onlyCurrent value (from the default) = falseFrom //build/config/chromecast_build.gni:23Set this true for an audio-only Chromecast build.is_cast_desktop_buildCurrent value (from the default) = falseFrom //build/config/chromecast_build.gni:39True if Chromecast build is targeted for linux desktop. This type of buildis useful for testing and development, but currently supports only a subsetof Cast functionality. Though this defaults to true for x86 Linux devices,this should be overriden manually for an embedded x86 build.TODO(slan): Remove instances of this when x86 is a fully supported platform.is_cfiCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:58Compile with Control Flow Integrity to protect virtual calls and casts.See http://clang.llvm.org/docs/ControlFlowIntegrity.htmlTODO(pcc): Remove this flag if/when CFI is enabled in all official builds.is_chrome_brandedCurrent value (from the default) = falseFrom //build/config/chrome_build.gni:9Select the desired branding flavor. False means normal Chromium branding,true means official Google Chrome branding (requires extra Google-internalresources).is_chromecastCurrent value (from the default) = falseFrom //build/config/chromecast_build.gni:11Set this true for a Chromecast build. Chromecast builds are supported onLinux and Android.is_clangCurrent value = falseFrom //out/first/args.gn:20Overridden from the default = trueFrom //build/config/BUILDCONFIG.gn:137Set to true when compiling with the Clang compiler.is_component_buildCurrent value = falseFrom //out/first/args.gn:18Overridden from the default = falseFrom //build/config/BUILDCONFIG.gn:165Component build. Setting to true compiles targets declared as "components"as shared libraries loaded dynamically. This speeds up development time.When false, components will be linked statically.For more information seehttps://chromium.googlesource.com/chromium/src/+/master/docs/component_build.mdis_debugCurrent value = falseFrom //out/first/args.gn:19Overridden from the default = trueFrom //build/config/BUILDCONFIG.gn:155Debug build. Enabling official builds automatically sets is_debug to false.is_desktop_linuxCurrent value (from the default) = trueFrom //build/config/BUILDCONFIG.gn:134Whether we're a traditional desktop unix.is_hwasanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:17Compile for Hardware-Assisted Address Sanitizer to find memory bugs(android/arm64 only).See http://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.htmlis_lsanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:24Compile for Leak Sanitizer to find leaks.is_msanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:27Compile for Memory Sanitizer to find uninitialized reads.is_multi_dll_chromeCurrent value (from the default) = falseFrom //build/config/chrome_build.gni:13Break chrome.dll into multple pieces based on process type. Only availableon Windows.is_official_buildCurrent value (from the default) = falseFrom //build/config/BUILDCONFIG.gn:131Set to enable the official build level of optimization. This has nothingto do with branding, but enables an additional level of optimization aboverelease (!is_debug). This might be better expressed as a tri-state(debug, release, official) but for historical reasons there are twoseparate flags.is_tsanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:30Compile for Thread Sanitizer to find threading bugs.is_ubsanCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:34Compile for Undefined Behaviour Sanitizer to find various types ofundefined behaviour (excludes vptr checks).is_ubsan_no_recoverCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:37Halt the program if a problem is detected.is_ubsan_nullCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:40Compile for Undefined Behaviour Sanitizer's null pointer checks.is_ubsan_securityCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:88Enables core ubsan security features. Will later be removed once it matchesis_ubsan.is_ubsan_vptrCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:43Compile for Undefined Behaviour Sanitizer's vptr checks.is_win_fastlinkCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:73Tell VS to create a PDB that references information in .obj files ratherthan copying it all. This should improve linker performance. mspdbcmf.execan be used to convert a fastlink pdb to a normal one.ldso_pathCurrent value (from the default) = ""From //build/config/gcc/BUILD.gn:20libcxx_is_sharedCurrent value (from the default) = falseFrom //build/config/c++/c++.gni:44WARNING: Setting this to a non-default value is highly discouraged.If true, libc++ will be built as a shared library; otherwise libc++ will belinked statically. Setting this to something other than the default isunsupported and can be broken by libc++ rolls. Note that if this is set totrue, you must also set libcxx_abi_unstable=false, which is bad forperformance and memory use.libcxx_natvis_includeCurrent value (from the default) = trueFrom //build/config/c++/c++.gni:30Builds libcxx Natvis into the symbols for type visualization.Set to false to workaround http://crbug.com/966676 andhttp://crbug.com/966687.linux_use_bundled_binutilsCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:60llvm_force_head_revisionCurrent value (from the default) = falseFrom //build/toolchain/toolchain.gni:18If this is set to true, or if LLVM_FORCE_HEAD_REVISION is set to 1in the environment, we use the revision in the llvm repo to determinethe CLANG_REVISION to use, instead of the version hard-coded into//tools/clang/scripts/update.py. This should only be used inconjunction with setting LLVM_FORCE_HEAD_REVISION in theenvironment when `gclient runhooks` is run as well.mac_sdk_minCurrent value (from the default) = "10.14"From //build/config/mac/mac_sdk_overrides.gni:12max_jobs_per_linkCurrent value (from the default) = 8From //build/config/compiler/compiler.gni:68Limit the number of jobs (threads/processes) the linker is allowedto use (for linkers that support this).msan_track_originsCurrent value (from the default) = 2From //build/config/sanitizers/sanitizers.gni:48Track where uninitialized memory originates from. From fastest to slowest:0 - no tracking, 1 - track only the initial allocation site, 2 - track thechain of stores leading from allocation site to use site.optimize_for_fuzzingCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:96Optimize for coverage guided fuzzing (balance between speed and number ofbranches). Can be also used to remove non-determinism and other issues.pdf_bundle_freetypeCurrent value = trueFrom //out/first/args.gn:10Overridden from the default = trueFrom //pdfium.gni:16Build PDFium either:1) When set to true, with a bundled FreeType, built from FreeType sourcecode in //third_party/freetype and PDFium's FreeType configs inthird_party/freetype/include.2) When set to false, use whatever FreeType target is defined in//build/config/freetype.pdf_enable_click_loggingCurrent value (from the default) = falseFrom //pdfium.gni:19Generate logging messages for click events that reach PDFiumpdf_enable_v8Current value = falseFrom //out/first/args.gn:6Overridden from the default = trueFrom //pdfium.gni:22Build PDFium either with or without v8 support.pdf_enable_xfaCurrent value = falseFrom //out/first/args.gn:5Overridden from the default = falseFrom //pdfium.gni:25Build PDFium either with or without XFA Forms support.pdf_enable_xfa_bmpCurrent value (from the default) = trueFrom //pdfium.gni:28If XFA, also support bmp codec. Ignored if not XFA.pdf_enable_xfa_gifCurrent value (from the default) = trueFrom //pdfium.gni:31If XFA, also support gif codec. Ignored if not XFA.pdf_enable_xfa_pngCurrent value (from the default) = trueFrom //pdfium.gni:34If XFA, also support png codec. Ignored if not XFA.pdf_enable_xfa_tiffCurrent value (from the default) = trueFrom //pdfium.gni:37If XFA, also support png codec. Ignored if not XFA.pdf_is_complete_libCurrent value = trueFrom //out/first/args.gn:4Overridden from the default = falseFrom //pdfium.gni:54Build a complete static librarypdf_is_standaloneCurrent value = trueFrom //out/first/args.gn:3Overridden from the default = falseFrom //pdfium.gni:51Build PDFium standalonepdf_use_skiaCurrent value = falseFrom //out/first/args.gn:7Overridden from the default = falseFrom //pdfium.gni:41Build PDFium against Skia (experimental) rather than AGG. Use Skia to draweverything.pdf_use_skia_pathsCurrent value = falseFrom //out/first/args.gn:8Overridden from the default = falseFrom //pdfium.gni:45Build PDFium against Skia (experimental) rather than AGG. Use Skia to drawpaths.pdf_use_win32_gdiCurrent value (from the default) = falseFrom //pdfium.gni:48Build PDFium with or without experimental win32 GDI APIs.pgo_data_pathCurrent value (from the default) = ""From //build/config/compiler/pgo/pgo.gni:16When using chrome_pgo_phase = 2, read profile data from this path.pkg_configCurrent value (from the default) = ""From //build/config/linux/pkg_config.gni:33A pkg-config wrapper to call instead of trying to find and call the rightpkg-config directly. Wrappers like this are common in cross-compilationenvironments.Leaving it blank defaults to searching PATH for 'pkg-config' and relying onthe sysroot mechanism to find the right .pc files.proprietary_codecsCurrent value (from the default) = falseFrom //build/config/features.gni:26Enables proprietary codecs and demuxers; e.g. H264, AAC, MP3, and MP4.We always build Google Chrome and Chromecast with proprietary codecs.Note: this flag is used by WebRTC which is DEPSed into Chrome. Moving itout of //build will require using the build_overrides directory.ro_segment_workaround_for_valgrindCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:122Set to true to pass --no-rosegment to lld. This is a workaroundfor a KI issue in Valgrind,https://bugs.kde.org/show_bug.cgi?id=384727sample_profile_is_accurateCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:114Whether we should consider the profile we're using to be accurate. Accurateprofiles have the benefit of (potentially substantial) binary sizereductions, by instructing the compiler to optimize cold and uncoveredfunctions heavily for size. This often comes at the cost of performance.sanitizer_coverage_flagsCurrent value (from the default) = ""From //build/config/sanitizers/sanitizers.gni:106Value for -fsanitize-coverage flag. Setting this causesuse_sanitizer_coverage to be enabled.This flag is not used for libFuzzer (use_libfuzzer=true). Instead, we use:-fsanitize=fuzzer-no-linkDefault value when unset and use_fuzzing_engine=true:trace-pc-guardDefault value when unset and use_sanitizer_coverage=true:trace-pc-guard,indirect-callsstrip_absolute_paths_from_debug_symbolsCurrent value (from the default) = trueFrom //build/config/compiler/compiler.gni:213strip_debug_infoCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:44Android-only: Strip the debug info of libraries within lib.unstripped toreduce size. As long as symbol_level > 0, this will still allow stacks to besymbolized.symbol_levelCurrent value (from the default) = -1From //build/config/compiler/compiler.gni:39How many symbols to include in the build. This affects the performance ofthe build since the symbols are large and dealing with them is slow.2 means regular build with symbols.1 means minimal symbols, usually enough for backtraces only. Symbols withinternal linkage (static functions or those in anonymous namespaces) may notappear when using this level.0 means no symbols.-1 means auto-set according to debug/release and platform.system_libdirCurrent value (from the default) = "lib"From //build/config/linux/pkg_config.gni:47CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfigand one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfigdepending on whether the systemroot is for a 32 or 64 bit architecture.When build under GYP, CrOS board builds specify the 'system_libdir' variableas part of the GYP_DEFINES provided by the CrOS emerge build or simplechrome build scheme. This variable permits controlling this for GN buildsin similar fashion by setting the `system_libdir` variable in the build'sargs.gn file to 'lib' or 'lib64' as appropriate for the target architecture.target_cpuCurrent value (from the default) = ""(Internally set; try `gn help target_cpu`.)target_osCurrent value (from the default) = ""(Internally set; try `gn help target_os`.)target_rpathCurrent value (from the default) = ""From //build/config/chromecast_build.gni:27If non empty, rpath of executables is set to this.If empty, default value is used.target_sysrootCurrent value (from the default) = ""From //build/config/sysroot.gni:13The absolute path of the sysroot that is applied when compiling usingthe target toolchain.target_sysroot_dirCurrent value (from the default) = "//build/linux"From //build/config/sysroot.gni:16The absolute path to directory containing linux sysroot imagesthin_lto_enable_optimizationsCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:136toolkit_viewsCurrent value (from the default) = trueFrom //build/config/ui.gni:35True means the UI is built using the "views" framework.treat_warnings_as_errorsCurrent value (from the default) = trueFrom //build/config/compiler/BUILD.gn:49Default to warnings as errors for default workflow, where we catchwarnings with known toolchains. Allow overriding this e.g. for Chromiumbuilds on Linux that could use a different version of the compiler.With GCC, warnings in no-Chromium code are always not treated as errors.use_aflCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:84Compile for fuzzing with AFL.use_auraCurrent value (from the default) = trueFrom //build/config/ui.gni:30Indicates if Aura is enabled. Aura is a low-level windowing library, sortof a replacement for GDI or GTK.use_cfi_castCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:64Enable checks for bad casts: derived cast and unrelated cast.TODO(krasin): remove this, when we're ready to add these checks by default.https://crbug.com/626794use_cfi_diagCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:73Print detailed diagnostics when Control Flow Integrity detects a violation.use_cfi_icallCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:69Enable checks for indirect function calls via a function pointer.TODO(pcc): remove this when we're ready to add these checks by default.https://crbug.com/701919use_cfi_recoverCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:77Let Control Flow Integrity continue execution instead of crashing whenprinting diagnostics (use_cfi_diag = true).use_clang_coverageCurrent value (from the default) = falseFrom //build/config/coverage/coverage.gni:17Enable Clang's Source-based Code Coverage.use_custom_libcxxCurrent value = falseFrom //out/first/args.gn:15Overridden from the default = trueFrom //build/config/c++/c++.gni:14use_custom_libcxx_for_hostCurrent value (from the default) = falseFrom //build/config/c++/c++.gni:25Use libc++ instead of stdlibc++ when using the host_cpu toolchain, even ifuse_custom_libcxx is false. This is useful for cross-compiles where a customtoolchain for the target_cpu has been set as the default toolchain, butuse_custom_libcxx should still be true when building for the host. Theexpected usage is to set use_custom_libcxx=false anduse_custom_libcxx_for_host=true in the passed in buildargs.use_cxx11Current value (from the default) = falseFrom //build/config/compiler/BUILD.gn:92Allow projects that wish to stay on C++11 to override Chromium's default.use_cxx11_on_androidCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:150C++11 may not be an option if Android test infrastructure is used.use_dbusCurrent value (from the default) = trueFrom //build/config/features.gni:31use_debug_fissionCurrent value (from the default) = "default"From //build/config/compiler/compiler.gni:60use_debug_fission: whether to use split DWARF debug infofiles. This can reduce link time significantly, but is incompatiblewith some utilities such as icecc and ccache. Requires gold andgcc >= 4.8 or clang.http://gcc.gnu.org/wiki/DebugFissionThis is a placeholder value indicating that the code below should setthe default. This is necessary to delay the evaluation of the defaultvalue expression until after its input values such as use_gold havebeen set, e.g. by a toolchain_args() block.use_ghashCurrent value (from the default) = trueFrom //build/config/compiler/BUILD.gn:126Turn this on to use ghash feature of lld for faster debug link on Windows.http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.htmluse_gioCurrent value (from the default) = trueFrom //build/config/features.gni:33use_glibCurrent value (from the default) = trueFrom //build/config/ui.gni:39Whether we should use glib, a low level C utility library.use_goldCurrent value (from the default) = trueFrom //build/config/compiler/compiler.gni:195use_gomaCurrent value = falseFrom //out/first/args.gn:14Overridden from the default = falseFrom //build/toolchain/goma.gni:9Set to true to enable distributed compilation using Goma.use_icfCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:166Set to true to use icf, Identical Code Folding.icf=all is broken in older golds, seehttps://sourceware.org/bugzilla/show_bug.cgi?id=17704See also https://crbug.com/663886`linux_use_bundled_binutils` is to avoid breaking Linux distros which maystill have a buggy gold.chromeos binutils has been patched with the fix, so always use icf there.The bug only affects x86 and x64, so we can still use ICF when targetingother architectures.lld doesn't have the bug.use_incremental_wpoCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:77Whether or not we should turn on incremental WPO. Only affects the VSWindows build.use_jacoco_coverageCurrent value (from the default) = falseFrom //build/config/coverage/coverage.gni:20Enables JaCoCo Java code coverage.use_libfuzzerCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:81Compile for fuzzing with LLVM LibFuzzer.See http://www.chromium.org/developers/testing/libfuzzeruse_libjpeg_turboCurrent value = trueFrom //out/first/args.gn:26Overridden from the default = trueFrom //third_party/BUILD.gn:327Uses libjpeg_turbo as the jpeg implementation. Has no effect ifuse_system_libjpeg is set.use_lldCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:189Set to true to use lld, the LLVM linker.use_locally_built_instrumented_librariesCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:52Use dynamic libraries instrumented by one of the sanitizers instead of thestandard system libraries. Set this flag to build the libraries from source.use_ozoneCurrent value (from the default) = falseFrom //build/config/ui.gni:26Indicates if Ozone is enabled. Ozone is a low-level library layer for Linuxthat does not require X11. Enabling this feature disables use of glib, x11,Pango, and Cairo.use_rttiCurrent value (from the default) = falseFrom //build/config/compiler/BUILD.gn:83Build with C++ RTTI enabled. Chromium builds without RTTI by default,but some sanitizers are known to require it, like CFI diagnosticsand UBsan variants.use_sanitizer_configs_without_instrumentationCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:114When enabled, only relevant sanitizer defines are set, but compilationhappens with no extra flags. This is useful when in component buildenabling sanitizers only in some of the components.use_sanitizer_coverageCurrent value (from the default) = falseFrom //build/config/sanitizers/sanitizers.gni:160use_sysrootCurrent value = falseFrom //out/first/args.gn:16Overridden from the default = trueFrom //build/config/sysroot.gni:18use_system_freetypeCurrent value (from the default) = falseFrom //build/config/freetype/freetype.gni:13Blink needs a recent and properly build-configured FreeType version tosupport OpenType variations, color emoji and avoid security bugs. By defaultwe ship and link such a version as part of Chrome. For distributions thatprefer to keep linking to the version the system, FreeType must be newerthan version 2.7.1 and have color bitmap support compiled in. WARNING:System FreeType configurations other than as described WILL INTRODUCE TEXTRENDERING AND SECURITY REGRESSIONS.use_system_lcms2Current value = trueFrom //out/first/args.gn:24Overridden from the default = falseFrom //pdfium.gni:63Don't build against bundled lcms2.use_system_libjpegCurrent value = falseFrom //out/first/args.gn:25Overridden from the default = falseFrom //third_party/BUILD.gn:323Uses system libjpeg. If true, overrides use_libjpeg_turbo.use_system_libopenjpeg2Current value = trueFrom //out/first/args.gn:27Overridden from the default = falseFrom //pdfium.gni:66Don't build against bundled libopenjpeg2.use_system_libpngCurrent value = trueFrom //out/first/args.gn:23Overridden from the default = falseFrom //pdfium.gni:69Don't build against bundled libpng.use_system_xcodeCurrent value (from the default) = ""From //build_overrides/build.gni:49Use the system install of Xcode for tools like ibtool, libtool, etc.This does not affect the compiler. When this variable is false, targets willinstead use a hermetic install of Xcode. [The hermetic install can beobtained with gclient sync after setting the environment variableFORCE_MAC_TOOLCHAIN].use_system_zlibCurrent value = trueFrom //out/first/args.gn:22Overridden from the default = falseFrom //pdfium.gni:60Don't build against bundled zlib.use_thin_ltoCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:64Enables support for ThinLTO, which links 3x-10x faster than full LTO. Seealso http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.htmluse_udevCurrent value (from the default) = trueFrom //build/config/features.gni:29libudev usage. This currently only affects the content layer.use_xcode_clangCurrent value (from the default) = falseFrom //build/toolchain/toolchain.gni:23Compile with Xcode version of clang instead of hermetic version shippedwith the build. Used to be used iOS for official builds, but is now off bydefault for all configurations.using_mismatched_sample_profileCurrent value (from the default) = falseFrom //build/config/compiler/compiler.gni:84Whether we're using a sample profile collected on an architecture differentthan the one we're compiling for.It's currently not possible to collect AFDO profiles on anything butx86{,_64}.v8_current_cpuCurrent value (from the default) = "x64"From //build/config/v8_target_cpu.gni:60This argument is declared here so that it can be overridden in toolchains.It should never be explicitly set by the user.v8_target_cpuCurrent value (from the default) = ""From //build/config/v8_target_cpu.gni:33This arg is used when we want to tell the JIT-generating v8 codethat we want to have it generate for an architecture that is differentthan the architecture that v8 will actually run on; we then run thecode under an emulator. For example, we might run v8 on x86, butgenerate arm code and run that under emulation.This arg is defined here rather than in the v8 project because we wantsome of the common architecture-specific args (like arm_float_abi ormips_arch_variant) to be set to their defaults either if the current_cpuapplies *or* if the v8_current_cpu applies.As described below, you can also specify the v8_target_cpu to useindirectly by specifying a `custom_toolchain` that contains v8_$cpu in thename after the normal toolchain.For example, `gn gen --args="custom_toolchain=...:clang_x64_v8_arm64"`is equivalent to setting --args=`v8_target_cpu="arm64"`. Setting`custom_toolchain` is more verbose but makes the toolchain that is(effectively) being used explicit.v8_target_cpu can only be used to target one architecture in a build,so if you wish to build multiple copies of v8 that are targetingdifferent architectures, you will need to do something morecomplicated involving multiple toolchains along the lines ofcustom_toolchain, above.x64_archCurrent value (from the default) = ""From //build/config/x64.gni:16The micro architecture of x64 cpu. This will be a string like "haswell" or"skylake". An empty string means to use the default architecture which is"x86-64".CPU options for "x86-64" in GCC can be found athttps://gcc.gnu.org/onlinedocs/gcc/x86-Options.htmlCPU options for "x86-64" in llvm can be found athttps://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/X86TargetParser.def6. 전체 빌드하기
out/first/build.ninja 파일을 보면 다음의 빌드 옵션이 있다는 것을 알 수 있다.
build freetype_common: phony obj/freetype_common.stamp
build fuzzers: phony obj/fuzzers.stamp
build pdfium: phony obj/libpdfium.a
build pdfium_all: phony obj/pdfium_all.stamp
build pdfium_embeddertest_deps: phony obj/pdfium_embeddertest_deps.stamp
build pdfium_public_headers: phony obj/pdfium_public_headers.stamp
build pdfium_public_headers_impl: phony obj/pdfium_public_headers_impl.stamp
build pdfium_unittest_deps: phony obj/pdfium_unittest_deps.stamp
build samples: phony obj/samples.stamp
build constants: phony obj/constants/constants.stamp
build fpdfsdk: phony obj/fpdfsdk/fpdfsdk.stamp
build fxjs: phony obj/fxjs/fxjs.stamp
build third_party: phony obj/third_party/third_party.stamp
build cmaps: phony obj/core/fpdfapi/cmaps/cmaps.stamp
...
ninja pdfium 은 pdfium 라이브러리만 빌드한다. unit test 를 포함한 전체 빌드는 다음과 같이 한다.
$ cd out/first
$ ninja pdfium_all
FAILED: obj/testing/test_support/file_util.o
...../../testing/utils/file_util.cpp: In member function ‘int FileAccessForTesting::GetBlockImpl(long unsigned int, unsigned char*, long unsigned int)’:
../../testing/utils/file_util.cpp:56:3: error: ‘memcpy’ was not declared in this scope
memcpy(pBuf, file_contents_.get() + pos, size);
^~~~~~
../../testing/utils/file_util.cpp:56:3: note: ‘memcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
../../testing/utils/file_util.cpp:10:1:
+#include <cstring>
../../testing/utils/file_util.cpp:56:3:
memcpy(pBuf, file_contents_.get() + pos, size);
^~~~~~
[142/222] CXX obj/fpdfsdk/embeddertests/fpdf_edit_embeddertest.o
ninja: build stopped: subcommand failed.
../../testing/utils/file_util.cpp 파일에 <cstring> 헤더를 추가해 준다.
빌드하면, pdfium_embeddertests 및 pdfium_test, pdfium_unittests 등의 파일이 생성된다.
테스트를 실행한다.
$ ./pdfium_embeddertests
...
[ PASSED ] 449 tests.
[ FAILED ] 31 tests, listed below:
[ FAILED ] CPDFSecurityHandlerEmbedderTest.PasswordAfterGenerateSave
[ FAILED ] FPDFParserDecodeEmbedderTest.Bug_455199
[ FAILED ] FPDFProgressiveRenderEmbedderTest.RenderWithoutPause
[ FAILED ] FPDFProgressiveRenderEmbedderTest.RenderWithPause
[ FAILED ] FPDFProgressiveRenderEmbedderTest.RenderAnnotWithPause
[ FAILED ] FPDFProgressiveRenderEmbedderTest.RenderFormsWithPause
[ FAILED ] FPDFAnnotEmbedderTest.ExtractInkMultiple
[ FAILED ] FPDFAnnotEmbedderTest.AddAndSaveUnderlineAnnotation
[ FAILED ] FPDFAnnotEmbedderTest.ModifyRectQuadpointsWithAP
[ FAILED ] FPDFAnnotEmbedderTest.AddAndModifyPath
[ FAILED ] FPDFAnnotEmbedderTest.AddAndModifyImage
[ FAILED ] FPDFAnnotEmbedderTest.AddAndModifyText
[ FAILED ] FPDFAnnotEmbedderTest.GetSetStringValue
[ FAILED ] FPDFEditEmbedderTest.SetText
[ FAILED ] FPDFEditEmbedderTest.RemovePageObject
[ FAILED ] FPDFEditEmbedderTest.RemoveMarkedObjectsPrime
[ FAILED ] FPDFEditEmbedderTest.RemoveExistingPageObjectSplitStreamsNotLonely
[ FAILED ] FPDFEditEmbedderTest.RemoveExistingPageObjectSplitStreamsLonely
[ FAILED ] FPDFEditEmbedderTest.RemoveAllFromStream
[ FAILED ] FPDFEditEmbedderTest.RemoveFirstFromSingleStream
[ FAILED ] FPDFEditEmbedderTest.RemoveLastFromSingleStream
[ FAILED ] FPDFEditEmbedderTest.PathOnTopOfText
[ FAILED ] FPDFEditEmbedderTest.AddStandardFontText
[ FAILED ] FPDFEditEmbedderTest.AddStandardFontText2
[ FAILED ] FPDFEditEmbedderTest.AddTrueTypeFontText
[ FAILED ] FPDFEditEmbedderTest.AddCIDFontText
[ FAILED ] FPDFEditEmbedderTest.AddMarkCompressedStream
[ FAILED ] FPDFEditEmbedderTest.AddMarkedText
[ FAILED ] FPDFFlattenEmbedderTest.BUG_861842
[ FAILED ] FPDFFormFillEmbedderTest.FormText
[ FAILED ] FPDFViewEmbedderTest.RenderHelloWorldWithFlags
$ ./pdfium_unittests
...
[----------] Global test environment tear-down
[==========] 637 tests from 84 test suites ran. (516 ms total)
[ PASSED ] 637 tests.
YOU HAVE 3 DISABLED TESTS
임베드 테스트의 경우, 많은 테스트 오류가 발생한다.
시스템 라이브러리를 사용하도록 한 옵션들중 freetype 은 임베드된 소스를 사용하도록 다시 수정한다.
# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
pdf_is_standalone = true # Set for a non-embedded build.
pdf_is_complete_lib = true # Static Library - libpdfium.a
pdf_enable_xfa = false # XFA support enabled.
pdf_enable_v8 = false # Javascript support enabled.
pdf_use_skia = false # Avoid skia backend experiment.
pdf_use_skia_paths = false # Avoid other skia backend experiment.
pdf_bundle_freetype = true
use_system_freetype = false
clang_use_chrome_plugins = false
use_goma = false
use_custom_libcxx = false
use_sysroot = false
is_component_build = false # Dynamic Library - libpdfium.so
is_debug = false # Enable debugging features.
is_clang = false # Avoid dependency hell.
use_system_zlib = true
use_system_libpng = true
use_system_lcms2 = true
use_system_libjpeg = true
use_libjpeg_turbo = true
use_system_libopenjpeg2 = true
테스트를 다시 실행한다.
$ ./pdfium_embeddertests
...
../../fpdfsdk/fpdf_edit_embeddertest.cpp:2660: Failure
Expected equality of these values:
"IPAGothic"
Which is: 0x55dfe376de88
CIDfont.GetFaceName()
Which is: { 'A' (65, 0x41), 'R' (82, 0x52), ' ' (32, 0x20), 'P' (80, 0x50), 'L' (76, 0x4C), ' ' (32, 0x20), 'U' (85, 0x55), 'K' (75, 0x4B), 'a' (97, 0x61), 'i' (105, 0x69), ' ' (32, 0x20), 'C' (67, 0x43), 'N' (78, 0x4E), ' ' (32, 0x20), 'B' (66, 0x42), 'o' (111, 0x6F), 'o' (111, 0x6F), 'k' (107, 0x6B) }
../../testing/embedder_test.cpp:640: Failure
Expected equality of these values:
expected_md5sum
Which is: "5159a72903fe57bf0cf645c894de8a74"
HashBitmap(bitmap)
Which is: "b60a1543387b3dec1401459836241844"
../../testing/embedder_test.cpp:640: Failure
Expected equality of these values:
expected_md5sum
Which is: "5159a72903fe57bf0cf645c894de8a74"
HashBitmap(bitmap)
Which is: "b60a1543387b3dec1401459836241844"
[ FAILED ] FPDFEditEmbedderTest.AddCIDFontText (1017 ms)
...[----------] Global test environment tear-down
[==========] 480 tests from 36 test suites ran. (4441 ms total)
[ PASSED ] 479 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] FPDFEditEmbedderTest.AddCIDFontText
단, 1개의 테스트 오류만 발생했다.
일단, system freetype 사용은 끄도록 하고 1개의 테스트 오류는 무시한다.
'Linux' 카테고리의 다른 글
PDFium 라이브러리 삽질기 - 3 (0) 2019.12.11 PDFium 라이브러리 삽질기 - 2 (0) 2019.12.10 TmaxOS 3.9.1 x64 설치기 (0) 2019.08.20 북한 폰트 (0) 2019.08.08 fail2ban 및 GeoIP 와 BlackIP를 이용한 IP 차단하기 (0) 2019.01.03