使用ccache大幅度加速gcc编译速度
来源:互联网 发布:无锡知谷网络 编辑:程序博客网 时间:2024/06/06 02:09
- Author:Echo Chen(陈斌)
- 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 ~/.bincd ~/.bin/ln -s /usr/bin/ccache gccln -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-buildif [[ "$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 parameterseoo=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 fidone $NDKBUILD_DIR/ndk-build.orig -j16 "${options[@]}"
-
Echo Chen:Blog.csdn.net/chen19870707
-
0 0
- 使用ccache大幅度加速gcc编译速度
- 使用ccache大幅度加速gcc编译速度
- (ubuntu)在andorid andk工程中使用ccache加速编译速度
- Android 源码编译加速 使用ccache
- Android 源码编译加速 使用ccache
- 使用ccache加速xcode编译过程
- android ccache 编译 加速
- ccache编译速度很快
- 通过使用ccache加速android 源码编译的配置
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 如何使用 CCache 进行 cocos2d-x 编译加速
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 如何使用 CCache 进行 Cocos2d-x 编译加速
- 如何使用 CCache 进行 cocos2d-x 编译加速
- 使用ccache 加速编译cocos2dx项目 android NDK
- android 4.3之后使用ccache提供编译速度
- 使用ccache机制加快Android重新编译速度
- 提高安卓的编译速度 -- 使用ccache
- nginx配置拒绝异常请求uri
- 学习笔记:boost lock-free queue
- ubuntu14上hadoop的搭建(1)
- MySQL修改表-防止SQL重复执行
- chinese
- 使用ccache大幅度加速gcc编译速度
- android开发步步为营之39:NotificationManager发通知
- chrome浏览器使用uploadify插件频繁崩溃的原因及解决办法
- 最近公共祖先LCA:Tarjan算法(介绍2)
- 结构模式之代理模式 静态代理
- C#中 Oracle实用随笔
- Cv照相机定标和三维重建
- WebService学习笔记5——AXIS2基础
- 当前Java工程师的要求