llvm社区目前不接受github的issue和pullrequest,而是通过Phabricator
做code review和提交patch的。如何向llvm代码仓库提交patch,llvm社区有相应的文档介绍,但是这个过程还是有一些坑的,所以开个文档记录一下。
按照llvm文档,首先需要在Phabricator
注册账户,可以直接用github或者google账户登录。
此外还需要一个命令行工具Arcanist
,该工具依赖php和git,需要先安装好这两个工具,然后参照"https://secure.phabricator.com/book/phabricator/article/arcanist_quick_start/">Arcanist指引文档
操作:
克隆工具仓库:
${your_tool_path}/ $ git clone https://github.com/phacility/arcanist.git
将路径加入到环境变量中
$ export PATH="$PATH:/somewhere/arcanist/bin/"
此时,命令行工具arc
应该就可以使用了(此处遇到第一个坑)。
安装好Arcanist
后,需要先安装一个认证证书(此处遇到第二个坑),然后就可以用该工具从命令行创建patch分支了。
cd $project_path
$project_path/ $ arc install-certificate
完成认证后,就可以根据Phabricator网站上对应的Review编号创建Patch分支了,具体命令如下:
arc path -D$(ReviewID)
到这里就创建了一个可以向llvm仓库贡献代码的分支。
另外,llvm在"https://bugs.llvm.org/">Bugzilla网站
上维护待修复的问题,(近期这个Bug列表也正在迁移到github,后续应该关联github issue就好了。),可以根据Issue中对应的问题做一些修复。
第一个坑是一些php函数被禁用问题:安装完成arc
运行报错现实php禁用了proc_open
函数:
Call to "proc_open()" to open a subprocess failed: proc_open() has been disabled for security reasons
查资料发现是在php.ini
配置文件中禁用了这个函数,全局搜索该文件位置,然后将里面disable-funcitons
字段中配置的proc_open
函数删掉即可。
第二个坑是arc
安装证书过程中https访问失败问题:
-> % arc install-certificate
CONNECT Connecting to "https://reviews.llvm.org/api/"...
Usage Exception: Failed to connect to server (https://reviews.llvm.org/api/): [cURL/60] (https://reviews.llvm.org/api/conduit.ping) <CURLE_SSL_CACERT> There was an error verifying the SSL connection. This usually indicates that the remote host has an SSL certificate for a different domain name than you are connecting with. Make sure the certificate you have installed is signed for the correct domain.
看意思是HTTPS使用的SSL证书CA和域名不匹配,但是单独执行curl https://reviews.llvm.org/api/conduit.ping
命令返回是正常的。
首先尝试了将llvm项目文件中的.arcconfig
配置文件中的https协议全部换成http协议:
{
"phabricator.uri" : "https://reviews.llvm.org/",
"repository.callsign" : "G",
"conduit_uri" : "https://reviews.llvm.org/",
"base": "git:HEAD^",
"arc.land.onto.default": "main",
"arc.land.onto": ["main"]
}
这样虽然arc install-certificate
可以执行,但是由于修改了llvm项目仓库中的配置文件.arcconfig
,导致新分支创建失败,而且http协议会有安全隐患,这样修改也不太好。
最终还是考虑CA证书和Domain不匹配的问题,查了一下发现Phabricator文档中有相关信息:Arcanist
在建立https连接的时候使用的是arcanist/resources/ssl/default.pem
这个CA证书,但是这个证书是给https://secure.phabricator.com
这个域名的,所以导致证书和域名不一致。我们只要找到https://reviews.llvm.org/
这个域名对应的CA证书,替换一下就ok了。找这个证书的话用chrome浏览器的F12大法就可以搞定了:
chrome浏览器F12,然后地址栏输入https://reviews.llvm.org/
在右边Security
里查看证书详细信息,并导出为文件,然后用该文件替换原来的default.pem
就好了。
如果命令行环境没有浏览器,也可以通过openssl客户端导出对应网站的CA证书:
openssl s_client -showcerts -servername reviews.llvm.org -connect reviews.llvm.org:443 > custom.pem
(**看arcanist的ssl文件夹下的readme才发现提供custom.pem
后会优先加载custom.pem。一定要先看README!!!**)