Skip to contentSkip to conversation

libxl: ensure var is inited in libxl__domain_firmware

PATCH In review Doug Goldstein 6 participants 19 messages Mar 8, 2016 – Apr 6, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libxl: ensure var is inited in libxl__domain_firmware

Some versions of GCC complain that the 'firmware' variable can be used uninitialized. It looks like the switch inside of the else case is just confusing GCC.

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/libxl/libxl_dom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_dom.c +1 -1
index 664adad..b825b98 100644
@@ -867,7 +867,7 @@ static int libxl__domain_firmware(libxl__gc *gc,
                                   struct xc_dom_image *dom)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    const char *firmware;
+    const char *firmware = NULL;
     int e, rc;
     int datalen = 0;
     void *data;
Signature · 7 lines
2.4.10


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/2 tools: detect appropriate debug optimization level

The build should not use -O0 as that results in miscompilations. There have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0 in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 7 lines
2.4.10


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

Quoted 4 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

gcc manual says -O0 is the default.

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

Quoted 2 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

Quoted 26 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 1 line
2.4.10

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

Quoted 7 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

Quoted 27 lines
Quoted 27 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 1 line
2.4.10
Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +0 -0
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
Quoted 16 lines
Quoted 11 lines
Quoted 11 lines
tools/Rules.mk +2 -1
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 1 line
2.4.10
Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 54 lines · Wei Liu
Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

Quoted 44 lines
Quoted 3 lines

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 32 lines
Quoted 27 lines
Quoted 27 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 1 line
2.4.10
Signature · 1 line
Doug Goldstein

ping?

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 100 lines · Doug Goldstein
Quoted 54 lines · Wei Liu
Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

Quoted 44 lines
Quoted 3 lines

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 32 lines
Quoted 27 lines
Quoted 27 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +2 -1
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
Signature · 1 line
2.4.10
Signature · 1 line
Doug Goldstein
Quoted 3 lines

ping?

ping the ping?

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 101 lines · Doug Goldstein
Quoted 100 lines · Doug Goldstein
Quoted 98 lines · Wei Liu
Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 32 lines
Quoted 16 lines
Quoted 16 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +0 -0
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
Quoted 11 lines
Quoted 11 lines
tools/Rules.mk +2 -2
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
--

2.4.10

--
Doug Goldstein

Quoted 5 lines
Quoted 3 lines

ping?

ping the ping?

So just reading through the history -- I'm a bit confused why, if -Og is supposed to "do the right thing", why you didn't add that in this patch?

In any case, having debug=y *functioning* should take priority over having gdb working, so I'm inclined to say that we should take a patch like this.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 106 lines · George Dunlap
Quoted 105 lines · Doug Goldstein
Quoted 103 lines · Doug Goldstein
Quoted 54 lines · Wei Liu
Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

Quoted 44 lines
Quoted 3 lines

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 32 lines
Quoted 16 lines
Quoted 16 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +0 -0
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
Quoted 11 lines
Quoted 11 lines
tools/Rules.mk +2 -2
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
--

2.4.10

--
Doug Goldstein

ping?

Quoted 5 lines
Quoted 1 line

ping the ping?

So just reading through the history -- I'm a bit confused why, if -Og is supposed to "do the right thing", why you didn't add that in this patch?

I did.

+$(call cc-option-add,CFLAGS,CC,-Og)

That tests to see if the version of GCC you're using supports that flag and if it does adds it. Otherwise it does nothing. Per the README we support down to GCC 4.1.2 and -Og was added in 4.7 I believe. For versions of GCC older than 4.7 this uses the debug=y default of -O1 instead of using -O0 which is known to break in some cases.

Quoted 4 lines

In any case, having debug=y *functioning* should take priority over having gdb working, so I'm inclined to say that we should take a patch like this.

Exactly why I'd like to see this land.

Quoted 3 lines

-George

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 115 lines · Doug Goldstein
Quoted 106 lines · George Dunlap
Quoted 105 lines · Doug Goldstein
Quoted 103 lines · Doug Goldstein
Quoted 54 lines · Wei Liu
Quoted 11 lines · Doug Goldstein
Quoted 5 lines · Wei Liu
Quoted 1 line · Doug Goldstein

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Urgh...

Quoted 4 lines

This came about from reading reports on the -devel and -user's ML that were solved by building Xen with debug=n. I was also striving to reduce the duplication of CFLAGS that are passed on the command line of builds.

I agree this is a good idea.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0

