Make the clang build work.

The funky offset calculation was causing clang some problems. It
complained about the invalid assembly used to extract the offsets
calculated by the compiler.

This changes the funkiness from using a fake mneumonic (which clang
can't not complain about) to using a constant. The assembly post
processing is updated accordingly.

Change-Id: I5beef119e8f7cefedcf99642a28cf5aa5bbfdff8
diff --git a/Makefile b/Makefile
index 92b2727..d5ddb7d 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,7 @@
 COPTS += -fpic
 COPTS += -std=c11
 COPTS += -Wall -Wpedantic -Werror
+COPTS += -Wno-extended-offsetof
 COPTS += -DDEBUG=$(DEBUG)
 COPTS += -MMD -MP -MF $$(patsubst %,%.d,$$@)
 COPTS += -DMAX_CPUS=8
@@ -87,7 +88,10 @@
   GLOBAL_OFFSETS += $$(TGT)
 $$(TGT): $(ROOT_DIR)$(1) | $$(dir $$(TGT))
 	$$(info GENOFFSET $(ROOT_DIR)$1)
-	@$(CC) $(COPTS) -MT $$@ -S -c $(ROOT_DIR)$(1) -o - | grep DEFINE_OFFSET | sed 's/\tDEFINE_OFFSET/#define/g' > $$@
+	@$(CC) $(COPTS) -MT $$@ -S -c $(ROOT_DIR)$(1) -o - | \
+		grep ^DEFINE_OFFSET -A1 | \
+		grep -v ^--$ | \
+		sed 's/^DEFINE_OFFSET__\([^:]*\):/#define \1 \\/g' | sed 's/\.xword//g' > $$@
 endef
 
 #
diff --git a/inc/decl_offsets.h b/inc/decl_offsets.h
index 01f182f..e0da1e8 100644
--- a/inc/decl_offsets.h
+++ b/inc/decl_offsets.h
@@ -2,9 +2,9 @@
 #define _DECL_OFFSETS_H
 
 #define DECL(name, type, field) \
-	__asm("DEFINE_OFFSET " #name " %0" : : "n" (offsetof(type, field)))
+    const size_t DEFINE_OFFSET__##name = offsetof(type, field)
 
 #define DECL_SIZE(name, type) \
-	__asm("DEFINE_OFFSET " #name " %0" : : "n" (sizeof(type)))
+    const size_t DEFINE_OFFSET__name = sizeof(type)
 
 #endif  /* _DECL_OFFSETS_H */
diff --git a/src/arch/aarch64/offsets.c b/src/arch/aarch64/offsets.c
index f16e242..8c49fed 100644
--- a/src/arch/aarch64/offsets.c
+++ b/src/arch/aarch64/offsets.c
@@ -1,10 +1,7 @@
 #include "cpu.h"
 #include "decl_offsets.h"
 
-void dummy(void)
-{
-	DECL(CPU_CURRENT, struct cpu, current);
-	DECL(CPU_STACK_BOTTOM, struct cpu, stack_bottom);
-	DECL(VCPU_REGS, struct vcpu, regs);
-	DECL(VCPU_LAZY, struct vcpu, regs.lazy);
-}
+DECL(CPU_CURRENT, struct cpu, current);
+DECL(CPU_STACK_BOTTOM, struct cpu, stack_bottom);
+DECL(VCPU_REGS, struct vcpu, regs);
+DECL(VCPU_LAZY, struct vcpu, regs.lazy);