yodalee / mozc

Mozc - a Japanese Input Method Editor designed for multi-platform
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

toolchain-related environment variables such as $CC and $CXX should be unset #80

Open yodalee opened 6 years ago

yodalee commented 6 years ago

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.

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.

cc = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-gcc
cxx = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-g++
ld = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-ld
ldxx = $cxx
ar = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-ar
nm = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-nm
readelf = $
    /home/mozc_builder/work/mozc/src/out_android/mozc_build_tools/ndk-standalone-toolchain/arm/bin/arm-linux-androideabi-readelf
ar_host = /usr/bin/ar
nm_host = /usr/bin/nm
readelf_host = /usr/bin/readelf
cc_host = /usr/bin/clang
cxx_host = /usr/bin/clang++
ld_host = /usr/bin/ld
ldxx_host = $cxx_host