Quoted 6 lines
Quoted 1 line

gcc manual says -O0 is the default.

I wasn't clear about where the 'the default' came from. That's the default in the Xen tree (see: config/StdGNU.mk for example but every platform has -O1 set).

OK. I thought you're talking about something in the manual.

Quoted 7 lines
Quoted 3 lines

Not that I disagree with this patch in general, but the commit message seems a bit misleading.

I can rewrite it. I'd also be willing to change the patch to prefer -Og if its available and use -O0 if its not.

No need to do it now because ...

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

And I have no idea why -O1 confuses the debugger so I've CC'ed Euan for more input.

Quoted 44 lines
Quoted 3 lines

-O1 can optimize things out when you look at them with gdb but -Og is suppose to do the right thing.

.. I don't know much about gcc so I would like to wait for Ian to give some input.

Wei.

Quoted 32 lines
Quoted 16 lines
Quoted 16 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/Rules.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/Rules.mk +0 -0
index 9ef0b47..ae6b01f 100644
@@ -137,7 +137,8 @@ SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_LIBVCHAN)
 
Quoted 11 lines
Quoted 11 lines
tools/Rules.mk +2 -2
 ifeq ($(debug),y)
 # Disable optimizations and enable debugging information for macros
-CFLAGS += -O0 -g3
+$(call cc-option-add,CFLAGS,CC,-Og)
+CFLAGS += -g3
 # But allow an override to -O0 in case Python enforces -D_FORTIFY_SOURCE=<n>.
 PY_CFLAGS += $(PY_NOOPT_CFLAGS)
 endif
--

2.4.10

--
Doug Goldstein

ping?

Quoted 5 lines
Quoted 1 line

ping the ping?

So just reading through the history -- I'm a bit confused why, if -Og is supposed to "do the right thing", why you didn't add that in this patch?

I did.

Quoted 7 lines

+$(call cc-option-add,CFLAGS,CC,-Og)

That tests to see if the version of GCC you're using supports that flag and if it does adds it. Otherwise it does nothing. Per the README we support down to GCC 4.1.2 and -Og was added in 4.7 I believe. For versions of GCC older than 4.7 this uses the debug=y default of -O1 instead of using -O0 which is known to break in some cases.

Gah -- sorry, my eyes skipped over that when skimming this thread. Sorry about that. :-)

So it looks like we're still waiting for someone who knows more about gcc to comment.

Andy, you seems to know this sort of thing -- would you be willing take a look? Otherwise we may have to ping IanJ out-of-band.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

In reply to Doug Goldstein

