diff mbox

Enable compiling with gcc tracing

Message ID 20170330153956.1822-1-eggi.innovations@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felix Schmoll March 30, 2017, 3:39 p.m. UTC
Make minimal adjustments in order to enable the compilation of the
xen source-code with gcc-6's -fsanitize-coverage=trace-pc option.

Due to a bug in Xen's build-system the flag for the compiler has
to be handed in via the command line, i.e. for compiling one would
use:

	make CC=<path to gcc-6>

This is an experimental patch as in a final version you would not
want all files to be compiled with this option by default.

Signed-off-by: Felix Schmoll <eggi.innovations@gmail.com>
---
 xen/Rules.mk                | 9 ++++++++-
 xen/include/xen/hypercall.h | 1 +
 xen/include/xen/my_tracer.h | 6 ++++++
 xen/my_tracer.c             | 1 +
 4 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 xen/include/xen/my_tracer.h
 create mode 100644 xen/my_tracer.c

Comments

Wei Liu March 30, 2017, 3:46 p.m. UTC | #1
Cool. I think Xen should boot with this.

You've successfully finished what I asked for. Now you can divert your
energy to polish your application. :-)

On Thu, Mar 30, 2017 at 05:39:56PM +0200, Felix Schmoll wrote:
> Make minimal adjustments in order to enable the compilation of the
> xen source-code with gcc-6's -fsanitize-coverage=trace-pc option.
> 
> Due to a bug in Xen's build-system the flag for the compiler has
> to be handed in via the command line, i.e. for compiling one would
> use:
> 
> 	make CC=<path to gcc-6>
> 

OOI, how can I reproduce the bug you met?

If you mean it doesn't work with:

       CC=XXX make

it is expected.

Wei.
Felix Schmoll March 31, 2017, 10:52 a.m. UTC | #2
2017-03-30 17:46 GMT+02:00 Wei Liu <wei.liu2@citrix.com>:

> Cool. I think Xen should boot with this.
>
> You've successfully finished what I asked for. Now you can divert your
> energy to polish your application. :-)
>
> On Thu, Mar 30, 2017 at 05:39:56PM +0200, Felix Schmoll wrote:
> > Make minimal adjustments in order to enable the compilation of the
> > xen source-code with gcc-6's -fsanitize-coverage=trace-pc option.
> >
> > Due to a bug in Xen's build-system the flag for the compiler has
> > to be handed in via the command line, i.e. for compiling one would
> > use:
> >
> >       make CC=<path to gcc-6>
> >
>
> OOI, how can I reproduce the bug you met?
>
> If you mean it doesn't work with:
>
>        CC=XXX make
>
> it is expected.
>
Yeah, this is what I meant.

I recalled having read on some archived mailing list that it was a bug, but
whatever.

Felix

>
> Wei.
>
diff mbox

Patch

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 77bcd44922..14de50d540 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -33,7 +33,9 @@  override TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
 
 TARGET := $(BASEDIR)/xen
 
+
 # Note that link order matters!
+ALL_OBJS-y               += $(BASEDIR)/my_tracer.o
 ALL_OBJS-y               += $(BASEDIR)/common/built_in.o
 ALL_OBJS-y               += $(BASEDIR)/drivers/built_in.o
 ALL_OBJS-y               += $(BASEDIR)/xsm/built_in.o
@@ -46,6 +48,7 @@  else
 CFLAGS += -O2 -fomit-frame-pointer
 endif
 
+CFLAGS += -fsanitize-coverage=trace-pc
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
@@ -171,7 +174,11 @@  _clean_%/: FORCE
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean
 
 %.o: %.c Makefile
-	$(CC) $(CFLAGS) -c $< -o $@
+	if [ $@ != $(BASEDIR)/my_tracer.o ]; \
+	  then $(CC) $(CFLAGS) -c $< -o $@; \
+	else \
+          $(CC) -include $(BASEDIR)/include/xen/my_tracer.h -c $(BASEDIR)/my_tracer.c -o $(BASEDIR)/my_tracer.o; \
+    	fi
 
 %.o: %.S Makefile
 	$(CC) $(AFLAGS) -c $< -o $@
diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h
index cc99aea57d..ec19e1c80f 100644
--- a/xen/include/xen/hypercall.h
+++ b/xen/include/xen/hypercall.h
@@ -5,6 +5,7 @@ 
 #ifndef __XEN_HYPERCALL_H__
 #define __XEN_HYPERCALL_H__
 
+#include <xen/my_tracer.h>
 #include <xen/types.h>
 #include <xen/time.h>
 #include <public/xen.h>
diff --git a/xen/include/xen/my_tracer.h b/xen/include/xen/my_tracer.h
new file mode 100644
index 0000000000..7081e60f34
--- /dev/null
+++ b/xen/include/xen/my_tracer.h
@@ -0,0 +1,6 @@ 
+#ifndef _TRACE_H_
+#define _TRACE_H_
+
+void __sanitizer_cov_trace_pc(void);
+
+#endif
diff --git a/xen/my_tracer.c b/xen/my_tracer.c
new file mode 100644
index 0000000000..2a2f8053f8
--- /dev/null
+++ b/xen/my_tracer.c
@@ -0,0 +1 @@ 
+void __sanitizer_cov_trace_pc(void) { return; }