[COMMIT osv master] musl: partially hide "hidden" macro that confuses Boost

1 view
Skip to first unread message

Commit Bot

unread,
Mar 17, 2024, 6:14:52 AMMar 17
to osv...@googlegroups.com, Nadav Har'El
From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

musl: partially hide "hidden" macro that confuses Boost

This patch fixes a build error when trying build OSv on a modern distro
(namely, Fedora 39) with Boost 1.81.

In the new Boost, they started to use the name "hidden" for some
constant variable as well as a namespace. The problem is that Musl
has a *macro* hidden in include/glibc-compat/feature.hh - see
commit af2d371.

An ideal fix would have been to rename Musl's macro, or use it (via
a "-D" option) just when building Musl source files, not files in core/.
But both of these solutions would require fairly elaborate changes.

So instead, in this patch we take a simpler workaround - there are just two
source files where we include a Musl header file which adds the "hidden"
macro and then a Boost header file which uses the "hidden" name. Just
in these two files, we "#undef" the macro "hidden" after including the
Musl header file and before including the Boost one.

After this fix, the OSv kernel mostly compiles on Fedora 39, but
fails linking due to other problems that will need to be fixed
separately.

Refs #1301

Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/core/mempool.cc b/core/mempool.cc
--- a/core/mempool.cc
+++ b/core/mempool.cc
@@ -31,11 +31,15 @@
#include <osv/shrinker.h>
#include <osv/defer.hh>
#include <osv/dbg-alloc.hh>
+#include <osv/migration-lock.hh>
+#include <osv/export.h>
+
+// recent Boost gets confused by the "hidden" macro we add in some Musl
+// header files, so need to undefine it
+#undef hidden
#include <boost/dynamic_bitset.hpp>
#include <boost/lockfree/stack.hpp>
#include <boost/lockfree/policies.hpp>
-#include <osv/migration-lock.hh>
-#include <osv/export.h>

TRACEPOINT(trace_memory_malloc, "buf=%p, len=%d, align=%d", void *, size_t,
size_t);
diff --git a/include/osv/callstack.hh b/include/osv/callstack.hh
--- a/include/osv/callstack.hh
+++ b/include/osv/callstack.hh
@@ -8,13 +8,16 @@
#ifndef CALLSTACK_HH_
#define CALLSTACK_HH_

-#include <boost/intrusive/unordered_set.hpp>
#include <osv/trace.hh>
#include <osv/percpu.hh>
#include <memory>
#include <atomic>
#include <stdlib.h>
#include <set>
+// recent Boost gets confused by the "hidden" macro we add in some Musl
+// header files, so need to undefine it
+#undef hidden
+#include <boost/intrusive/unordered_set.hpp>

// An object that instruments tracepoints to collect backtraces.
//
Reply all
Reply to author
Forward
0 new messages