base: Add a M5_PUBLIC and M5_LOCAL attribute macro
authorAndreas Sandberg <andreas.sandberg@arm.com>
Wed, 2 May 2018 14:34:24 +0000 (15:34 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 29 Jun 2018 08:50:42 +0000 (08:50 +0000)
There are cases where we need to limit the symbol visibility to avoid
compilation errors. This is a problem for Python code that relies on
PyBind11 since recent versions enforce hidden symbols. As a
consequence, classes that have member variables from PyBind11 need to
be declared with the hidden attribute (or gem5 needs to be compiled
with -fvisibility=hidden).

Change-Id: I30e582fde494ff61ab7a596a595efc26a2952a5f
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/11513
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/base/compiler.hh

index 4765adc367f2fb24528a527ada7f6e2383402d14..35156ee67491cd014c8478f7a68cbae8f8fe523f 100644 (file)
@@ -56,6 +56,8 @@
 #  define M5_DEPRECATED __attribute__((deprecated))
 #  define M5_DEPRECATED_MSG(MSG) __attribute__((deprecated(MSG)))
 #  define M5_UNREACHABLE __builtin_unreachable()
+#  define M5_PUBLIC __attribute__ ((visibility ("default")))
+#  define M5_LOCAL __attribute__ ((visibility ("hidden")))
 #endif
 
 #if defined(__clang__)