diff mbox

[v2] build: make debug option affect tools only

Message ID 1478028130-27500-1-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Nov. 1, 2016, 7:22 p.m. UTC
The debug option in Config.mk affects hypervisor, tools and stubdom by
appending different flags to CFLAGS.  Mini-os under extra is not
affected because it already has its own build system when it is
separated from xen.git.

It is undesirable because now hypervisor build is affected by both
Kconfig and debug.

Disentangle the semantics of debug by pushing relevant options to
individual sub-systems.

For hypervisor, the flags previously added by debug option is now
controlled by CONFIG_DEBUG.

For tools, flags are moved from config/*.mk into tools/Rules.mk.

For stubdom, because it unilaterally sets debug=y before including
top-level Config.mk, we only need to move the debug build set of flags
into stubdom Makefile.

Specifically there are some considerations on what flags are picked:

1. we don't need -fno-optimize-sibling-calls anymore because gcc doc
   indicates that it is not enabled for -O1, which we already set in the
   debug build.
2. for tools we use -O0 -g3 in Rules.mk because they already take
   precedence over the flags set in config/*.mk.
3. for hypervisor we don't add -fno-omit-frame-pointer to debug build
   because that's controlled by CONFIG_FRAME_POINTER.

This patch doesn't intend to tune those flags, but to provide identical
set of effective flags as before.  The debug option in Config.mk will
only affect tools components after this patch is applied.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 config/StdGNU.mk | 8 --------
 config/SunOS.mk  | 7 -------
 stubdom/Makefile | 2 ++
 tools/Rules.mk   | 4 +++-
 xen/Rules.mk     | 6 ++++++
 5 files changed, 11 insertions(+), 16 deletions(-)

Comments

Jan Beulich Nov. 2, 2016, 8:53 a.m. UTC | #1
>>> On 01.11.16 at 20:22, <wei.liu2@citrix.com> wrote:
> The debug option in Config.mk affects hypervisor, tools and stubdom by
> appending different flags to CFLAGS.  Mini-os under extra is not
> affected because it already has its own build system when it is
> separated from xen.git.
> 
> It is undesirable because now hypervisor build is affected by both
> Kconfig and debug.
> 
> Disentangle the semantics of debug by pushing relevant options to
> individual sub-systems.
> 
> For hypervisor, the flags previously added by debug option is now
> controlled by CONFIG_DEBUG.
> 
> For tools, flags are moved from config/*.mk into tools/Rules.mk.
> 
> For stubdom, because it unilaterally sets debug=y before including
> top-level Config.mk, we only need to move the debug build set of flags
> into stubdom Makefile.
> 
> Specifically there are some considerations on what flags are picked:
> 
> 1. we don't need -fno-optimize-sibling-calls anymore because gcc doc
>    indicates that it is not enabled for -O1, which we already set in the
>    debug build.
> 2. for tools we use -O0 -g3 in Rules.mk because they already take
>    precedence over the flags set in config/*.mk.
> 3. for hypervisor we don't add -fno-omit-frame-pointer to debug build
>    because that's controlled by CONFIG_FRAME_POINTER.
> 
> This patch doesn't intend to tune those flags, but to provide identical
> set of effective flags as before.  The debug option in Config.mk will
> only affect tools components after this patch is applied.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
Wei Liu Nov. 2, 2016, 10:13 a.m. UTC | #2
On Wed, Nov 02, 2016 at 02:53:32AM -0600, Jan Beulich wrote:
> >>> On 01.11.16 at 20:22, <wei.liu2@citrix.com> wrote:
> > The debug option in Config.mk affects hypervisor, tools and stubdom by
> > appending different flags to CFLAGS.  Mini-os under extra is not
> > affected because it already has its own build system when it is
> > separated from xen.git.
> > 
> > It is undesirable because now hypervisor build is affected by both
> > Kconfig and debug.
> > 
> > Disentangle the semantics of debug by pushing relevant options to
> > individual sub-systems.
> > 
> > For hypervisor, the flags previously added by debug option is now
> > controlled by CONFIG_DEBUG.
> > 
> > For tools, flags are moved from config/*.mk into tools/Rules.mk.
> > 
> > For stubdom, because it unilaterally sets debug=y before including
> > top-level Config.mk, we only need to move the debug build set of flags
> > into stubdom Makefile.
> > 
> > Specifically there are some considerations on what flags are picked:
> > 
> > 1. we don't need -fno-optimize-sibling-calls anymore because gcc doc
> >    indicates that it is not enabled for -O1, which we already set in the
> >    debug build.
> > 2. for tools we use -O0 -g3 in Rules.mk because they already take
> >    precedence over the flags set in config/*.mk.
> > 3. for hypervisor we don't add -fno-omit-frame-pointer to debug build
> >    because that's controlled by CONFIG_FRAME_POINTER.
> > 
> > This patch doesn't intend to tune those flags, but to provide identical
> > set of effective flags as before.  The debug option in Config.mk will
> > only affect tools components after this patch is applied.
> > 
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 

Thanks.

I will push this patch along with the two other earlier patches after my
OSSTest patch lands on production. Please speak up if anyone thinks
that's a bad idea.


Wei.
Wei Liu Nov. 3, 2016, 11:11 a.m. UTC | #3
On Wed, Nov 02, 2016 at 10:13:28AM +0000, Wei Liu wrote:
> On Wed, Nov 02, 2016 at 02:53:32AM -0600, Jan Beulich wrote:
> > >>> On 01.11.16 at 20:22, <wei.liu2@citrix.com> wrote:
> > > The debug option in Config.mk affects hypervisor, tools and stubdom by
> > > appending different flags to CFLAGS.  Mini-os under extra is not
> > > affected because it already has its own build system when it is
> > > separated from xen.git.
> > > 
> > > It is undesirable because now hypervisor build is affected by both
> > > Kconfig and debug.
> > > 
> > > Disentangle the semantics of debug by pushing relevant options to
> > > individual sub-systems.
> > > 
> > > For hypervisor, the flags previously added by debug option is now
> > > controlled by CONFIG_DEBUG.
> > > 
> > > For tools, flags are moved from config/*.mk into tools/Rules.mk.
> > > 
> > > For stubdom, because it unilaterally sets debug=y before including
> > > top-level Config.mk, we only need to move the debug build set of flags
> > > into stubdom Makefile.
> > > 
> > > Specifically there are some considerations on what flags are picked:
> > > 
> > > 1. we don't need -fno-optimize-sibling-calls anymore because gcc doc
> > >    indicates that it is not enabled for -O1, which we already set in the
> > >    debug build.
> > > 2. for tools we use -O0 -g3 in Rules.mk because they already take
> > >    precedence over the flags set in config/*.mk.
> > > 3. for hypervisor we don't add -fno-omit-frame-pointer to debug build
> > >    because that's controlled by CONFIG_FRAME_POINTER.
> > > 
> > > This patch doesn't intend to tune those flags, but to provide identical
> > > set of effective flags as before.  The debug option in Config.mk will
> > > only affect tools components after this patch is applied.
> > > 
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > 
> > Acked-by: Jan Beulich <jbeulich@suse.com>
> > 
> 
> Thanks.
> 
> I will push this patch along with the two other earlier patches after my
> OSSTest patch lands on production. Please speak up if anyone thinks
> that's a bad idea.
> 

My osstest patch landed last night, so I've now pushed this patch and
the other two.

Wei.
diff mbox

Patch

diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 39d36b2..6be8233 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -35,14 +35,6 @@  UTIL_LIBS = -lutil
 SONAME_LDFLAG = -soname
 SHLIB_LDFLAGS = -shared
 
-ifneq ($(debug),y)
-CFLAGS += -O2 -fomit-frame-pointer
-else
-# Less than -O1 produces bad code and large stack frames
-CFLAGS += -O1 -fno-omit-frame-pointer
-CFLAGS-$(gcc) += -fno-optimize-sibling-calls
-endif
-
 ifeq ($(lto),y)
 CFLAGS += -flto
 LDFLAGS-$(clang) += -plugin LLVMgold.so
diff --git a/config/SunOS.mk b/config/SunOS.mk
index 86a384d..0fe5f45 100644
--- a/config/SunOS.mk
+++ b/config/SunOS.mk
@@ -31,12 +31,5 @@  UTIL_LIBS =
 SONAME_LDFLAG = -h
 SHLIB_LDFLAGS = -R $(SunOS_LIBDIR) -shared
 
-ifneq ($(debug),y)
-CFLAGS += -O2 -fno-omit-frame-pointer
-else
-# Less than -O1 produces bad code and large stack frames
-CFLAGS += -O1 -fno-omit-frame-pointer
-endif
-
 CFLAGS += -Wa,--divide -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__
 
diff --git a/stubdom/Makefile b/stubdom/Makefile
index 571704d..2921f30 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -6,6 +6,8 @@  export XEN_OS=MiniOS
 
 export stubdom=y
 export debug=y
+# Moved from config/StdGNU.mk
+CFLAGS += -O1 -fno-omit-frame-pointer
 
 ifeq (,$(findstring clean,$(MAKECMDGOALS)))
   ifeq ($(wildcard $(MINI_OS)/Config.mk),)
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 5a80fec..0e73690 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -138,9 +138,11 @@  SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+CFLAGS += -O0 -g3 -fno-omit-frame-pointer
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
+else
+CFLAGS += -O2 -fomit-frame-pointer
 endif
 
 LIBXL_BLKTAP ?= $(CONFIG_BLKTAP2)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index a9fda71..08cc776 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -46,6 +46,12 @@  ALL_OBJS-y               += $(BASEDIR)/xsm/built_in.o
 ALL_OBJS-y               += $(BASEDIR)/arch/$(TARGET_ARCH)/built_in.o
 ALL_OBJS-$(CONFIG_CRYPTO)   += $(BASEDIR)/crypto/built_in.o
 
+ifeq ($(CONFIG_DEBUG),y)
+CFLAGS += -O1
+else
+CFLAGS += -O2 -fomit-frame-pointer
+endif
+
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
 CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h