Mojo🔥 现已开源!
Modular 团队
公司
我们很高兴地宣布,Mojo🔥 语言现已根据 Apache 2.0 许可证(含 LLVM 例外条款)完全开源!Mojo 编译器、工具链以及构建该语言所需的一切源代码,现已在我们的 modular GitHub 仓库中提供。
Mojo 语言是一场大胆的押注:一种比旧语言走得更远的新型通用编程语言。Mojo 整合了编译器与编程语言研究的最新成果,以解锁 GPU、AI 加速器及其他先进算力。过去四年,Mojo 一直以开放社区、封闭编译器的方式开发。上周 Mojo 达到 1.0 版本(实现源码稳定性),而今天我们激动地宣布,将整个编译器与工具链全部开源。
Apache 2:一种宽松许可证
Apache 2.0 许可证是编程语言和编译器的黄金标准,因为它提供了极大的灵活性,可用于各类应用。该许可证的 LLVM 扩展条款进一步扩大了这些自由,允许构建和分发由 Mojo 编译出的二进制文件。我们希望你能在所能想象的尽可能多的应用场景中采用和使用 Mojo。
我们的开源策略是经过深思熟虑的:我们发现,小而紧密的设计团队(而非委员会)最适合找到一门语言的“灵魂”,但更广泛社区的反馈对于避免回声室效应至关重要。因此,我们首先开源了 Mojo 标准库,随后发布了数十万行用 Mojo 编写的内核代码、工具和支持内容。我们与社区反馈和公开设计提案共同构建,现在开源编译器。随着 Mojo 不断成熟,我们将继续进一步开放我们的流程。
如何获取并构建编译器
Mojo 语言的所有代码现已在主 modular GitHub 仓库中提供。首先,将该仓库克隆到本地:
git clone https://github.com/modular/modular.git
cd modular 然后,要从源码构建 Mojo 编译器并针对 Mojo 文件运行它,你可以使用一条构建命令:
./bazelw run --config=build-mojo KGEN:mojo -- run hello.mojo 在 Modular,我们使用 Bazel 来管理 Mojo 和 MAX 复杂的构建流程与缓存。这一条命令就能下载或构建出编译 Mojo 编译器及 Mojo 标准库所需的全部内容。`--config=build-mojo` 这个标志会告诉构建系统,使用你本地系统上的源代码从头编译所有内容。
这也适用于 Mojo 标准库的开发——你可以修改编译器或库代码,并通过以下命令运行完整的测试套件:
./bazelw test --config=build-mojo mojo/stdlib/test/... 如果你不直接开发编译器本身,可以使用 `--config=prebuilt-mojo` 标志,构建系统会下载最新的编译器夜间二进制发行版,为你节省一些编译时间。请注意,如果你要定制 MAX 内核或模型,目前仍然需要一个预构建的 Mojo 编译器。
贡献
Mojo 标准库自 2024 年起就开始接受外部贡献,我们非常感谢每一位帮助推动这门语言发展的人。我们学到的一点(尤其是在当今 AI 编程的时代)是,我们需要审慎地处理贡献。因此,我们目前还不准备接受对编译器和工具链的贡献。我们的目标是在今年年底前开始接受对编译器和工具链的贡献,届时我们会分享更多细节。
如果你在阅读 Mojo 编译器源码时有任何疑问,或者想分享你正在做的工作,欢迎加入我们的论坛。克隆源代码,告诉我们你正在用 Mojo 语言构建什么。我们非常期待将 Mojo 向世界开放,并见证它的成长!
从 Modular 了解更多
查看所有博客
与 Modular 一起构建 AI 的未来
立即开始——免费
查看版本

立即注册
立即注册我们的云平台,轻松上手。

浏览开放模型
浏览我们的模型目录,或部署你自己的自定义模型
浏览模型
Mojo🔥 is now open source!
Modular Team
Company
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.
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.
Apache 2: A permissive license
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.
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.
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 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 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.
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/... 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.
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.
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!
Read more from Modular
View all blogs
Build the future of AI with Modular
Get started - FREE
View Editions

Sign up today
Signup to our Cloud Platform today to get started easily.

Browse open models
Browse our model catalog, or deploy your own custom model
Browse models