Merge branch 'compiler-option' into 'master'

cookbook: Define compiler options

See merge request redox-os/redox!2344
This commit is contained in:
Jeremy Soller 2026-09-11 14:54:24 -06:00
commit 9f51053fd7
4 changed files with 35 additions and 0 deletions

View File

@ -9,6 +9,7 @@ dependencies = [
"mpc",
"zlib"
]
compiler = "gcc-no-lto"
script = """
DYNAMIC_INIT
COOKBOOK_CONFIGURE="${COOKBOOK_SOURCE}/libatomic/configure"

View File

@ -8,6 +8,7 @@ patches = ["redox.patch"]
dev-dependencies = [
"host:libicu"
]
compiler = "no-lto"
template = "custom"
script = """
DYNAMIC_INIT

View File

@ -7,6 +7,7 @@ use crate::config::CookConfig;
use crate::cook::fetch_repo;
use crate::cook::package::{package_source_paths, package_target};
use crate::cook::{fetch, fs, pty::PtyOut, script::*};
use crate::recipe::BuildCompiler;
use crate::recipe::{AutoDeps, BuildKind, CookRecipe, OptionalPackageRecipe, Recipe};
use std::io::Read;
use std::{
@ -464,6 +465,23 @@ pub fn build(
} else if name.is_host() {
command.env("COOKBOOK_TOOLCHAIN", &cookbook_sysroot);
}
if let Some(compiler) = recipe.build.compiler.as_ref() {
match compiler {
BuildCompiler::Gcc | BuildCompiler::GccNoLTO => {
command.env("REDOXER_USE_CLANG", "0");
}
BuildCompiler::Clang | BuildCompiler::ClangNoLTO => {
command.env("REDOXER_USE_CLANG", "1");
}
_ => {}
}
match compiler {
BuildCompiler::ClangNoLTO | BuildCompiler::GccNoLTO | BuildCompiler::NoLTO => {
command.env("REDOXER_USE_LTO", "0");
}
_ => {}
}
};
command.env("COOKBOOK_MAKE_JOBS", cli_jobs.to_string());
if cook_config.verbose_cmd {
command.env("COOKBOOK_VERBOSE", "1");

View File

@ -142,6 +142,7 @@ pub struct BuildRecipe {
#[serde(flatten)]
pub kind: BuildKind,
pub dependencies: Vec<PackageName>,
pub compiler: Option<BuildCompiler>,
#[serde(rename = "dev-dependencies")]
pub dev_dependencies: Vec<PackageName>,
}
@ -177,6 +178,20 @@ pub struct Recipe {
pub optional_packages: Vec<OptionalPackageRecipe>,
}
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
pub enum BuildCompiler {
#[serde(rename = "gcc")]
Gcc,
#[serde(rename = "clang")]
Clang,
#[serde(rename = "gcc-no-lto")]
GccNoLTO,
#[serde(rename = "clang-no-lto")]
ClangNoLTO,
#[serde(rename = "no-lto")]
NoLTO,
}
impl BuildRecipe {
pub fn new(kind: BuildKind) -> Self {
let mut build = Self::default();