You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generally speaking, the build results in these two environments are consistent, and you can choose according to actual needs.
42
-
43
-
In the doctor module, static-php-cli will first detect the current Linux distribution.
44
-
If the current distribution is a glibc environment, you will be prompted to install the musl-wrapper and musl-cross-make packages.
45
-
46
-
The process of installing `musl-wrapper` in the glibc environment is as follows:
47
-
48
-
1. Download the specific version of [musl-wrapper source code](https://musl.libc.org/releases/) from the musl official website.
49
-
2. Use `gcc` installed from the package management to compile the musl-wrapper source code and generate `musl-libc` and other libraries: `./configure --disable-gcc-wrapper && make -j && sudo make install`.
50
-
3. The musl-wrapper related libraries will be installed in the `/usr/local/musl` directory.
51
-
52
-
The process of installing `musl-cross-make` in the glibc environment is as follows:
53
-
54
-
1. Download the precompiled [musl-cross-make](https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/) compressed package from dl.static-php.dev .
55
-
2. Unzip to the `/usr/local/musl` directory.
56
-
57
-
::: tip
58
-
In the glibc environment, static compilation can be achieved by directly installing musl-wrapper,
59
-
but musl-wrapper only contains `musl-gcc` and not `musl-g++`, which means that C++ code cannot be compiled.
60
-
So we need musl-cross-make to provide `musl-g++`.
61
-
62
-
The reason why the musl-cross-make package cannot be compiled directly locally is that
63
-
its compilation environment requirements are relatively high (requires more than 36GB of memory, compiled under Alpine Linux),
64
-
so we provide precompiled binary packages that can be used for all Linux distributions.
65
-
66
-
At the same time, the package management of some distributions provides musl-wrapper,
67
-
but musl-cross-make needs to match the corresponding musl-wrapper version,
68
-
so we do not use package management to install musl-wrapper.
69
-
70
-
Compiling musl-cross-make will be introduced in the **musl-cross-make Toolchain Compilation** section of this chapter.
71
-
:::
72
41
73
42
### Musl Environment
74
43
@@ -82,133 +51,14 @@ You only need to install basic compilation tools (such as `gcc`, `cmake`, etc.)
82
51
For other distributions, if your distribution uses the musl environment,
83
52
you can also use static-php-cli to build static PHP directly after installing the necessary compilation tools.
84
53
85
-
::: tip
86
-
In the musl environment, static-php-cli will automatically skip the installation of musl-wrapper and musl-cross-make.
87
-
:::
88
-
89
54
### Docker Environment
90
55
91
-
The Docker environment refers to using Docker containers to build static PHP. You can use `bin/spc-alpine-docker` to build.
92
-
Before executing this command, you need to install Docker first, and then execute `bin/spc-alpine-docker` in the project root directory.
56
+
The Docker environment refers to using Docker containers to build static PHP. You can use `bin/spc-alpine-docker`or `bin/spc-gnu-docker`to build.
57
+
Before executing this command, you need to install Docker first.
93
58
94
59
After executing `bin/spc-alpine-docker`, static-php-cli will automatically download the Alpine Linux image and then build a `cwcc-spc-x86_64` or `cwcc-spc-aarch64` image.
95
60
Then all build process is performed within this image, which is equivalent to compiling in Alpine Linux.
96
61
97
-
## musl-cross-make Toolchain Compilation
98
-
99
-
In Linux, although you do not need to manually compile the musl-cross-make tool,
100
-
if you want to understand its compilation process, you can refer here.
101
-
Another important reason is that this may not be compiled using automated tools such as CI and Actions,
102
-
because the existing CI service compilation environment does not meet the compilation requirements of musl-cross-make,
103
-
and the configuration that meets the requirements is too expensive.
104
-
105
-
The compilation process of musl-cross-make is as follows:
106
-
107
-
Prepare an Alpine Linux environment (either directly installed or using Docker).
108
-
The compilation process requires more than **36GB** of memory,
109
-
so you need to compile on a machine with larger memory.
110
-
Without this much memory, compilation may fail.
111
-
112
-
Then write the following content into the `config.mak` file:
sed -i 's/poison calloc/poison/g' ./gcc-13.2.0/gcc/system.h
198
-
make TARGET=x86_64-linux-musl -j
199
-
make TARGET=x86_64-linux-musl install -j
200
-
tar cvzf x86_64-musl-toolchain.tgz output/*
201
-
```
202
-
203
-
::: tip
204
-
All the above scripts are suitable for x86_64 architecture Linux.
205
-
If you need to build musl-cross-make for the ARM environment, just replace all `x86_64` above with `aarch64`.
206
-
:::
207
-
208
-
This compilation process may fail due to insufficient memory, network problems, etc.
209
-
You can try a few more times, or use a machine with larger memory to compile.
210
-
If you encounter problems or you have better improvement solutions, go to [Discussion](https://github.com/crazywhalecc/static-php-cli-hosted/issues/1).
211
-
212
62
## macOS Environment
213
63
214
64
For macOS systems, the main compilation tool we use is `clang`,
0 commit comments