Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions crates/pixi-build-mojo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,7 @@ impl GenerateRecipe for MojoGenerator {
// rattler-build selectors with simple string comparison.
let model_dependencies = model.dependencies(Some(host_platform));

// Get the list of compilers from config, defaulting to ["mojo"] if not specified
let mut compilers = config
.compilers
.clone()
.unwrap_or_else(|| vec!["mojo".to_string()]);

// Handle mojo compiler specially if it's in the list
if let Some(idx) = compilers.iter().position(|name| name == "mojo") {
let mojo_compiler_pkg = "mojo-compiler";
// All of these packages also contain the mojo compiler and maintain backward compat.
// They should be removable at a future point.
let alt_names = ["max", "mojo", "modular"];

let mojo_pkg_name = pixi_build_types::SourcePackageName::from(mojo_compiler_pkg);
if !model_dependencies.build.contains_key(&mojo_pkg_name)
&& !alt_names.iter().any(|alt| {
model_dependencies
.build
.contains_key(&pixi_build_types::SourcePackageName::from(*alt))
})
{
requirements
.build
.push(mojo_compiler_pkg.parse().into_diagnostic()?);
}

// Remove the mojo compiler from the list of compilers.
compilers.swap_remove(idx);
}
let compilers = config.compilers.clone().unwrap_or_default();

pixi_build_backend::compilers::add_compilers_to_requirements(
&compilers,
Expand Down Expand Up @@ -451,7 +423,7 @@ mod tests {
.generate_recipe(
&project_model,
&MojoBackendConfig {
compilers: Some(vec!["mojo".to_string(), "c".to_string(), "cxx".to_string()]),
compilers: Some(vec!["c".to_string(), "cxx".to_string()]),
..Default::default()
},
temp.path().to_path_buf(),
Expand All @@ -465,12 +437,6 @@ mod tests {
// Check that we have both the mojo-compiler package and the additional compilers
let build_reqs = &generated_recipe.recipe.requirements.build;

// Check for mojo-compiler package (should be present)
let has_mojo_compiler = build_reqs
.iter()
.any(|item| format!("{item:?}").contains("mojo-compiler"));
assert!(has_mojo_compiler, "Should have mojo-compiler package");

// Check for additional compiler templates
let compiler_templates: Vec<String> = build_reqs
.iter()
Expand Down Expand Up @@ -544,15 +510,6 @@ mod tests {
// Check that we have only the mojo-compiler package by default
let build_reqs = &generated_recipe.recipe.requirements.build;

// Check for mojo-compiler package (should be present by default)
let has_mojo_compiler = build_reqs
.iter()
.any(|item| format!("{item:?}").contains("mojo-compiler"));
assert!(
has_mojo_compiler,
"Should have mojo-compiler package by default"
);

// Check that no additional compiler templates are present
let compiler_templates: Vec<String> = build_reqs
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ build:
number: ~
script: "[ ... script ... ]"
requirements:
build:
- mojo-compiler
build: []
host: []
run:
- boltons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ build:
env: {}
secrets: []
requirements:
build:
- mojo-compiler
build: []
host: []
run:
- boltons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ build:
env: {}
secrets: []
requirements:
build:
- mojo-compiler
build: []
host: []
run:
- boltons
Expand Down
17 changes: 6 additions & 11 deletions docs/backends/pixi-build-mojo.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The auto-derive feature supports various common project layouts:

### Required Dependencies

- `max` package for both the compiler and linked runtime
- `mojo` / `mojo-compiler` package for both the compiler and linked runtime

## Configuration Options

Expand Down Expand Up @@ -177,32 +177,27 @@ extra-input-globs = ["**/*.c", "assets/**/*", "*.md"]
### `compilers`

- **Type**: `Array<String>`
- **Default**: `["mojo"]`
- **Default**: `[]`
- **Target Merge Behavior**: `Overwrite` - Platform-specific compilers completely replace base compilers

List of compilers to use for the build. The mojo compiler is handled specially and uses the `mojo-compiler` package, while other compilers use conda-forge's standard compiler infrastructure.
List of compilers to use for the build. Compilers use conda-forge's standard compiler infrastructure.

```toml
[package.build.config]
compilers = ["mojo", "c", "cxx"]
compilers = ["c", "cxx"]
```

For target-specific configuration, platform compilers completely replace the base configuration:

```toml
[package.build.config]
compilers = ["mojo"]
compilers = []

[package.build.target.linux-64.config]
compilers = ["mojo", "c", "cuda"]
compilers = ["c", "cuda"]
# Result for linux-64: ["mojo", "c", "cuda"]
```

**Special mojo compiler behavior:**
- When `mojo` is included in the compilers list, the backend automatically adds the `mojo-compiler` package to build requirements
- You can opt out of the mojo compiler entirely by specifying a list without `"mojo"`, e.g., `compilers = ["c", "cxx"]`
- The mojo compiler does not use the standard conda-forge compiler template system like other compilers

!!! info "Comprehensive Compiler Documentation"
For detailed information about available compilers, platform-specific behavior, and how conda-forge compilers work, see the [Compilers Documentation](../key_concepts/compilers.md). Note that the mojo compiler has special behavior as described above.

Expand Down
8 changes: 1 addition & 7 deletions docs/key_concepts/compilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ The table below lists the core compilers, specialized compilers, and some backen
|----------|-------------|-----------|
| `cuda` | NVIDIA CUDA compiler | Linux, Windows, (limited macOS) |

### Backend-Specific Compilers

| Compiler | Description | Backend | Special Behavior |
|----------|-------------|---------|------------------|
| `mojo` | Mojo compiler | pixi-build-mojo | Uses `mojo-compiler` package instead of template |

## Backend-Specific Defaults

Only certain `pixi-build` backends support the `compilers` configuration option. Each supporting backend has sensible defaults based on the typical requirements for that language ecosystem:
Expand All @@ -148,7 +142,7 @@ Only certain `pixi-build` backends support the `compilers` configuration option.
| **[pixi-build-cmake](../backends/pixi-build-cmake.md#compilers)** | ✅ **Supported** | `["cxx"]` | Most CMake projects are C++ |
| **[pixi-build-rust](../backends/pixi-build-rust.md#compilers)** | ✅ **Supported** | `["rust"]` | Rust projects need the Rust compiler |
| **[pixi-build-python](../backends/pixi-build-python.md#compilers)** | ✅ **Supported** | `[]` | Pure Python packages typically don't need compilers |
| **[pixi-build-mojo](../backends/pixi-build-mojo.md#compilers)** | ✅ **Supported** | `["mojo"]` | Mojo projects need the Mojo compiler |
| **[pixi-build-mojo](../backends/pixi-build-mojo.md#compilers)** | ✅ **Supported** | `[]` | `mojo-compiler` must be specified in the `package.*-dependencies` manually. |
| **pixi-build-rattler-build** | ❌ **Not Supported** | N/A | Uses direct `recipe.yaml` - configure compilers directly in recipe |

!!! info "Adding Compiler Support to Other Backends"
Expand Down
Loading