static-php-cli/en/develop/system-build-tools.html

91 lines
46 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Compilation Tools | static-php-cli</title>
<meta name="description" content="Build single static PHP binary, with PHP project together, with popular extensions included.">
<meta name="generator" content="VitePress v1.2.3">
<link rel="preload stylesheet" href="/assets/style.B7QwpTn2.css" as="style">
<script type="module" src="/assets/app.DAnd8ZqT.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.CszIUXhs.js">
<link rel="modulepreload" href="/assets/chunks/theme.Yd2LEGgK.js">
<link rel="modulepreload" href="/assets/en_develop_system-build-tools.md.Ds5Kgdf6.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar has-sidebar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle has-sidebar" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/en/" data-v-ab179fa1><!--[--><!--]--><!----><span data-v-ab179fa1>static-php-cli</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/guide/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Guide</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/develop/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Advanced</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/contributing/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Contributing</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/faq/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>FAQ</span><!--]--></a><!--]--><!--]--></nav><div class="VPFlyout VPNavBarTranslations translations" data-v-ccf7ddec data-v-88af2de4 data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="Change language" data-v-b6c34ac9><span class="text" data-v-b6c34ac9><span class="vpi-languages option-icon" data-v-b6c34ac9></span><!----><span class="vpi-chevron-down text-icon" data-v-b6c34ac9></span></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-e7ea1737><!----><!--[--><!--[--><div class="items" data-v-88af2de4><p class="title" data-v-88af2de4>English</p><!--[--><div class="VPMenuLink" data-v-88af2de4 data-v-43f1e123><a class="VPLink link" href="/zh/develop/system-build-tools.html" data-v-43f1e123><!--[-->简体中文<!--]--></a></div><!--]--></div><!--]--><!--]--></div></div></div><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/crazywhalecc/static-php-cli" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-ccf7ddec data-v-d0bd9dde data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-b6c34ac9><span class="vpi-more-horizontal icon" data-v-b6c34ac9></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-e7ea1737><!----><!--[--><!--[--><div class="group translations" data-v-d0bd9dde><p class="trans-title" data-v-d0bd9dde>English</p><!--[--><div class="VPMenuLink" data-v-d0bd9dde data-v-43f1e123><a class="VPLink link" href="/zh/develop/system-build-tools.html" data-v-43f1e123><!--[-->简体中文<!--]--></a></div><!--]--></div><div class=
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">FLAG = -g0 -Os -Wno-error</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">ifneq</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">$(</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATIVE</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMMON_CONFIG += CC=&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">$(</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">HOST</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">-gcc </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">STAT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot; CXX=&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">$(</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">HOST</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">-g++ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">STAT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMMON_CONFIG += CC=&quot;gcc </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">STAT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot; CXX=&quot;g++ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">STAT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">endif</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMMON_CONFIG += CFLAGS=&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">FLAG</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot; CXXFLAGS=&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">FLAG</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot; LDFLAGS=&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">${</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">STAT</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">}</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BINUTILS_CONFIG += --enable-gold=yes --enable-gprofng=no</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">GCC_CONFIG += --enable-static-pie --disable-cet --enable-default-pie </span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">#--enable-default-pie</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONFIG_SUB_REV = 888c8e3d5f7b</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">GCC_VER = 13.2.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BINUTILS_VER = 2.40</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">MUSL_VER = 1.2.4</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">GMP_VER = 6.2.1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">MPC_VER = 1.2.1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">MPFR_VER = 4.2.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LINUX_VER = 6.1.36</span></span></code></pre></div><p>And also you need to add <code>gcc-13.2.0.tar.xz.sha1</code> file, contents here:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>5f95b6d042fb37d45c6cbebfc91decfbc4fb493c gcc-13.2.0.tar.xz</span></span></code></pre></div><p>If you are using Docker to build, create a new <code>Dockerfile</code> file and write the following content:</p><div class="language-dockerfile vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">dockerfile</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">FROM</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> alpine:edge</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> apk add --no-cache \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">gcc g++ git make curl perl \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">rsync patch wget libtool \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">texinfo autoconf automake \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bison tar xz bzip2 zlib \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">file binutils flex \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">linux-headers libintl \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">gettext gettext-dev icu-libs pkgconf \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">pkgconfig icu-dev bash \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ccache libarchive-tools zip</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">WORKDIR</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> /opt</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> git clone https://git.zv.io/toolchains/musl-cross-make.git</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">WORKDIR</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> /opt/musl-cross-make</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">COPY</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.mak /opt/musl-cross-make</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">COPY</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> gcc-13.2.0.tar.xz.sha1 /opt/musl-cross-make/hashes</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make TARGET=x86_64-linux-musl -j || :</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sed -i </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;s/poison calloc/poison/g&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ./gcc-13.2.0/gcc/system.h</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make TARGET=x86_64-linux-musl -j</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make TARGET=x86_64-linux-musl install -j</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">RUN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tar cvzf x86_64-musl-toolchain.tgz output/*</span></span></code></pre></div><p>If you are using Alpine Linux in a non-Docker environment, you can directly execute the commands in the Dockerfile, for example:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">apk</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> add</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --no-cache</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">gcc </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">g++</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> perl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">rsync </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">patch</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> wget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> libtool</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">texinfo </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">autoconf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> automake</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bison </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">tar</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xz</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bzip2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> zlib</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">file </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">binutils</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> flex</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">linux-headers </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">libintl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">gettext </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">gettext-dev</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> icu-libs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pkgconf</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">pkgconfig </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">icu-dev</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bash</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ccache </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">libarchive-tools</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> zip</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://git.zv.io/toolchains/musl-cross-make.git</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Copy config.mak to the working directory of musl-cross-make.</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># You need to replace /path/to/config.mak with your config.mak file path.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">cp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/config.mak</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> musl-cross-make/</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">cp</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /path/to/gcc-13.2.0.tar.xz.sha1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> musl-cross-make/hashes</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> TARGET=x86_64-linux-musl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -j</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> ||</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> :</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sed</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -i</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;s/poison calloc/poison/g&#39;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ./gcc-13.2.0/gcc/system.h</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> TARGET=x86_64-linux-musl</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -j</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">make</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> TARGET=x86_64-linux-musl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -j</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">tar</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cvzf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> x86_64-musl-toolchain.tgz</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> output/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">*</span></span></code></pre></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>All the above scripts are suitable for x86_64 architecture Linux. If you need to build musl-cross-make for the ARM environment, just replace all <code>x86_64</code> above with <code>aarch64</code>.</p></div><p>This compilation process may fail due to insufficient memory, network problems, etc. You can try a few more times, or use a machine with larger memory to compile. If you encounter problems or you have better improvement solutions, go to <a href="https://github.com/crazywhalecc/static-php-cli-hosted/issues/1" target="_blank" rel="noreferrer">Discussion</a>.</p><h2 id="macos-environment" tabindex="-1">macOS Environment <a class="header-anchor" href="#macos-environment" aria-label="Permalink to &quot;macOS Environment&quot;"></a></h2><p>For macOS systems, the main compilation tool we use is <code>clang</code>, which is the default compiler for macOS systems and is also the compiler of Xcode.</p><p>Compiling under macOS mainly relies on Xcode or Xcode Command Line Tools. You can download Xcode from the App Store, or execute <code>xcode-select --install</code> in the terminal to install Xcode Command Line Tools.</p><p>In addition, in the <code>doctor</code> environment check module, static-php-cli will check whether Homebrew, compilation tools, etc. are installed on the macOS system. If not, you will be prompted to install them. I will not go into details here.</p><h2 id="freebsd-environment" tabindex="-1">FreeBSD Environment <a class="header-anchor" href="#freebsd-environment" aria-label="Permalink to &quot;FreeBSD Environment&quot;"></a></h2><p>FreeBSD is also a Unix system, and its compilation tools are similar to macOS. You can directly use the package management <code>pkg</code> to install <code>clang</code> and other compilation tools through the <code>doctor</code> command.</p><h2 id="pkg-config-compilation-nix-only" tabindex="-1">pkg-config Compilation (*nix only) <a class="header-anchor" href="#pkg-config-compilation-nix-only" aria-label="Permalink to &quot;pkg-config Compilation (*nix only)&quot;"></a></h2><p>If you observe the compilation log when using static-php-cli to build static PHP, you will find that no matter what is compiled, <code>pkg-config</code> will be compiled first. This is because <code>pkg-config</code> is a library used to find dependencies. In earlier versions of static-php-cli, we directly used the <code>pkg-config</code> tool installed by package management, but this would cause some problems, such as:</p><ul><li>Even if <code>PKG_CONFIG_PATH</code> is specified, <code>pkg-config</code> will try to find dependent packages from the system path.</li><li>Since <code>pkg-config</code> will look for dependent packages from the system path, if a dependent package with the same name exists in the system, compilation may fail.</li></ul><p>In order to avoid the above problems, we compile <code>pkg-config</code> into <code>buildroot/bin</code> in user mode and use it. We use parameters such as <code>--without-sysroot</code> to avoid looking for dependent packages from the system path.</p></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-d4a0bba5><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-d4a0bba5><span class="visually-hidden" id="doc-footer-aria-label" data-v-d4a0bba5>Pager</span><div class="pager" data-v-d4a0bba5><a class="VPLink link pager-link prev" href="/en/develop/source-module.html" data-v-d4a0bba5><!--[--><span class="desc" data-v-d4a0bba5>Previous page</span><span class="title" data-v-d4a0bba5>Source</span><!--]--></a></div><div class="
<script>window.__VP_HASH_MAP__=JSON.parse("{\"zh_guide_action-build.md\":\"BQOsJgGT\",\"zh_guide_index.md\":\"D0Jfo4Dz\",\"zh_guide_build-on-windows.md\":\"C1RFP4Q6\",\"en_guide_cli-generator.md\":\"D5hLj5t8\",\"en_guide_extension-notes.md\":\"C-SzmSnl\",\"en_develop_doctor-module.md\":\"M_P38WuA\",\"en_guide_env-vars.md\":\"XRLVeMgw\",\"en_index.md\":\"B7rqxnyF\",\"en_guide_extensions.md\":\"BtMDj8Bu\",\"en_guide_troubleshooting.md\":\"BZNNttUZ\",\"en_guide_index.md\":\"DzPC1rL-\",\"zh_develop_doctor-module.md\":\"CPRdzud3\",\"zh_develop_index.md\":\"CISWAEXj\",\"zh_guide_troubleshooting.md\":\"CSXAWaMN\",\"extensions.md\":\"2KrBccsz\",\"extension-notes.md\":\"CYTuu5Xm\",\"zh_guide_extensions.md\":\"BHyfzh9r\",\"zh_index.md\":\"Bu-me8xZ\",\"zh_contributing_index.md\":\"BgLPhRbJ\",\"zh_develop_system-build-tools.md\":\"DvA9SnOG\",\"en_contributing_index.md\":\"0xRtVBv6\",\"zh_develop_source-module.md\":\"ByssbQZ9\",\"zh_develop_structure.md\":\"DDUlE6Vc\",\"en_guide_manual-build.md\":\"Bn941fl8\",\"zh_faq_index.md\":\"Bs3v_2I2\",\"zh_guide_extension-notes.md\":\"BI7HOrtL\",\"en_faq_index.md\":\"DM_hczmb\",\"en_develop_system-build-tools.md\":\"Ds5Kgdf6\",\"index.md\":\"DDaDbFm-\",\"en_develop_php-src-changes.md\":\"Dw_q8s3t\",\"en_develop_source-module.md\":\"BvLG6ZYy\",\"en_guide_action-build.md\":\"DqfXKtKF\",\"zh_guide_env-vars.md\":\"Dn5AS_wq\",\"zh_guide_manual-build.md\":\"DuFqT3ee\",\"en_develop_structure.md\":\"Bam0WW0K\",\"en_develop_index.md\":\"BqNiKnHj\",\"zh_guide_cli-generator.md\":\"CT-jTm3v\",\"en_guide_build-on-windows.md\":\"Bw1buXoR\",\"zh_develop_php-src-changes.md\":\"C7L9rEms\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"static-php-cli\",\"description\":\"Build single static PHP binary, with PHP project together, with popular extensions included.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/crazywhalecc/static-php-cli\"}]},\"locales\":{\"en\":{\"label\":\"English\",\"lang\":\"en\",\"themeConfig\":{\"nav\":[{\"text\":\"Guide\",\"link\":\"/en/guide/\"},{\"text\":\"Advanced\",\"link\":\"/en/develop/\"},{\"text\":\"Contributing\",\"link\":\"/en/contributing/\"},{\"text\":\"FAQ\",\"link\":\"/en/faq/\"}],\"sidebar\":{\"/en/guide/\":[{\"text\":\"Guide\",\"items\":[{\"text\":\"Guide\",\"link\":\"/en/guide/\"},{\"text\":\"Actions Build\",\"link\":\"/en/guide/action-build\"},{\"text\":\"Manual Build\",\"link\":\"/en/guide/manual-build\"},{\"text\":\"Extension List\",\"link\":\"/en/guide/extensions\"},{\"text\":\"Extension Notes\",\"link\":\"/en/guide/extension-notes\"},{\"text\":\"Command Generator\",\"link\":\"/en/guide/cli-generator\"},{\"text\":\"Environment Variables\",\"link\":\"/en/guide/env-vars\",\"collapsed\":true}]},{\"items\":[{\"text\":\"Troubleshooting\",\"link\":\"/en/guide/troubleshooting\"},{\"text\":\"Build on Windows\",\"link\":\"/en/guide/build-on-windows\"}]}],\"/en/develop/\":[{\"text\":\"Development\",\"items\":[{\"text\":\"Get Started\",\"link\":\"/en/develop/\"},{\"text\":\"Project Structure\",\"link\":\"/en/develop/structure\"},{\"text\":\"PHP Source Modification\",\"link\":\"/en/develop/php-src-changes\"}]},{\"text\":\"Module\",\"items\":[{\"text\":\"Doctor \",\"link\":\"/en/develop/doctor-module\"},{\"text\":\"Source\",\"link\":\"/en/develop/source-module\"}]},{\"text\":\"Extra\",\"items\":[{\"text\":\"Compilation Tools\",\"link\":\"/en/develop/system-build-tools\"}]}],\"/en/contributing/\":[{\"text\":\"Contributing\",\"items\":[{\"text\":\"Contributing\",\"link\":\"/en/contributing/\"}]}]},\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright © 2023-present crazywhalecc\"}}},\"zh\":{\"label\":\"\",\"lang\":\"zh\",\"themeConfig\":{\"nav\":[{\"text\":\"\",\"link\":\"/zh/guide/\"},{\"text\":\"\",\"link\":\"/zh/develop/\"},{\"text\":\"\",\"link\":\"/zh/contributing/\"},{\"text\":\"FAQ\",\"link\":\"/zh/faq/\"}],\"sidebar\":{\"/zh/guide/\"
</body>
</html>