From 93b01400753fc97e1c6529f0e9ad67a0ad2653f4 Mon Sep 17 00:00:00 2001
From: Matt Jolly <kangie@gentoo.org>
Date: Sat, 13 Jun 2026 18:18:55 +1000
Subject: [PATCH] modules: Only set --sysroot if sysroot is set

This enables downstream distro builds that don't use the sysroot to
evaluate the file without GN getting upset.

Signed-off-by: Matt Jolly <kangie@gentoo.org>
--- a/build/modules/BUILD.gn
+++ b/build/modules/BUILD.gn
@@ -230,10 +230,12 @@ if (use_unified_system_module) {
     } else {
       # We need to pass the sysroot in so that it can scan it to generate a
       # modulemap for the sysroot headers.
-      args += [
-        "--sysroot",
-        rebase_path(sysroot, root_build_dir),
-      ]
+      if (defined(sysroot) && sysroot != "") {
+        args += [
+          "--sysroot",
+          rebase_path(sysroot, root_build_dir),
+        ]
+      }
     }
     args += [
       "--",
-- 
2.54.0

