[sim] Fix linkage errors in Clang.
Commit Message
Hello.
By differences about inline function, we can't build simulators on Clang.
I have write after approval permission. Ok to apply this?
>From 4c2093a1765fdf626335d3f3479bd076627bdb3b Mon Sep 17 00:00:00 2001
From: Masaki Muranaka <monaka@monami-software.com>
Date: Wed, 14 May 2014 11:17:12 +0900
Subject: [PATCH] Fix linkage errors in Clang
* common/cgen-mem.h: Fix linkage errors in Clang
* common/cgen-ops.h: Ditto.
* common/sim-arange.h: Ditto.
---
sim/ChangeLog | 6 ++++++
sim/common/cgen-mem.h | 4 +++-
sim/common/cgen-ops.h | 7 ++++++-
sim/common/sim-arange.h | 7 ++++++-
4 files changed, 21 insertions(+), 3 deletions(-)
Comments
On 05/14/2014 03:31 AM, Masaki Muranaka wrote:
> Hello.
>
> By differences about inline function, we can't build simulators on Clang.
The difference is probably that Clang defaults to C99.
You should probably be using CC="clang -std=gnu89".
Patchwise, please try using __attribute__ ((gnu_inline)).
On Fri 30 May 2014 12:09:49 Pedro Alves wrote:
> On 05/14/2014 03:31 AM, Masaki Muranaka wrote:
> > By differences about inline function, we can't build simulators on Clang.
>
> The difference is probably that Clang defaults to C99.
> You should probably be using CC="clang -std=gnu89".
>
> Patchwise, please try using __attribute__ ((gnu_inline)).
yeah i'm not a fan of sprinkling __clang__ everywhere. i'm aware that there's
a bunch of __GNUC__ in there, but those should get cleaned up/centralized
rather than expanded. a quick glance shows that there's already cases where
that can happen (like moving to ATTRIBUTE_NORETURN).
-mike
@@ -1,3 +1,9 @@
+2014-05-14 Muranaka Masaki <monaka@monami-software.com>
+
+ * common/cgen-mem.h: Fix linkage errors in Clang
+ * common/cgen-ops.h: Ditto.
+ * common/sim-arange.h: Ditto.
+
2014-03-12 Nick Clifton <nickc@redhat.com>
* MAINTAINERS: Add myself as the maintainer for the MSP430.
@@ -20,7 +20,9 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef CGEN_MEM_H
#define CGEN_MEM_H
-#ifdef MEMOPS_DEFINE_INLINE
+#if defined (__clang__)
+#define MEMOPS_INLINE static inline
+#elif defined (MEMOPS_DEFINE_INLINE)
#define MEMOPS_INLINE
#else
#define MEMOPS_INLINE extern inline
@@ -24,7 +24,12 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>.
#include <assert.h>
-#if defined (__GNUC__) && ! defined (SEMOPS_DEFINE_INLINE)
+#if defined (__clang__)
+#ifndef SEMOPS_DEFINE_INLINE
+#define SEMOPS_DEFINE_INLINE
+#endif
+#define SEMOPS_INLINE static inline
+#elif defined (__GNUC__) && ! defined (SEMOPS_DEFINE_INLINE)
#define SEMOPS_DEFINE_INLINE
#define SEMOPS_INLINE extern inline
#else
@@ -62,7 +62,12 @@ extern void sim_addr_range_delete (ADDR_RANGE * /*ar*/,
/* Return non-zero if ADDR is in range AR, traversing the entire tree.
If no range is specified, that is defined to mean "everything". */
-extern INLINE int
+#if defined (__clang__)
+static
+#else
+extern
+#endif
+INLINE int
sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/);
#define ADDR_RANGE_HIT_P(ar, addr) \
((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr)))