搭建php7源代码编译调试环境
前言:搭建php7源代码编译调试环境,自己的系统环境是mac m1
参考文章:https://www.php.net/manual/en/install.unix.php
参考文章:https://dev.to/xsavitar/compiling-php-php-src-source-on-macos-bigsur-3efp
参考文章:https://blog.csdn.net/u011929670/article/details/127091556
编译php7
安装bison
brew install bison

安装re2c
brew install re2c

安装libiconv
brew install libiconv

./configure --enable-debug --with-iconv=/opt/homebrew/opt/libiconv -prefix=/Users/xiaoyu/Desktop/software_source_reader/read-php-src-master/php-src/source/

make -j4
报错一修复,修改文件main/reentrancy.c改成下面这行

报错二修复

将Zend/zend_language_parser.c中添加如下两行

报错三修复

将makefile文件中的EXTRA_LIBS中的-liconv -liconv 修改为 -liconv /opt/homebrew/opt/libiconv/lib/libiconv.dylib

报错四修复

./configure --enable-debug --with-iconv=/opt/homebrew/opt/libiconv --without-pear --disable-phar -prefix=/Users/xiaoyu/Desktop/software_source_reader/read-php-src-master/php-src/source/
make clean
make -j4 && make install

php7调试环境
vscode的launch.json配置文件如下所示
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debuug php source",
"type": "cppdbg",
"request": "launch",
"program": "/Users/xiaoyu/Desktop/software_source_reader/read-php-src-master/php-src/source/bin/php",
"args": ["-f","/Users/xiaoyu/test.php"],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
]
}

test.php
<?php
var_dump(parse_url("http://www.baidu.com"));


浙公网安备 33010602011771号