From f4b1ad43d4e701538e60c5640032117c353577e2 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sat, 22 Jun 2024 00:13:04 +0300 Subject: [PATCH] gdb: protect debug::the_database from lto Clang 18.1 with lto gained the ability to eliminate dead stores. Since debug::the_database is write-only as far as the compiler understands (it is read only by gdb), all writes to it are eliminated. Protect writes to the variable by marking it volatile. Closes scylladb/scylladb#22454 --- debug.cc | 2 +- debug.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debug.cc b/debug.cc index fac4aec30f..ad1f5f29c2 100644 --- a/debug.cc +++ b/debug.cc @@ -10,6 +10,6 @@ namespace debug { -seastar::sharded* the_database = nullptr; +seastar::sharded* volatile the_database = nullptr; } diff --git a/debug.hh b/debug.hh index b0874e1959..39f9ff84eb 100644 --- a/debug.hh +++ b/debug.hh @@ -16,7 +16,7 @@ class database; namespace debug { -extern seastar::sharded* the_database; +extern seastar::sharded* volatile the_database; }