import{_ as s,c as e,o as a,ae as t}from"./chunks/framework.l7bN90nj.js";const k=JSON.parse('{"title":"Build from Source","description":"","frontmatter":{},"headers":[],"relativePath":"dev/build.md","filePath":"en/dev/build.md"}'),l={name:"dev/build.md"};function n(o,i,p,d,r,h){return a(),e("div",null,[...i[0]||(i[0]=[t(`<h1 id="build-from-source" tabindex="-1">Build from Source <a class="header-anchor" href="#build-from-source" aria-label="Permalink to &quot;Build from Source&quot;">​</a></h1><p>clice depends on C++23 features and requires a modern C++ toolchain. We also need to link against LLVM/Clang to parse ASTs. To speed up builds, the default configuration downloads our published <a href="https://github.com/clice-io/clice-llvm" target="_blank" rel="noreferrer">clice-llvm</a> prebuilt package. This assumes your local environment matches the prebuilt environment closely (especially when enabling Address Sanitizer or LTO).</p><p>To simplify setup and keep builds reproducible, we <strong>strongly recommend</strong> <a href="https://pixi.prefix.dev/latest" target="_blank" rel="noreferrer">pixi</a> to manage the development environment. Dependency versions are pinned in <code>pixi.toml</code>.</p><p>If you prefer not to use pixi, see <a href="#manual-build">Manual Build</a> below.</p><h2 id="quick-start" tabindex="-1">Quick Start <a class="header-anchor" href="#quick-start" aria-label="Permalink to &quot;Quick Start&quot;">​</a></h2><p>Install pixi following the <a href="https://pixi.prefix.dev/latest/installation" target="_blank" rel="noreferrer">official guide</a>.</p><p>We ship several tasks; the commands below configure, build, and run tests:</p><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># configure &amp;&amp; build (default RelWithDebInfo)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># unit &amp;&amp; integration</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> test</span></span></code></pre></div><p>For finer-grained tasks (first argument sets the build type):</p><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</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;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cmake-config</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Debug</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> cmake-build</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Debug</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> unit-test</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Debug</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> integration-test</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Debug</span></span></code></pre></div><div class="tip custom-block github-alert"><p class="custom-block-title">TIP</p><p>If you want to develop directly with <code>cmake</code>, <code>ninja</code>, <code>clang++</code>, etc., run <code>pixi shell</code> to enter a shell with all env vars configured.</p></div><h3 id="xmake" tabindex="-1">XMake <a class="header-anchor" href="#xmake" aria-label="Permalink to &quot;XMake&quot;">​</a></h3><p>We also support building with XMake:</p><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># config &amp; build (default releasedbg)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xmake</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># unit &amp; integration</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pixi</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xmake-test</span></span></code></pre></div><h2 id="manual-build" tabindex="-1">Manual Build <a class="header-anchor" href="#manual-build" aria-label="Permalink to &quot;Manual Build&quot;">​</a></h2><p>If you plan to build manually, first ensure your toolchain matches the versions defined in <code>pixi.toml</code>.</p><blockquote><p>Compatibility: In theory clice does not rely on compiler-specific extensions, so mainstream compilers (GCC/Clang/MSVC) should work. However, CI only guarantees specific versions of Clang. Other compilers or versions are supported on a <strong>best-effort</strong> basis. Please open an issue or PR if you hit problems.</p></blockquote><h3 id="cmake" tabindex="-1">CMake <a class="header-anchor" href="#cmake" aria-label="Permalink to &quot;CMake&quot;">​</a></h3><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</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;">cmake</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -B</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -G</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Ninja</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">    -DCMAKE_BUILD_TYPE=RelWithDebInfo</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">    -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> \\</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">    -DCLICE_ENABLE_TEST=ON</span></span></code></pre></div><blockquote><p>Note: <code>CMAKE_TOOLCHAIN_FILE</code> is optional. If your toolchain exactly matches ours, you can use the predefined <code>cmake/toolchain.cmake</code>; otherwise remove that flag.</p></blockquote><p>Optional build options:</p><table tabindex="0"><thead><tr><th>Option</th><th>Default</th><th>Effect</th></tr></thead><tbody><tr><td>LLVM_INSTALL_PATH</td><td>&quot;&quot;</td><td>Build clice with LLVM from a custom path</td></tr><tr><td>CLICE_ENABLE_TEST</td><td>OFF</td><td>Build clice unit tests</td></tr><tr><td>CLICE_USE_LIBCXX</td><td>OFF</td><td>Build clice with libc++ (adds <code>-std=libc++</code>); if enabled, ensure the LLVM libs are also built with libc++</td></tr><tr><td>CLICE_CI_ENVIRONMENT</td><td>OFF</td><td>Enable the <code>CLICE_CI_ENVIRONMENT</code> macro; some tests only run in CI</td></tr></tbody></table><h3 id="xmake-1" tabindex="-1">XMake <a class="header-anchor" href="#xmake-1" aria-label="Permalink to &quot;XMake&quot;">​</a></h3><p>Build clice with:</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;">xmake</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> f</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -c</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --mode=releasedbg</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --toolchain=clang</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">xmake</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --all</span></span></code></pre></div><p>Optional build options:</p><table tabindex="0"><thead><tr><th>Option</th><th>Default</th><th>Effect</th></tr></thead><tbody><tr><td>--llvm</td><td>&quot;&quot;</td><td>Build clice with LLVM from a custom path</td></tr><tr><td>--enable_test</td><td>false</td><td>Build clice unit tests</td></tr><tr><td>--ci</td><td>false</td><td>Enable <code>CLICE_CI_ENVIRONMENT</code></td></tr></tbody></table><h2 id="about-llvm" tabindex="-1">About LLVM <a class="header-anchor" href="#about-llvm" aria-label="Permalink to &quot;About LLVM&quot;">​</a></h2><p>clice calls Clang APIs to parse C++ code, so it must link against LLVM/Clang. Because clice uses Clang&#39;s private headers (usually absent from distro packages), the system LLVM package cannot be used directly.</p><p>Two ways to satisfy this dependency:</p><ol><li>We publish prebuilt binaries of the LLVM version we use at <a href="https://github.com/clice-io/clice-llvm/releases" target="_blank" rel="noreferrer">clice-llvm</a> for CI and release builds. During builds, cmake and xmake download these LLVM libs by default.</li></ol><div class="important custom-block github-alert"><p class="custom-block-title">IMPORTANT</p><p></p><p>For debug LLVM builds, we enable address sanitizer, which depends on compiler-rt and is very sensitive to compiler version. If you use a debug build, ensure your clang compiler-rt version matches the one defined in <code>pixi.toml</code>.</p></div><ol start="2"><li>Build LLVM/Clang yourself to match your environment. If the default prebuilt binaries fail due to ABI or library version mismatches, or you need a custom debug build, use this approach. We provide <code>scripts/build-llvm.py</code> to build the required LLVM libs, or refer to LLVM&#39;s official guide <a href="https://llvm.org/docs/CMake.html" target="_blank" rel="noreferrer">Building LLVM with CMake</a>.</li></ol>`,33)])])}const u=s(l,[["render",n]]);export{k as __pageData,u as default};
