From 13e27eb8cd363012daf3577678179848ef68e822 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 11 Sep 2026 03:29:04 +0700 Subject: [PATCH] cookbook: Define compiler options --- recipes/libs/libatomic/recipe.toml | 1 + recipes/wip/libs/other/libicu/recipe.toml | 1 + src/cook/cook_build.rs | 18 ++++++++++++++++++ src/recipe.rs | 15 +++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/recipes/libs/libatomic/recipe.toml b/recipes/libs/libatomic/recipe.toml index e6f08a2e2..ece7d8d08 100644 --- a/recipes/libs/libatomic/recipe.toml +++ b/recipes/libs/libatomic/recipe.toml @@ -9,6 +9,7 @@ dependencies = [ "mpc", "zlib" ] +compiler = "gcc-no-lto" script = """ DYNAMIC_INIT COOKBOOK_CONFIGURE="${COOKBOOK_SOURCE}/libatomic/configure" diff --git a/recipes/wip/libs/other/libicu/recipe.toml b/recipes/wip/libs/other/libicu/recipe.toml index 87f7c09fb..5cef02e38 100644 --- a/recipes/wip/libs/other/libicu/recipe.toml +++ b/recipes/wip/libs/other/libicu/recipe.toml @@ -8,6 +8,7 @@ patches = ["redox.patch"] dev-dependencies = [ "host:libicu" ] +compiler = "no-lto" template = "custom" script = """ DYNAMIC_INIT diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index a820aebe8..909bdcaff 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -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"); diff --git a/src/recipe.rs b/src/recipe.rs index 59a2ee9e3..da56d0ebb 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -142,6 +142,7 @@ pub struct BuildRecipe { #[serde(flatten)] pub kind: BuildKind, pub dependencies: Vec, + pub compiler: Option, #[serde(rename = "dev-dependencies")] pub dev_dependencies: Vec, } @@ -177,6 +178,20 @@ pub struct Recipe { pub optional_packages: Vec, } +#[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();