crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.16k stars 181 forks source link

macos 上的mongodb DB扩展关于ZSTD、 ZLIB 、SNNAPY库的处理办法 #61

Closed jingjingxyk closed 1 year ago

jingjingxyk commented 1 year ago

macos 因为mongodb 扩展对于这三个库,有自动检测,但是没有关闭选项。

https://github.com/crazywhalecc/static-php-cli/actions/runs/5087204006

这个问题我是这么解决的

为啥我知道这个,因为swoole-cli 也是同样的问题,https://github.com/swoole/swoole-cli/actions/runs/5042675610/jobs/9043555754

    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
    /usr/lib/libsasl2.2.dylib (compatibility version 3.0.0, current version 3.15.0)
    /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/snappy/lib/libsnappy.1.dylib (compatibility version 1.0.0, current version 1.1.10)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
    /usr/lib/libnetwork.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/opt/zstd/lib/libzstd.1.dylib (compatibility version 1.0.0, current version 1.5.5)

解决办法: 办法一: 通过查看mongodb 源码,发现,它可以通过设置环境变量设置值;我就是通过查看源码,发现加上PHP_MONGODB_ZSTD_CFLAGS PHP_MONGODB_ZSTD_LIBS ,解决了它总是链接到系统库的问题

办法二: 卸载系统带有 zstd zlib snappy库以后,在进行编译

 brew uninstall --ignore-dependencies snappy
brew uninstall --ignore-dependencies  zstd
crazywhalecc commented 1 year ago

方法二就不考虑了,会影响系统。

方法一的话,目前在配置文件添加 lib-depends: zstd 可以解决 zstd 的依赖问题,但目前还没有对 libsnappy 编译的脚本,而且它是 C++ 项目,支持起来会比较麻烦。所以我在想,zstd 可以通过加上 lib-depends 实现,snappy 先 patch 掉,以后有需求了再支持把 snappy 编译进去。

crazywhalecc commented 1 year ago

还有一计,给 mongodb 库提 Issue。这样说不定能根本上解决这个问题,因为毕竟这几个库是可选库,它没有开启 configure 选项就说不过去了,也不能总是让本项目这么 patch 下去。之前 libevent 扩展就是配合 dixyes 大佬给 pecl-event 库提了一个内嵌编译的支持。

https://github.com/mongodb/mongo-php-driver/issues/1427

jingjingxyk commented 1 year ago

@crazywhalecc capstone 不是mongodb 需要的选项哈。而是macos 编译PHP opcache 扩展时会检测这个库。上面我写的时候,写多了

crazywhalecc commented 1 year ago

已修复: https://github.com/crazywhalecc/static-php-cli/commit/fdf36ad7263e6d2779bb26c327eca0e83c519355