https://github.com/ceph/ceph/pull/66924

The patch is adjusted so that it can be applied to all ebuilds in the tree.

From d5a8eaeb862d1840de8d82f6e958c1f609693ed8 Mon Sep 17 00:00:00 2001
From: "Z. Liu" <zhixu.liu@gmail.com>
Date: Sat, 17 Jan 2026 20:59:09 +0800
Subject: [PATCH] common: add dependency on legacy-option-headers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A heap_profiler build failure was initially observed due to parallel
build ordering. During parallel builds, src/perfglue/heap_profiler.cc
may fail to compile because it depends on legacy-option-headers and the
generated header global_legacy_options.h may not be available yet. This
results in incomplete definitions in included headers, leading to
compilation errors such as missing members in ConfigValues.

For example, the following error is observed when building with "-j64":

FAILED: [code=1] src/perfglue/CMakeFiles/heap_profiler.dir/heap_profiler.cc.o
/var/tmp/portage/sys-cluster/ceph-20.1.0-r2/work/ceph-20.1.0/src/perfglue/heap_profiler.cc: In function ‘void get_profile_name(char*, int)’:
src/perfglue/heap_profiler.cc:102:48: error: ‘class ConfigValues’ has no member named ‘log_file’
  snprintf(path, sizeof(path), "%s", g_conf()->log_file.c_str());
                                               ^~~~~~~~

The dependency chain is as follows:

src/perfglue/heap_profiler.cc
 -> src/perfglue/heap_profiler.h
 -> src/common/config.h
 -> src/common/config_values.h
 -> src/common/options/legacy_config_opts.h
 -> global_legacy_options.h (generated by y2c.py)

The issue can be reliably reproduced by adding time.sleep(3600) at the
beginning of y2c.py.

Further testing showed that heap_profiler is not the only affected
consumer. Additional analysis indicates that common is a shared
dependency of all affected components. Therefore, it is appropriate to
add legacy-option-headers as a dependency of common to ensure correct
build ordering under parallel builds.

Signed-off-by: Z. Liu <zhixu.liu@gmail.com>

diff --git a/src/common/options/CMakeLists.txt b/src/common/options/CMakeLists.txt
index 60cdbc3f224..4879c10d813 100644
--- a/src/common/options/CMakeLists.txt
+++ b/src/common/options/CMakeLists.txt
@@ -112,3 +112,7 @@ target_sources(legacy-option-headers
 include(AddCephTest)
 add_ceph_test(validate-options
   ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/validate-options.py ${options_yamls})
+
+add_dependencies(common-options-objs
+  legacy-option-headers
+)
