| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>xmake</title>
- <link rel="icon" href="/assets/img/favicon.ico">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <meta name="description" content="Description">
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <link href="/assets/npm/github-markdown/github-markdown.min.css" rel="stylesheet">
- <style>
- .markdown-body {
- box-sizing: border-box;
- min-width: 200px;
- max-width: 980px;
- margin: 0 auto;
- padding: 45px;
- }
- @media (max-width: 767px) {
- .markdown-body {
- padding: 15px;
- }
- }
- </style>
- </head>
- <body>
- <article class="markdown-body">
- <h4>This is a mirror page, please see the original page: </h4><a href="https://xmake.io/#/toolchain/builtin_toolchains">https://xmake.io/#/toolchain/builtin_toolchains</a>
- <div id="wwads-panel" class="wwads-cn wwads-vertical wwads-sticky" data-id="239" style="max-width:180px;bottom:20px;right:20px;width:200px;height:260px;background:#fff;position:fixed"></div>
- </br>
- <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
- <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CE7I52QU&placement=xmakeio" id="_carbonads_js"></script>
- <style>
- #carbonads {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
- Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
- }
- #carbonads {
- display: flex;
- max-width: 330px;
- background-color: hsl(0, 0%, 98%);
- box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, .1);
- }
- #carbonads a {
- color: inherit;
- text-decoration: none;
- }
- #carbonads a:hover {
- color: inherit;
- }
- #carbonads span {
- position: relative;
- display: block;
- overflow: hidden;
- }
- #carbonads .carbon-wrap {
- display: flex;
- }
- .carbon-img {
- display: block;
- margin: 0;
- line-height: 1;
- }
- .carbon-img img {
- display: block;
- }
- .carbon-text {
- font-size: 13px;
- padding: 10px;
- line-height: 1.5;
- text-align: left;
- }
- .carbon-poweredby {
- display: block;
- padding: 8px 10px;
- background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
- text-align: center;
- text-transform: uppercase;
- letter-spacing: .5px;
- font-weight: 600;
- font-size: 9px;
- line-height: 1;
- }
- </style>
- <p>!> Due to the author's limited personal energy, all the tool chains supported by xmake are not listed in this document, which will be gradually added later, and everyone is welcome to propose pr improvements or provide sponsored support document updates.</p>
- <h3 id="gcc">Gcc</h3>
- <p>If the gcc toolchain is installed on linux, xmake will usually be detected and used first. Of course, we can also manually switch to gcc to build.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=gcc -c
- $ xmake
- </code></pre>
- <h4 id="usethespecifiedversionofgcc">Use the specified version of Gcc</h4>
- <p>If the user additionally installs a specific version of the gcc tool chain such as gcc-11, gcc-10, the local gcc program may be named <code>/usr/bin/gcc-11</code>.</p>
- <p>One way is to switch by specifying the configuration one by one through <code>xmake f --cc=gcc-11 --cxx=gcc-11 --ld=g++-11</code>, but it is very cumbersome.</p>
- <p>Therefore, xmake also provides a faster switching method:</p>
- <pre><code class="lang-console">$ xmake f --toolchain=gcc-11 -c
- $ xmake
- </code></pre>
- <p>You only need to specify the version name corresponding to <code>gcc-11</code> to quickly switch the entire gcc tool chain.</p>
- <h3 id="clang">Clang</h3>
- <p>In macOS and linux, usually xmake will try to automatically detect and use it first. Of course, we can also switch manually.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=clang -c
- $ xmake
- </code></pre>
- <p>On Windows, it will automatically load the msvc environment.</p>
- <p>In addition, we also support PortableBuildTools + clang environment:</p>
- <pre><code class="lang-console">$ xmake f -c --sdk=C:/BuildTools --toolchain=clang
- $ xmake -v
- [50%]: cache compiling.release src\main.cpp C:\Users\star\scoop\apps\llvm\current\bin\clang -c -Qunused-arguments -m64 --target=x86_64-windows-msvc -fexceptions -fcxx-exceptions -o build\.objs\test\windows\x64\release\src\main.cpp.obj src\main.cpp
- [75%]: linking.release test.exe C:\Users\star\scoop\apps\llvm\current\bin\clang++ -o build\windows\x64\release\test.exe build\.objs\test\windows\x64\release\src\main.cpp.obj -m64 --target=x86_64-windows-msvc
- [100%]: build ok, spent 0.235s
- </code></pre>
- <h3 id="clangcl">Clang-cl</h3>
- <p>If you simply switch to the clang-cl.exe compiler, and use msvc for the rest of the link operation, then we don't need to switch the entire tool chain, just cut the c/c++ compiler.</p>
- <pre><code class="lang-console">$ xmake f --cc=clang-cl --cxx=clang-cl -c
- $ xmake
- </code></pre>
- <p>Since xmake v2.7.2, there's also a dedicated clang-cl toolchain. The advantage of using the clang-cl toolchain over the msvc one is that on windows, the<br><code>--vs_toolset</code> option will be handled correctly.<br>You can use it by running:</p>
- <pre><code class="lang-console">$ xmake f --toolchain=clang-cl
- $ xmake
- </code></pre>
- <h3 id="llvm">LLVM</h3>
- <p>In addition to the independent clang compiler, if the user installs a complete llvm tool chain, we can also switch to it, including tools such as <code>llvm-ar</code>.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=llvm --sdk=/xxxx/llvm
- $ xmake
- </code></pre>
- <p>If it is a manually downloaded llvm sdk, we need to specify the llvm sdk root directory to ensure that xmake can find it. Of course, if the user has installed it in the PATH directory, the setting of the <code>--sdk</code> parameter is also optional.</p>
- <h3 id="cirle">Cirle</h3>
- <p>v2.5.9 xmake adds support for the circle compiler. This is a new C++20 compiler with some interesting compile-time meta-programming features. Those who are interested can check it out on the official website: <a href="https://www.circle-lang.org/">https://www.circle-lang.org/</a></p>
- <pre><code class="lang-console">$ xmake f --toolchain=circle
- $ xmake
- </code></pre>
- <h3 id="tinyc">Tinyc</h3>
- <p><a href="https://bellard.org/tcc/">Tiny C Compiler</a> is very lightweight. In some cases where you don’t want to install heavy-weight compilers such as msvc/llvm, you may use it to quickly compile some c code.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=tinycc
- $ xmake
- </code></pre>
- <p>When using it, please add the tinycc compiler to the PATH environment.</p>
- <p>We can also use the remote tool chain to automatically download and integrate it, and truly achieve one-click compilation on all platforms without any manual installation operations by users.</p>
- <pre><code class="lang-lua">add_requires("tinycc")
- target("test")
- set_kind("binary")
- add_files("src/*.c)
- set_toolchains("@tinycc")
- </code></pre>
- <h3 id="armccforkeilmdk">Armcc for Keil/MDK</h3>
- <p>v2.5.9 added toolchain support for armcc under Keil/MDK, see related issue: <a href="https://github.com/xmake-io/xmake/issues/1753">#1753</a></p>
- <pre><code class="lang-console">xmake f -p cross -a cortex-m3 --toolchain=armcc -c
- xmake
- </code></pre>
- <p>This toolchain is mainly used for embedded cross-compilation, so the <code>-p cross</code> cross-compilation platform is specified, and the cpu used by <code>-a cortex-m3</code> is specified, and the <code>-a/--arch</code> parameter is reused here.</p>
- <h3 id="armclangforkeilmdk">Armclang for Keil/MDK</h3>
- <p>v2.5.9 adds toolchain support for armclang under Keil/MDK. For related issues, see: <a href="https://github.com/xmake-io/xmake/issues/1753">#1753</a></p>
- <pre><code class="lang-console">xmake f -p cross -a cortex-m3 --toolchain=armclang -c
- xmake
- </code></pre>
- <p>This toolchain is mainly used for embedded cross-compilation, so the <code>-p cross</code> cross-compilation platform is specified, and the cpu used by <code>-a cortex-m3</code> is specified, and the <code>-a/--arch</code> parameter is reused here.</p>
- <h3 id="gnurm">GNU-RM</h3>
- <p>Another cross toolchain for embedded arm, official website: <a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm">https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm</a></p>
- <pre><code class="lang-console">$ xmake f --toolchain=gnu-rm -c
- $ xmake
- </code></pre>
- <h3 id="sdcc">SDCC</h3>
- <p>It is also an embedded arm compilation tool chain.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=sdcc -a stm8
- $ xmake
- </code></pre>
- <p>We can specify <code>-a stm8</code> to switch the cpu architecture, currently supported are:</p>
- <p>-stm8<br>-mcs51<br>-z80<br>-z180<br>-r2k<br>-r3ka<br>-s08<br>-hc08</p>
- <h3 id="mingw">Mingw</h3>
- <p>The mingw toolchain is very commonly used and is available on all platforms. We can just switch the relevant toolchain:</p>
- <pre><code class="lang-console">$ xmake f --toolchain=mingw -c
- $ xmake
- </code></pre>
- <p>However, in this way, the suffixes of some target files do not match exactly, so it is recommended to switch to the mingw platform for compilation and to support the download of dependent packages.</p>
- <pre><code class="lang-console">$ xmake f -p mingw -c
- $ xmake
- </code></pre>
- <p>xmake will automatically detect the location of the mingw toolchain by default, macOS and msys/mingw64 environments can usually be automatically detected, if detected, you can also manually specify the mingw sdk path.</p>
- <pre><code class="lang-console">$ xmake f -p mingw --mingw=/xxx/mingw -c
- $ xmake
- </code></pre>
- <p>Note that <code>--mingw</code> is used here instead of <code>--sdk</code>. In fact, both are ok, but the use of <code>--mingw</code> as a single parameter can better ensure that other cross-compilation toolchains do not conflict.</p>
- <h3 id="llvmmingw">LLVM-Mingw</h3>
- <p>This is actually a project independent of Mingw, the usage is completely the same as Mingw, but it is based on LLVM, and provides arm/arm64 and other more architecture support, not just i386/x86_64</p>
- <pre><code class="lang-console">$ xmake f -p mingw -a arm64 --mingw=/xxx/llvm-mingw -c
- $ xmake
- </code></pre>
- <p>If you want to use the arm/arm64 architecture of llvm-mingw, you need to specify the additional <code>-a arm64</code> parameter. In addition, the default xmake of llvm-mingw may not be able to detect it, and you need to set the sdk path additionally.</p>
- <h3 id="zig">Zig</h3>
- <p>If you want to build a Zig program, we can automatically use the zig tool chain by executing xmake by default, but the premise is that zig is already in the PATH environment.</p>
- <pre><code class="lang-console">$ xmake
- </code></pre>
- <p>Of course, we can also set it manually.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=zig -c
- $ xmake
- </code></pre>
- <p>You can also specify the path of the zig compiler.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=zig --zc=/xxxx/zig -c
- $ xmake
- </code></pre>
- <h4 id="zigcc">Zig CC</h4>
- <p>We can also use the <code>zig cc</code> compiler provided by zig to compile C/C++ code.</p>
- <pre><code class="lang-console">$ xmake f --cc="zig cc" --cxx="zig cc" --ld="zig c++" -c
- $ xmake
- </code></pre>
- <h4 id="crosscompilation">Cross compilation</h4>
- <p>In addition, we can also use zig to achieve cross-compilation.</p>
- <pre><code class="lang-console">$ xmake f -p cross --cross=riscv64-linux-musl --toolchain=zig
- $ xmake
- </code></pre>
- <p>Or compile the arm64 architecture:</p>
- <pre><code class="lang-console">$ xmake f --toolchain=zig -a arm64 -c
- $ xmake
- </code></pre>
- <h3 id="emccwasm">Emcc (WASM)</h3>
- <p>If you want to compile the wasm program, we only need to switch to the wasm platform, and the emcc tool chain will be used to compile by default.</p>
- <pre><code class="lang-console">$ xmake f -p wasm
- $ xmake
- </code></pre>
- <h3 id="wasiwasm">Wasi (WASM)</h3>
- <p>This is another Wasm toolchain with WASI enabled, and we need to switch it manually.</p>
- <pre><code class="lang-console">$ xmake f -p wasm --toolchain=wasi
- $ xmake
- </code></pre>
- <h3 id="iccintelcccompiler">Icc (Intel C/C++ Compiler)</h3>
- <p>We can also switch to Intel's C/C++ compiler to use.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=icc -c
- $ xmake
- </code></pre>
- <h3 id="ifortintelfortaincompiler">Ifort (Intel Fortain Compiler)</h3>
- <p>We can also switch to Intel's Fortran compiler to use.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=ifort -c
- $ xmake
- </code></pre>
- <h3 id="gfortran">gfortran</h3>
- <p>In addition to Intel's Fortran compiler, we also have the gnu fortran compiler available.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=gfortran -c
- $ xmake
- </code></pre>
- <h3 id="fpcfreepascal">fpc (Free Pascal)</h3>
- <p>For pascal programs, xmake will use the fpc compiler to compile by default.</p>
- <pre><code class="lang-console">$ xmake
- </code></pre>
- <p>Of course, we can also switch manually.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=fpc -c
- $ xmake
- </code></pre>
- <h3 id="dlang">Dlang</h3>
- <p>For dlang programs, xmake will use the dmd compiler to compile by default.</p>
- <pre><code class="lang-console">$ xmake
- </code></pre>
- <p>Of course, we can also switch manually.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=dlang -c
- $ xmake
- </code></pre>
- <p>It should be noted that the dlang toolchain here actually includes automatic detection and switching of <code>dmd</code>, <code>ldc2</code> and <code>gdc</code>.</p>
- <h3 id="cuda">Cuda</h3>
- <p>For Cuda programs, we need to manually switch to the cuda tool chain.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=cuda -c
- $ xmake
- </code></pre>
- <p>We can also manually switch the C/C++ compiler called internally by nvcc.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=cuda --cu-ccbin=clang -c
- $ xmake
- </code></pre>
- <h3 id="assembler">Assembler</h3>
- <p>Regarding the independent assembler tool chain, xmake supports three: yasm, nasm, and fasm, which can be switched at will. If not set, the assembler that comes with gcc/clang/msvc will be used by default.</p>
- <pre><code class="lang-console">$ xmake f --toolchain=nasm -c
- $ xmake
- </code></pre>
- <p>You can also specify the assembler path separately</p>
- <pre><code class="lang-console">$ xmake f --toolchain=nasm --as=/xxx/nasm -c
- $ xmake
- </code></pre>
- <h3 id="go">Go</h3>
- <p>The golang compiler tool chain is automatically enabled when compiling go programs by default.</p>
- <pre><code class="lang-console">$ xmake
- </code></pre>
- <h3 id="rust">Rust</h3>
- <p>The rust compiler tool chain is automatically enabled when the rust program is compiled by default.</p>
- <pre><code class="lang-console">$ xmake
- </code></pre>
- <p>At present, the rust toolchain can also support cross-compilation environments such as android.</p>
- <pre><code class="lang-console">$ xmake f -p android --ndk=~/android-ndk-r20b -c
- $ xmake
- </code></pre>
- <h3 id="ndk">NDK</h3>
- <p>Android's NDK compilation tool chain, as long as the android platform is enabled, it will be enabled by default.</p>
- <pre><code class="lang-console">$ xmake f -p android --ndk=~/android-ndk-r20b -c
- $ xmake
- </code></pre>
- <p>If the <code>--ndk</code> parameter is not specified, xmake will also detect it from the AndroidSDK/ndk-bundle directory and environment variables such as <code>$ANDROID_NDK_HOME</code>, <code>ANDROID_NDK_ROOT</code>, etc. by default.</p>
- <p>In addition, we can also set the global <code>xmake g --ndk=</code> configuration to avoid repeated settings each time.</p>
- </article>
- </body>
- </html>
|