[libcamera-devel,2/2] libcamera: Use compile optimisation by default

Message ID 20190428231238.30547-2-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • [libcamera-devel,1/2] libcamera: Don't ignore the return value of read() and write()
Related show

Commit Message

Laurent Pinchart April 28, 2019, 11:12 p.m. UTC
Set the compiler optimisation level to 2 by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 meson.build | 1 +
 1 file changed, 1 insertion(+)

Comments

Jacopo Mondi April 28, 2019, 11:57 p.m. UTC | #1
Hi Laurent,

On Mon, Apr 29, 2019 at 02:12:38AM +0300, Laurent Pinchart wrote:
> Set the compiler optimisation level to 2 by default.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks,
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

> ---
>  meson.build | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/meson.build b/meson.build
> index d272ff33b100..a11a1e4c238e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -5,6 +5,7 @@ project('libcamera', 'c', 'cpp',
>      'werror=true',
>      'warning_level=2',
>      'cpp_std=c++11',
> +    'optimization=2',
>    ],
>    license : 'LGPL 2.1+')
>
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham April 29, 2019, 12:37 p.m. UTC | #2
Hi Laurent,

On 29/04/2019 00:12, Laurent Pinchart wrote:
> Set the compiler optimisation level to 2 by default.
> 

Isn't this handled already by the buildtype?

buildtype {plain, debug, debugoptimized, release, minsize, custom}

The default buildtype is 'debug', which I would expect to have an
optimization level of '0' or 'g' to make debugging in GDB easier.


Looking at https://mesonbuild.com/Running-Meson.html, it states that the
buildtype has the following effects:

========================================================================
You can specify a different type of build with the --buildtype command
line argument. It can have one of the following values.

value	 	meaning

plain		no extra build flags are used, even for compiler
		warnings, useful for distro packagers and other cases
		where you need to specify all arguments by yourself

debug		debug info is generated but the result is not optimized,
		this is the default

debugoptimized	debug info is generated and the code is optimized (on
		most compilers this means -g -O2)

release		full optimization, no debug info
========================================================================

So I think this patch is unnecessary.

--
Regards

Kieran


> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  meson.build | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/meson.build b/meson.build
> index d272ff33b100..a11a1e4c238e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -5,6 +5,7 @@ project('libcamera', 'c', 'cpp',
>      'werror=true',
>      'warning_level=2',
>      'cpp_std=c++11',
> +    'optimization=2',
>    ],
>    license : 'LGPL 2.1+')
>  
>
Laurent Pinchart April 29, 2019, 12:47 p.m. UTC | #3
Hi Kieran,

On Mon, Apr 29, 2019 at 01:37:55PM +0100, Kieran Bingham wrote:
> On 29/04/2019 00:12, Laurent Pinchart wrote:
> > Set the compiler optimisation level to 2 by default.
> 
> Isn't this handled already by the buildtype?
> 
> buildtype {plain, debug, debugoptimized, release, minsize, custom}
> 
> The default buildtype is 'debug', which I would expect to have an
> optimization level of '0' or 'g' to make debugging in GDB easier.
> 
> 
> Looking at https://mesonbuild.com/Running-Meson.html, it states that the
> buildtype has the following effects:
> 
> ========================================================================
> You can specify a different type of build with the --buildtype command
> line argument. It can have one of the following values.
> 
> value	 	meaning
> 
> plain		no extra build flags are used, even for compiler
> 		warnings, useful for distro packagers and other cases
> 		where you need to specify all arguments by yourself
> 
> debug		debug info is generated but the result is not optimized,
> 		this is the default
> 
> debugoptimized	debug info is generated and the code is optimized (on
> 		most compilers this means -g -O2)
> 
> release		full optimization, no debug info
> ========================================================================
> 
> So I think this patch is unnecessary.

I've tested this before and the optimisation level wasn't set
appropriately, but I think I made a mistake somewhere, as testing it now
produces the expected results. I thus agree with you, I'll drop this
patch.

Given that optimised builds use _FORTIFY_SOURCE by default with gcc,
should we enable that in the libcamera buildroot package ? Or does
buildroot handle that internally ?

> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  meson.build | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/meson.build b/meson.build
> > index d272ff33b100..a11a1e4c238e 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -5,6 +5,7 @@ project('libcamera', 'c', 'cpp',
> >      'werror=true',
> >      'warning_level=2',
> >      'cpp_std=c++11',
> > +    'optimization=2',
> >    ],
> >    license : 'LGPL 2.1+')
> >

Patch

diff --git a/meson.build b/meson.build
index d272ff33b100..a11a1e4c238e 100644
--- a/meson.build
+++ b/meson.build
@@ -5,6 +5,7 @@  project('libcamera', 'c', 'cpp',
     'werror=true',
     'warning_level=2',
     'cpp_std=c++11',
+    'optimization=2',
   ],
   license : 'LGPL 2.1+')