[libcamera-devel] [PATCH] meson: Don't set _FORTIFY_SOURCE for ChromeOS

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Sep 8 17:08:57 CEST 2023


On Thu, Sep 07, 2023 at 10:12:59AM -0600, George Burgess IV via libcamera-devel wrote:
> ChromeOS is moving to a platform default of `_FORTIFY_SOURCE=3`, and
> this definition conflicts with that:
> 
> ```
> <command line>:4:9: error: '_FORTIFY_SOURCE' macro redefined
> [-Werror,-Wmacro-redefined]
> ```
> 
> Rather than adding logic to keep up with their local configuration, it
> seems best to leave setting _FORTIFY_SOURCE on ChromeOS up to ChromeOS.
> 
> Signed-off-by: George Burgess IV <gbiv at google.com>
> ---
>  meson.build | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 7959b538..109923ac 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -101,7 +101,8 @@ if cc.get_id() == 'clang'
>  
>      # Turn _FORTIFY_SOURCE by default on optimised builds (as it requires -O1
>      # or higher). This is needed on clang only as gcc enables it by default.
> -    if get_option('optimization') != '0'
> +    # CrOS sets their preferred FORTIFY level in platform-level CFLAGS.

Someone else may do the same. I wonder, would it be possible here to add
-D_FORTIFY_SOURCES only if not already set in CFLAGS ?

> +    if get_option('optimization') != '0' and get_option('android_platform') != 'cros'
>          common_arguments += [
>              '-D_FORTIFY_SOURCE=2',
>          ]

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list