Doug Goldstein writes ("Re: [PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 10 lines · Wei Liu
Quoted 5 lines · Doug Goldstein
Quoted 1 line

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

My initial reaction is that I any actual problems are bugs either in the compiler or in Xen, which should be fixed.

There should be nothing wrong with lack of inlining or dead code elimination. If you can give an example of structure padding going wrong, please do.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#11 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Ian Jackson writes ("Re: [PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 6 lines

My initial reaction is that I any actual problems are bugs either in the compiler or in Xen, which should be fixed.

There should be nothing wrong with lack of inlining or dead code elimination. If you can give an example of structure padding going wrong, please do.

Having said that, the reason for specifying -O0 is the use case that gcc now provides -Og for. So I see no harm and some benefit in using -Og if it is supported.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#12 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

In reply to Ian Jackson
Quoted 12 lines · Ian Jackson

Doug Goldstein writes ("Re: [PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 10 lines · Wei Liu
Quoted 5 lines · Doug Goldstein
Quoted 1 line

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Quoted 9 lines

My initial reaction is that I any actual problems are bugs either in the compiler or in Xen, which should be fixed.

There should be nothing wrong with lack of inlining or dead code elimination. If you can give an example of structure padding going wrong, please do.

Ian.

Ok fine, I'm just confused why we're insisting on using -O0 over -Og?

From the gcc manual:

-Og
Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

In reply to Ian Jackson
Quoted 12 lines · Ian Jackson

Doug Goldstein writes ("Re: [PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 10 lines · Wei Liu
Quoted 5 lines · Doug Goldstein
Quoted 1 line

The build should not use -O0 as that results in miscompilations. There

This needs some (concrete) references. Is that a known issue in gcc? If so can you reference the bug number?

So its not really a bug in GCC but just the complete lack of optimizations in play. inlines aren't inlined. dead code elimination isn't run so things are much bigger. structures aren't padded the same way.

Quoted 6 lines

My initial reaction is that I any actual problems are bugs either in the compiler or in Xen, which should be fixed.

There should be nothing wrong with lack of inlining or dead code elimination. If you can give an example of structure padding going wrong, please do.

I know in the Linux kernel the level of optimization must be -O2, because there are certain things that rely on dead code elimination to function properly. I'm not sure if the Xen hypervisor has similar requirements, but I'd be rather surprised if it didn't.

It would be nice to know what functionality in the tools relied on inlining and/or dead code elimination (and under what circumstances), but we probably have better things to do than make -O0 to work. :-)

-George

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#14 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

In reply to Doug Goldstein

Doug Goldstein writes ("[PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 6 lines

The build should not use -O0 as that results in miscompilations. There have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0 in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

To summarise: I agree with using -Og if it is available. But I disagree with reverting 1166ecf7 in the case where it isn't; if -Og is not available, we should stick with -O0.

I'm open to persuasion in the latter point but I would like specific examples of problems (and then I would form an opinion about the specific problems), not generalities.

Doug, would you like to, for now, propose a patch that uses -Og if it is available, but otherwise falls back to -O0 ? NB that if convenient, this can be done simply by always specifying -O0 and putting -Og after it if it is supported.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

Quoted 12 lines · Ian Jackson

Doug Goldstein writes ("[PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 6 lines

The build should not use -O0 as that results in miscompilations. There have been a few instances on the ML where users were told to switch from -O0 to -O1 or -O2 or to set debug=n and their issue went away. The preferred route should be to use -Og if its available, otherwise use -O1 which is the default. This change undoes the change from -O1 to -O0 in 1166ecf781b1016eaa61f8d5ba4fb1fde9d599b6.

To summarise: I agree with using -Og if it is available. But I disagree with reverting 1166ecf7 in the case where it isn't; if -Og is not available, we should stick with -O0.

Quoted 8 lines

I'm open to persuasion in the latter point but I would like specific examples of problems (and then I would form an opinion about the specific problems), not generalities.

Doug, would you like to, for now, propose a patch that uses -Og if it is available, but otherwise falls back to -O0 ? NB that if convenient, this can be done simply by always specifying -O0 and putting -Og after it if it is supported.

I agree that it would be good to include specific bugs that this fixes. Presuming that they are as described (compilation errors for reasonable setups), I continue to think that making things compile for everyone is more important than making them debuggable via gdb for people running compilers that don't support -Og.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#16 lore raw

Re: [PATCH 2/2] tools: detect appropriate debug optimization level

George Dunlap writes ("Re: [Xen-devel] [PATCH 2/2] tools: detect appropriate debug optimization level"):

Quoted 11 lines · Ian Jackson
Quoted 4 lines

Doug, would you like to, for now, propose a patch that uses -Og if it is available, but otherwise falls back to -O0 ? NB that if convenient, this can be done simply by always specifying -O0 and putting -Og after it if it is supported.

I agree that it would be good to include specific bugs that this fixes. Presuming that they are as described (compilation errors for reasonable setups), I continue to think that making things compile for everyone is more important than making them debuggable via gdb for people running compilers that don't support -Og.

I think making debug builds debuggable for people with non-broken compilers is more important than making debug builds build for people with broken compilers.

(Under some unstated but I think reasonable, and rebuttable, assumptions about the sizes of the two sets of people.)

Non-debug builds are, after all, not affected by any of this.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/2
#17 lore raw
In reply to Doug Goldstein
Quoted 5 lines · Doug Goldstein

Some versions of GCC complain that the 'firmware' variable can be used uninitialized. It looks like the switch inside of the else case is just confusing GCC.

Quoted 24 lines

---
CC: Ian Jackson <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/libxl/libxl_dom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_dom.c +1 -1
index 664adad..b825b98 100644
@@ -867,7 +867,7 @@ static int libxl__domain_firmware(libxl__gc *gc,
                                   struct xc_dom_image *dom)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    const char *firmware;
+    const char *firmware = NULL;
     int e, rc;
     int datalen = 0;
     void *data;
Signature · 1 line
2.4.10

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#18 lore raw
Quoted 9 lines · Wei Liu
Quoted 5 lines · Doug Goldstein

Some versions of GCC complain that the 'firmware' variable can be used uninitialized. It looks like the switch inside of the else case is just confusing GCC.

I sent these two together but they really aren't dependent on each other so this can go in without the other.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel