Mojo is now open source
Mojo is now open source
Mojo 现已开源
August 18, 2026. We are happy to announce that the Mojo🔥 language is now fully open source under the Apache 2.0 license (with LLVM exceptions)! The source code for the Mojo compiler, tooling, and everything else you need to build the language are now available in our modular GitHub repository.
2026 年 8 月 18 日。我们很高兴地宣布,Mojo🔥 语言现已在 Apache 2.0 许可证(包含 LLVM 例外条款)下完全开源!Mojo 编译器、工具链以及构建该语言所需的一切源代码,现已在我们的 Modular GitHub 仓库中提供。
The Mojo language is a bold bet: a novel general purpose programming language that goes further than older ones. Mojo integrates the latest in compiler and programming language research to unlock GPUs, AI accelerators, and other advanced compute. For the last four years, Mojo has been developed with an open community, but a closed compiler. Last week Mojo hit 1.0 (with source stability), and today we’re excited to open source the entire compiler and toolchain.
Mojo 语言是一次大胆的尝试:它是一种超越了传统语言的新型通用编程语言。Mojo 集成了编译器和编程语言领域的最新研究成果,旨在充分释放 GPU、AI 加速器及其他先进计算设备的潜能。在过去四年中,Mojo 一直在开放社区的参与下进行开发,但编译器此前处于闭源状态。上周,Mojo 发布了 1.0 版本(实现了源码稳定性),今天我们非常激动地将整个编译器和工具链开源。
Apache 2: A permissive license
Apache 2:一种宽松的许可证
The Apache 2.0 license is the gold standard for programming languages and compilers, because it provides great flexibility to be used in all sorts of applications. The LLVM extensions to the license further expand those freedoms for building and distributing binaries compiled from Mojo. We want you to be able to adopt and use Mojo in as many applications as you can imagine.
Apache 2.0 许可证是编程语言和编译器的黄金标准,因为它为各种应用程序的使用提供了极大的灵活性。该许可证的 LLVM 扩展进一步扩大了构建和分发由 Mojo 编译的二进制文件的自由度。我们希望您能够在尽可能多的应用场景中采用并使用 Mojo。
Our open source approach has been deliberate: we’ve found that small and tight-knit design teams (not committees) are the best for finding the “soul” of a language, but that feedback from a broader community is essential to escape an echo chamber. As such, we first open-sourced the Mojo standard library, then released hundreds of thousands of lines of kernel code written in Mojo, tools, and support. We built together with community feedback and public design proposals, and are now open sourcing the compiler. We will continue to open our processes further as Mojo keeps maturing.
我们的开源策略是经过深思熟虑的:我们发现,小型且紧密的团队(而非委员会)最能发掘一门语言的“灵魂”,但来自更广泛社区的反馈对于打破“回声壁效应”至关重要。因此,我们首先开源了 Mojo 标准库,随后发布了数十万行用 Mojo 编写的内核代码、工具和支持组件。我们通过社区反馈和公开的设计提案共同构建了这一切,现在我们正式开源了编译器。随着 Mojo 的不断成熟,我们将继续进一步开放我们的流程。
How to get and build the compiler
如何获取并构建编译器
All code for the Mojo language is now available at the main modular GitHub repository. First, clone that repository locally:
git clone https://github.com/modular/modular.git
cd modular
Mojo 语言的所有代码现已在主要的 Modular GitHub 仓库中提供。首先,将该仓库克隆到本地:
git clone https://github.com/modular/modular.git
cd modular
Then, to build the Mojo compiler from source and run it against a Mojo file you can use a single build command:
./bazelw run --config=build-mojo KGEN:mojo -- run hello.mojo
然后,要从源码构建 Mojo 编译器并运行 Mojo 文件,您可以使用一条构建命令:
./bazelw run --config=build-mojo KGEN:mojo -- run hello.mojo
At Modular, we use Bazel to manage the complex build processes and caching for Mojo and MAX. This one command will download or build everything needed to build the Mojo compiler and the Mojo standard library. The flag --config=build-mojo tells the build system to compile everything from scratch, using the source code on your local system.
在 Modular,我们使用 Bazel 来管理 Mojo 和 MAX 的复杂构建过程及缓存。这条命令将下载或构建构建 Mojo 编译器和 Mojo 标准库所需的一切。--config=build-mojo 标志告诉构建系统使用您本地系统上的源代码从零开始编译所有内容。
This extends to working with the Mojo standard library, where you can modify the compiler or library code and run the full suite of tests via:
./bazelw test --config=build-mojo mojo/stdlib/test/...
这也适用于 Mojo 标准库的开发,您可以修改编译器或库代码,并通过以下命令运行全套测试:
./bazelw test --config=build-mojo mojo/stdlib/test/...
If you aren’t working on the compiler itself, you can use the flag --config=prebuilt-mojo and the build system will download the latest nightly binary distribution of the compiler, saving you some compilation time. Note that a prebuilt Mojo compiler is still necessary today if you are customizing MAX kernels or models.
如果您不需要修改编译器本身,可以使用 --config=prebuilt-mojo 标志,构建系统将下载最新的编译器每日构建二进制版本,从而节省编译时间。请注意,如果您正在自定义 MAX 内核或模型,目前仍需要使用预构建的 Mojo 编译器。
Contributions
贡献
The Mojo standard library has been accepting contributions since 2024, and we’re grateful for everyone that has helped advance the language. One learning (particularly in today’s era of AI coding) is that we need to be deliberate about how we handle contributions. As such, we aren’t ready to take contributions to the compiler and tooling. We aim to accept contributions to the compiler and tooling by the end of this year, and we’ll share more details when we can.
Mojo 标准库自 2024 年起就开始接受贡献,我们非常感谢每一位帮助推动该语言发展的人。我们学到的一点经验(特别是在当今 AI 编程时代)是,我们需要谨慎对待贡献的处理方式。因此,我们目前尚未准备好接受对编译器和工具链的贡献。我们的目标是在今年年底前开始接受相关贡献,届时我们将分享更多细节。
To ask any questions about the Mojo compiler source as you read through it, or to share what you’re working on, please join our forum. Clone the source code and let us know what you’re building with the Mojo language. We’re excited to open Mojo up to the world and see how it grows!
如果您在阅读 Mojo 编译器源码时有任何疑问,或者想分享您的工作成果,请加入我们的论坛。欢迎克隆源代码,并让我们知道您正在用 Mojo 语言构建什么。我们很高兴能将 Mojo 向世界开放,并期待见证它的成长!