Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macbook上使用SPC构建报错 #352

Closed
y1713375484 opened this issue Feb 25, 2024 · 24 comments
Closed

macbook上使用SPC构建报错 #352

y1713375484 opened this issue Feb 25, 2024 · 24 comments
Labels
bug Something isn't working os/macos Things only for macOS

Comments

@y1713375484
Copy link

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [xsltproc] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
[08:14:20] [ERRO] Uncaught SPC\exception\RuntimeException: Command run failed with code[2]: cd '/Applications/EServer/www/php-spc/source/libxslt' && make -j8 at phar:///Applications/EServer/www/php-spc/spc/src/globals/functions.php(100)
[08:14:20] [ERRO] #0 phar:///Applications/EServer/www/php-spc/spc/src/SPC/util/UnixShell.php(47): f_passthru('cd '/Applicatio...')
#1 phar:///Applications/EServer/www/php-spc/spc/src/SPC/builder/unix/library/libxslt.php(45): SPC\util\UnixShell->exec('cd '/Applicatio...')
#2 phar:///Applications/EServer/www/php-spc/spc/src/SPC/builder/LibraryBase.php(144): SPC\builder\macos\library\libxslt->build()
#3 phar:///Applications/EServer/www/php-spc/spc/src/SPC/builder/LibraryBase.php(152): SPC\builder\LibraryBase->tryBuild(true)
#4 phar:///Applications/EServer/www/php-spc/spc/src/SPC/builder/unix/UnixBuilderBase.php(143): SPC\builder\LibraryBase->tryBuild(false)
#5 phar:///Applications/EServer/www/php-spc/spc/src/SPC/command/BuildCliCommand.php(135): SPC\builder\unix\UnixBuilderBase->buildLibs(Array)
#6 phar:///Applications/EServer/www/php-spc/spc/src/SPC/command/BaseCommand.php(99): SPC\command\BuildCliCommand->handle()
#7 phar:///Applications/EServer/www/php-spc/spc/vendor/symfony/console/Command/Command.php(326): SPC\command\BaseCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 phar:///Applications/EServer/www/php-spc/spc/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///Applications/EServer/www/php-spc/spc/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(SPC\command\BuildCliCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///Applications/EServer/www/php-spc/spc/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///Applications/EServer/www/php-spc/spc/bin/spc(20): Symfony\Component\Console\Application->run()
#12 /Applications/EServer/www/php-spc/spc(8): require('phar:///Applica...')

这个报错之前是先报错未安装cmake,然后通过brew安装cmake后报错就是如上了

@y1713375484
Copy link
Author

编译的扩展有
./spc build --build-micro "apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib" --debug

@y1713375484
Copy link
Author

编译的过程有点长发不出来

@crazywhalecc
Copy link
Owner

你的错误信息刚好没有包含关键信息,编译错误应该在 clang: error: linker command failed with exit code 1 (use -v to see invocation) 上面的几句。

@crazywhalecc crazywhalecc added bug Something isn't working os/macos Things only for macOS labels Feb 25, 2024
@y1713375484
Copy link
Author

1.txt

@crazywhalecc
Copy link
Owner

删除 buildroot source 两个目录后再次构建试下?

@y1713375484
Copy link
Author

依旧还是报错

@crazywhalecc
Copy link
Owner

还是同样的报错吗,如果是的话,发一下 source/libxslt/config.log 文件。

@y1713375484
Copy link
Author

Uploading config.log…

@y1713375484
Copy link
Author

config.log

@crazywhalecc
Copy link
Owner

  1. 删除 ./buildroot/ ./source/ 两个目录
  2. 运行 `./spc doctor
  3. 运行 ./spc doctor
  4. 运行 ./spc download --all --debug 下载所有依赖
  5. 运行 ./spc build xxxxx,yyyyyy --build-cli --debug 并将错误日志完全拷贝出来

另外,我看你第一个发送的日志里面是用 --from-zip 来下载资源的,是从哪里下载的?

@y1713375484
Copy link
Author

--from-zip的资源就是从这里下载的,我尝试用bin/spc download --all下载也是有报错的
image

@y1713375484
Copy link
Author

用./spc doctor修复过后,下载了依赖重新尝试
config.log

@crazywhalecc
Copy link
Owner

crazywhalecc commented Feb 25, 2024

--from-zip的资源就是从这里下载的,我尝试用bin/spc download --all下载也是有报错的

如果你在大陆境内可能得挂全局梯子下载会好一点,六七十个资源都是在外网服务器的。

用./spc doctor修复过后,下载了依赖重新尝试

这个 config.log 显示没啥问题,目前没看出来是什么问题,麻烦再把终端的信息发一下。

@y1713375484
Copy link
Author

麻烦了
终端报错.txt

@crazywhalecc
Copy link
Owner

这样看下来很可能是因为你的部分构建工具装错成了 Intel x86 版,导致你在 M 芯片上用 Rosetta 跑的部分库的编译。我猜测你可能是 cmake 装错了,建议卸载 cmake 后直接用 doctor 自动修复重新安装下。

@y1713375484
Copy link
Author

我卸载了cmake,然后通过doctor重新安装修复之后,并删除 ./buildroot/ ./source/ 目录重新编译还是报错
终端报错.txt
config.log

@y1713375484
Copy link
Author

image 好像cmake还是x86的,我这是通过doctor安装的

@crazywhalecc
Copy link
Owner

那你的 Homebrew 是装在 /usr/local/Homebrew 的还是 /opt/homebrew 的?如果是前者,你可能需要安装一个 arm 的 homebrew。

@y1713375484
Copy link
Author

是/usr/local/bin/brew

@y1713375484
Copy link
Author

应该是解决了,现在提示在编译二进制文件是内存不足
yzh@yanzehangdeMacBook-Pro php-spc % ./spc micro:combine wbxt.phar
_ _ _ _
| | __ | |() ___ _ __ | |_ _ __
/ | / ` | __| |/ __|| ' | ' | ' \
__ \ || (| | || | (_|
| |) | | | | |) |
|
/__,|_||_| | ./|| || .__/ v2.1.0
|
| |_|

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 89772592 bytes) in phar:///Applications/EServer/www/php-spc/spc/src/SPC/command/MicroCombineCommand.php on line 89
yzh@yanzehangdeMacBook-Pro php-spc %

@y1713375484
Copy link
Author

应该和我本地的PHP内存没关系吧

@crazywhalecc
Copy link
Owner

应该和我本地的PHP内存没关系吧

没关系,这个是一个小 Bug,如果使用 micro:combine 来结合代码和 micro 的话,默认的内存限制是 128M。我后面把默认的 memory_limit 调大一点就好了。如果文件过大,建议直接用 cat 命令:cat buildroot/bin/micro.sfx wbxt.phar > my-app

@y1713375484
Copy link
Author

感谢大佬耐心解答,以捐赠,最后想问下,在MacBook上是不是不能打包linux、windows的可执行文件

@crazywhalecc
Copy link
Owner

感谢大佬耐心解答,以捐赠,最后想问下,在MacBook上是不是不能打包linux、windows的可执行文件

目前不能交叉编译,但你可以提前预编译好其他平台的 micro.sfx 然后在另外一个操作系统上组合你的代码。因为 PHP 代码可能会经常变化,但是 php 和相关扩展的变化确定后一般变化不多,可以提前定时使用 CI 编译好然后直接使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working os/macos Things only for macOS
Projects
None yet
Development

No branches or pull requests

2 participants