Basically our build mechanism relies on an assumption that src/build_mozc.py and src/gyp/common.gyp have the full control of what compilers and linkers will be used for a given target platform and build configuration.
As of Mozc cfe9a2a5c7576a01fdbbadca43760496a9405ece, the above assumption is not always true, because make_global_settings in src/gyp/common.gyp can be overridden by certain environment variables such as $CC and $CXX.
As described in pylib/gyp/generator/ninja.py, environment variables such as $CC and $CXX have higher priority than make_global_settings.
# Grab make settings for CC/CXX.
# The rules are
# - The priority from low to high is gcc/g++, the 'make_global_settings' in
# gyp, the environment variable.
# - If there is no 'make_global_settings' for CC.host/CXX.host or
# 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set
# to cc/cxx.
In order to make our build process more reliable and reproducible, the following environment variables should be cleared when running python build_mozc.py gyp so that build tools specified in src/gyp/common.gyp can be picked up as intended.
CC
CC_host
CC_target
CXX
CXX_host
CXX_target
LINK
AR
AR_host
AR_target
NM
NM_host
NM_target
READELF
READELF_host
READELF_target
Note that you can see what build tools are picked up by GYP in build.ninja (e.g. out_android/Release/build.ninja for Android release build). Here is an expected result for Android build, which was taken in Ubuntu 14.04 Docker image as of cfe9a2a5c7576a01fdbbadca43760496a9405ece.
Basically our build mechanism relies on an assumption that
src/build_mozc.py
andsrc/gyp/common.gyp
have the full control of what compilers and linkers will be used for a given target platform and build configuration.As of Mozc cfe9a2a5c7576a01fdbbadca43760496a9405ece, the above assumption is not always true, because
make_global_settings
insrc/gyp/common.gyp
can be overridden by certain environment variables such as$CC
and$CXX
.As described in pylib/gyp/generator/ninja.py, environment variables such as
$CC
and$CXX
have higher priority thanmake_global_settings
.In order to make our build process more reliable and reproducible, the following environment variables should be cleared when running
python build_mozc.py gyp
so that build tools specified insrc/gyp/common.gyp
can be picked up as intended.CC
CC_host
CC_target
CXX
CXX_host
CXX_target
LINK
AR
AR_host
AR_target
NM
NM_host
NM_target
READELF
READELF_host
READELF_target
Note that you can see what build tools are picked up by GYP in
build.ninja
(e.g.out_android/Release/build.ninja
for Android release build). Here is an expected result for Android build, which was taken in Ubuntu 14.04 Docker image as of cfe9a2a5c7576a01fdbbadca43760496a9405ece.