diff mbox series

[v2,05/12] package/flare-engine: fix BUG_85180 build timeout

Message ID 20190521133932.81841-6-giulio.benetti@micronovasrl.com
State Accepted
Headers show
Series Fix GCC BUG 85180 per-package | expand

Commit Message

Giulio Benetti May 21, 2019, 1:39 p.m. UTC
With Microblaze Gcc version < 8.x build hangs on compiling last files.
This is due to bug 85180:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180
Bug shows up building flare-engine with optimization but not when
building with -O0.

If BR2_TOOLCHAIN_HAS_GCC_BUG_85180=y force using -O0 by:
- setting CMAKE_BUILD_TYPE to Dummy to avoid CMakeLists.txt to impose
  -O* and -g* flags
- pass -O0 to CXXFLAGS to override previous -O flags
Then remove 'depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_85180' and its
comment if not available in Config.in

Fixes:
http://autobuild.buildroot.net/results/706/7065e14917a8bbc0faf21b29183ac55b6c800ee3/

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 package/flare-engine/Config.in       | 4 ----
 package/flare-engine/flare-engine.mk | 6 ++++++
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Thomas Petazzoni May 24, 2019, 7:58 p.m. UTC | #1
On Tue, 21 May 2019 15:39:25 +0200
Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:

> With Microblaze Gcc version < 8.x build hangs on compiling last files.
> This is due to bug 85180:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180
> Bug shows up building flare-engine with optimization but not when
> building with -O0.
> 
> If BR2_TOOLCHAIN_HAS_GCC_BUG_85180=y force using -O0 by:
> - setting CMAKE_BUILD_TYPE to Dummy to avoid CMakeLists.txt to impose
>   -O* and -g* flags

Why does flare-engine need this, but not jasper, which is also a
CMake-based package ?

Thanks,

Thomas
Giulio Benetti May 24, 2019, 8:05 p.m. UTC | #2
Hello Thomas,

Il 24/05/2019 21:58, Thomas Petazzoni ha scritto:
> On Tue, 21 May 2019 15:39:25 +0200
> Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:
> 
>> With Microblaze Gcc version < 8.x build hangs on compiling last files.
>> This is due to bug 85180:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180
>> Bug shows up building flare-engine with optimization but not when
>> building with -O0.
>>
>> If BR2_TOOLCHAIN_HAS_GCC_BUG_85180=y force using -O0 by:
>> - setting CMAKE_BUILD_TYPE to Dummy to avoid CMakeLists.txt to impose
>>    -O* and -g* flags
> 
> Why does flare-engine need this, but not jasper, which is also a
> CMake-based package ?

Because in flare-engine CMakeLists.txt there is no fallback to -O0, so 
that was the only decent way to force CMake to generate Makefiles 
without optimizations. I don't like it very much but it was the only way 
I've found.

Thank you for reviewing and improving all commit logs!
Thomas Petazzoni May 24, 2019, 8:30 p.m. UTC | #3
On Fri, 24 May 2019 22:05:12 +0200
Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:

> > Why does flare-engine need this, but not jasper, which is also a
> > CMake-based package ?  
> 
> Because in flare-engine CMakeLists.txt there is no fallback to -O0, so 
> that was the only decent way to force CMake to generate Makefiles 
> without optimizations.

Could you be more specific ? How does it work for jasper and
libcpprestsdk, which are also based on CMake ?

Thanks,

Thomas
Giulio Benetti May 27, 2019, 5:20 p.m. UTC | #4
Hello Thomas,

Il 24/05/2019 22:30, Thomas Petazzoni ha scritto:
> On Fri, 24 May 2019 22:05:12 +0200
> Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:
> 
>>> Why does flare-engine need this, but not jasper, which is also a
>>> CMake-based package ?
>>
>> Because in flare-engine CMakeLists.txt there is no fallback to -O0, so
>> that was the only decent way to force CMake to generate Makefiles
>> without optimizations.
> 
> Could you be more specific ? How does it work for jasper and
> libcpprestsdk, which are also based on CMake ?

