使用ccache大幅度加速gcc编译速度
2014-11-14 00:00
260 查看
Author:Echo Chen(陈斌)
Email:chenb19870707@gmail.com
Blog:Blog.csdn.net/chen19870707
Date:May 9th, 2013
查看安装路径, /usr/bin/ccache
如果是/home/<user>/.bin/g++就成功了;
直接编译项目,是不是飞一样的感觉,
xcode ccache加速:https://stackedit.io/viewer#!provider=gist&gistId=bace97f64151a503b824&filename=speedup-xcode-via-ccache-zhzheng-1.md
此外ccache也支持android(MacOS)
安装Homebrew Google之
brew 会把ccache安装到/usr/local/bin,确保这个路径在你的$PATH中
设置ccache缓存大小,最好超过10G
我设置了缓存空间200G,对build-machine应该足够了。ccache -s可以查看ccache的运行状态
增加CCACHE变量 修改.bashrc or .bash_profile
修改build_native.sh. 将其中的ndk-build -j3…改为 ndk-build -j16
四核cpu配置8,16,32都可以,看自己习惯
注意下面代码中的 -j16
创建ndk-build-j16脚本,内容在后面
ndk-build-j16 我放到了~/bin中,也可以直接放到$NDK_ROOT/中
chmod +x ~/bin/ndk-build-j16, only once
ln -s $HOME/bin/ndk-build-j16 $NDK_ROOT/bin/ndk-build-j16
mv -v $NDK_ROOT/ndk-build ndk-build.orig
ln -s $NDK_ROOT/ndk-build-j16 $NDK_ROOT/ndk-build
-
Echo Chen:Blog.csdn.net/chen19870707
-
Email:chenb19870707@gmail.com
Blog:Blog.csdn.net/chen19870707
Date:May 9th, 2013
Explain
在做游戏服务器时,由于耦合度较高,每次编译都需要编译整个工程,非常耗时,偶然的发现了ccache,安装使用了一下,果然神奇,原来需要5分钟编译的工程1分钟可以编译完成,很好用,下面mark一下ubuntu下安装使用方法。
安装ccache
sudo apt-get install ccache
查看ccache 安装位置
whereis ccache
查看安装路径, /usr/bin/ccache
创建gcc,g++链接
mkdir ~/.bin cd ~/.bin/ ln -s /usr/bin/ccache gcc ln -s /usr/bin/ccache g++
PATH设置,更改本地.bashrc文件,修改gcc,g++链接到ccache
vim ~/.bashrc
添加 export PATH="/home/<user>/.bin:$PAHT
确认是否生效
which g++
如果是/home/<user>/.bin/g++就成功了;直接编译项目,是不是飞一样的感觉,
xcode ccache加速:https://stackedit.io/viewer#!provider=gist&gistId=bace97f64151a503b824&filename=speedup-xcode-via-ccache-zhzheng-1.md
此外ccache也支持android(MacOS)
安装Homebrew Google之
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" brew update brew install ccache
brew 会把ccache安装到/usr/local/bin,确保这个路径在你的$PATH中
设置ccache缓存大小,最好超过10G
ccache -M 200G ccache -s
我设置了缓存空间200G,对build-machine应该足够了。ccache -s可以查看ccache的运行状态
增加CCACHE变量 修改.bashrc or .bash_profile
export NDK_CCACHE=ccache export USE_CCACHE=1
修改build_native.sh. 将其中的ndk-build -j3…改为 ndk-build -j16
四核cpu配置8,16,32都可以,看自己习惯
注意下面代码中的 -j16
# run ndk-build if [[ "$buildexternalsfromsource" ]]; then echo "Building external dependencies from source" "$NDK_ROOT"/ndk-build -j16 -C "$APP_ANDROID_ROOT" $* \ "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" else echo "Using prebuilt externals" "$NDK_ROOT"/ndk-build -j16 -C "$APP_ANDROID_ROOT" $* \ "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
下面内容可以忽略
如果不想修改native_build.sh,也可以通过修改ndk-build工具达到强制gcc并行编译的数量。操作步奏如下创建ndk-build-j16脚本,内容在后面
ndk-build-j16 我放到了~/bin中,也可以直接放到$NDK_ROOT/中
chmod +x ~/bin/ndk-build-j16, only once
ln -s $HOME/bin/ndk-build-j16 $NDK_ROOT/bin/ndk-build-j16
mv -v $NDK_ROOT/ndk-build ndk-build.orig
ln -s $NDK_ROOT/ndk-build-j16 $NDK_ROOT/ndk-build
~/bin/ndk-build-16 的文件内容,记得chmod +x
#!/bin/bash # ndk-build wrapper, for ignore -jN options # this file should put into $NDK_ROOT # mv -v $NDK_ROOT/ndk-build ndk-build.orig # ln -s $NDK_ROOT/ndk-build-j16 $NDK_ROOT/ndk-build # ndk-build-j16 is current script name options=() # the buffer array for the parameters eoo=0 # end of options reached NDKBUILD_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" while [[ $1 ]] do if ! ((eoo)); then case "$1" in -j[0-9]+) shift ;; --) eoo=1 options+=("$1") shift ;; *) options+=("$1") shift ;; esac else options+=("$1") # Another (worse) way of doing the same thing: # options=("${options[@]}" "$1") shift fi done $NDKBUILD_DIR/ndk-build.orig -j16 "${options[@]}"
-
Echo Chen:Blog.csdn.net/chen19870707
-
相关文章推荐
- 使用ccache大幅度加速gcc编译速度
- 用ccache加速gcc/g++的编译速度
- (ubuntu)在andorid andk工程中使用ccache加速编译速度
- (ubuntu)在andorid andk工程中使用ccache加速编译速度
- Android 源码编译加速 使用ccache
- android 4.3之后使用ccache提供编译速度
- 通过使用ccache加速android 源码编译的配置
- 使用ccache机制加快Android重新编译速度
- 怎样使用 CCache 进行 cocos2d-x 编译加速
- Android 源码编译加速 使用ccache
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 提高安卓的编译速度 -- 使用ccache
- 如何使用 CCache 进行 cocos2d-x 编译加速
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 使用ccache加速xcode编译过程
- 使用ccache 加速编译cocos2dx项目 android NDK
- 使用预编译头文件加快C++语言编译速度
- 如何在puppy linux 4.1上使用GCC编译---devx_410.sfs
- 使用gcc编译1-3.c