Yes, the problem here is that even if there's the way to append 
something to CMAKE_CXX_FLAGS, then any other CMAKE_CXX_FLAGS_* will be 
appended, so if I set CMAKE_CXX_FLAGS to -O0, I will obtain "-O0 -O2 -g".

This is due to the fact that we fall into one of the cases of the next 
if-elseif statements(in CMakeLists.txt):
"
if(CMAKE_BUILD_TYPE STREQUAL "Release")
   set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")
   if(MINGW)
     set(CMAKE_CXX_FLAGS_RELEASE "-Wl,-subsystem,windows 
${CMAKE_CXX_FLAGS_RELEASE}")
   endif()
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
   set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g0")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
   set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -pg")
   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg")
   set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-pg")
   set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-pg")
endif()
"
where Release is the default and if BR2_ENABLE_DEBUG=y 
CMAKE_BUILD_TYPE=RelWithDebInfo according to flare-engine.mk
So I thought to set CMAKE_BUILD_TYPE to "Dummy" to jump over that 
if-elseif. But just right now I've realized that's enough to give 
-DCMAKE_BUILD_TYPE=
Empty is enough to jump over if-elseif.
Another way would be to patch CMakeLists.txt adding a fallback "else" to 
those if-elseif

What do you think?

Best regards
Arnout Vandecappelle May 27, 2019, 9:03 p.m. UTC | #5
On 27/05/2019 19:20, Giulio Benetti wrote:
> Hello Thomas,
> 
> Il 24/05/2019 22:30, Thomas Petazzoni ha scritto:
>> On Fri, 24 May 2019 22:05:12 +0200
>> Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:
>>
>>>> Why does flare-engine need this, but not jasper, which is also a
>>>> CMake-based package ?
>>>
>>> Because in flare-engine CMakeLists.txt there is no fallback to -O0, so
>>> that was the only decent way to force CMake to generate Makefiles
>>> without optimizations.
>>
>> Could you be more specific ? How does it work for jasper and
>> libcpprestsdk, which are also based on CMake ?
> 
> Yes, the problem here is that even if there's the way to append something to
> CMAKE_CXX_FLAGS, then any other CMAKE_CXX_FLAGS_* will be appended, so if I set
> CMAKE_CXX_FLAGS to -O0, I will obtain "-O0 -O2 -g".
> 
> This is due to the fact that we fall into one of the cases of the next if-elseif
> statements(in CMakeLists.txt):
> "
> if(CMAKE_BUILD_TYPE STREQUAL "Release")
>   set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")

 Note that you could also get away without overriding CMAKE_BUILD_TYPE, and just
setting CMAKE_CXX_FLAGS_RELEASE. Definitions passed on the command line will
override the ones in CMakeFiles.txt (at least, I think so...).

 However, since we now still set CMAKE_BUILD_TYPE based on BR2_ENABLE_DEBUG,
that won't work :-(


>   if(MINGW)
>     set(CMAKE_CXX_FLAGS_RELEASE "-Wl,-subsystem,windows
> ${CMAKE_CXX_FLAGS_RELEASE}")
>   endif()
> elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
>   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
> elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
>   set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g0")
> elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
>   set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -pg")
>   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg")
>   set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-pg")
>   set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-pg")
> endif()
> "
> where Release is the default and if BR2_ENABLE_DEBUG=y
> CMAKE_BUILD_TYPE=RelWithDebInfo according to flare-engine.mk
> So I thought to set CMAKE_BUILD_TYPE to "Dummy" to jump over that if-elseif. But
> just right now I've realized that's enough to give -DCMAKE_BUILD_TYPE=
> Empty is enough to jump over if-elseif.
> Another way would be to patch CMakeLists.txt adding a fallback "else" to those
> if-elseif

 Another interesting example to consider how we should handle the
CMAKE_BUILD_TYPE...

 We could just always set CMAKE_BUILD_TYPE to Dummy or empty or whatever.
However, I'm not sure if that's the right thing to do. For other package infras,
we pass the optimisation options in CFLAGS, which still gives packages the
opportunity to change or override them. Looking at a few autotools packages,
they seem to generally append stuff to CFLAGS, but not really override it - and
autoconf itself takes care of not overriding user-passed CFLAGS. CMake packages,
on the other hand, seem to mess a lot more with optimisation flags (like the
example above). Also, I have the impression that CMake packages tend to also
override CMAKE_C_FLAGS (rather than append to it or override CMAKE_C_FLAGS_RELEASE).

 My feeling *at this time* is that the best option would be to set:

CMAKE_BUILD_TYPE=Buildroot
CMAKE_C_FLAGS_BUILDROOT=@TARGET_CFLAGS@

and not set CMAKE_C_FLAGS at all. For packages that do something sensible and
necessary under a BUILD_TYPE == Release condition, we can still do
package-specific override of BUILD_TYPE. And for packages that need something
extra, we can pass -DCMAKE_C_FLAGS_BUILDROOT="$(TARGET_CFLAGS) -O0"

 But it's very hard to be sure what is the best way, and what will cause the
least amount of breakage... So, to have the least amount of breakage, it would
be better to stick to CMAKE_BUILD_TYPE=Release and live with the fact that many
packages will override the optimisation flags...

 Bwerk, difficult to decide...

 Let's add Yann to the already huge Cc list :-)

 Regards,
 Arnout
Arnout Vandecappelle May 27, 2019, 9:44 p.m. UTC | #6
On 27/05/2019 23:03, Arnout Vandecappelle wrote:
> 
> 
> On 27/05/2019 19:20, Giulio Benetti wrote:
>> Hello Thomas,
>>
>> Il 24/05/2019 22:30, Thomas Petazzoni ha scritto:
>>> On Fri, 24 May 2019 22:05:12 +0200
>>> Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:
>>>
>>>>> Why does flare-engine need this, but not jasper, which is also a
>>>>> CMake-based package ?
>>>>
>>>> Because in flare-engine CMakeLists.txt there is no fallback to -O0, so
>>>> that was the only decent way to force CMake to generate Makefiles
>>>> without optimizations.
>>>
>>> Could you be more specific ? How does it work for jasper and
>>> libcpprestsdk, which are also based on CMake ?
>>
>> Yes, the problem here is that even if there's the way to append something to
>> CMAKE_CXX_FLAGS, then any other CMAKE_CXX_FLAGS_* will be appended, so if I set
>> CMAKE_CXX_FLAGS to -O0, I will obtain "-O0 -O2 -g".
>>
>> This is due to the fact that we fall into one of the cases of the next if-elseif
>> statements(in CMakeLists.txt):
>> "
>> if(CMAKE_BUILD_TYPE STREQUAL "Release")
>>   set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")
> 
>  Note that you could also get away without overriding CMAKE_BUILD_TYPE, and just
> setting CMAKE_CXX_FLAGS_RELEASE. Definitions passed on the command line will
> override the ones in CMakeFiles.txt (at least, I think so...).
> 
>  However, since we now still set CMAKE_BUILD_TYPE based on BR2_ENABLE_DEBUG,
> that won't work :-(

 Because of this (and because we can't wait for CMake refactoring), I've
improved the comment in the .mk file a little and also rewrote the commit log
based on what Thomas wrote for the other commits, and applied to master, thanks.

 Regards,
 Arnout


[snip]
Giulio Benetti May 27, 2019, 9:45 p.m. UTC | #7
Il 27/05/2019 23:44, Arnout Vandecappelle ha scritto:
> 
> 
> On 27/05/2019 23:03, Arnout Vandecappelle wrote:
>>
>>
>> On 27/05/2019 19:20, Giulio Benetti wrote:
>>> Hello Thomas,
>>>
>>> Il 24/05/2019 22:30, Thomas Petazzoni ha scritto:
>>>> On Fri, 24 May 2019 22:05:12 +0200
>>>> Giulio Benetti <giulio.benetti@micronovasrl.com> wrote:
>>>>
>>>>>> Why does flare-engine need this, but not jasper, which is also a
>>>>>> CMake-based package ?
>>>>>
>>>>> Because in flare-engine CMakeLists.txt there is no fallback to -O0, so
>>>>> that was the only decent way to force CMake to generate Makefiles
>>>>> without optimizations.
>>>>
>>>> Could you be more specific ? How does it work for jasper and
>>>> libcpprestsdk, which are also based on CMake ?
>>>
>>> Yes, the problem here is that even if there's the way to append something to
>>> CMAKE_CXX_FLAGS, then any other CMAKE_CXX_FLAGS_* will be appended, so if I set
>>> CMAKE_CXX_FLAGS to -O0, I will obtain "-O0 -O2 -g".
>>>
>>> This is due to the fact that we fall into one of the cases of the next if-elseif
>>> statements(in CMakeLists.txt):
>>> "
>>> if(CMAKE_BUILD_TYPE STREQUAL "Release")
>>>    set(CMAKE_CXX_FLAGS_RELEASE "-O2 -g0")
>>
>>   Note that you could also get away without overriding CMAKE_BUILD_TYPE, and just
>> setting CMAKE_CXX_FLAGS_RELEASE. Definitions passed on the command line will
>> override the ones in CMakeFiles.txt (at least, I think so...).
>>
>>   However, since we now still set CMAKE_BUILD_TYPE based on BR2_ENABLE_DEBUG,
>> that won't work :-(
> 
>   Because of this (and because we can't wait for CMake refactoring), I've
> improved the comment in the .mk file a little and also rewrote the commit log
> based on what Thomas wrote for the other commits, and applied to master, thanks.

Thank you instead!

Best regards
diff mbox series

Patch

diff --git a/package/flare-engine/Config.in b/package/flare-engine/Config.in
index e299a6b7de..cdcb018948 100644
--- a/package/flare-engine/Config.in
+++ b/package/flare-engine/Config.in
@@ -2,7 +2,6 @@  config BR2_PACKAGE_FLARE_ENGINE
 	bool "flare-engine"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on !BR2_STATIC_LIBS # SDL2
-	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_85180
 	select BR2_PACKAGE_SDL2
 	select BR2_PACKAGE_SDL2_IMAGE
 	select BR2_PACKAGE_SDL2_MIXER
@@ -18,6 +17,3 @@  config BR2_PACKAGE_FLARE_ENGINE
 
 comment "flare-engine needs a toolchain w/ C++, dynamic library"
 	depends on !BR2_INSTALL_LIBSTDCPP || BR2_STATIC_LIBS
-
-comment "flare-engine needs a toolchain not affected by GCC bug 85180"
-	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_85180
diff --git a/package/flare-engine/flare-engine.mk b/package/flare-engine/flare-engine.mk
index 2f36602348..a9d506e220 100644
--- a/package/flare-engine/flare-engine.mk
+++ b/package/flare-engine/flare-engine.mk
@@ -19,4 +19,10 @@  ifeq ($(BR2_ENABLE_DEBUG),y)
 FLARE_ENGINE_CONF_OPTS += -DCMAKE_BUILD_TYPE=RelWithDebInfo
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_85180),y)
+# Avoid CMakeLists.txt to impose "-O* -g*" flags
+FLARE_ENGINE_CONF_OPTS += -DCMAKE_BUILD_TYPE=Dummy
+FLARE_ENGINE_CONF_OPTS += -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -O0"
+endif
+
 $(eval $(cmake-package))