meson: Define _FORTIFY_SOURCE for optimised builds
_FORTIFY_SOURCE adds useful checks during compilation. The option is enabled by default by gcc on all non-optimised builds (as it requires -O1 or higher). Enable it explicitly for clang. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
af4304e497
commit
965c5bf7fb
1 changed files with 16 additions and 6 deletions
22
meson.build
22
meson.build
|
@ -38,12 +38,22 @@ common_arguments = [
|
||||||
c_arguments = common_arguments
|
c_arguments = common_arguments
|
||||||
cpp_arguments = common_arguments
|
cpp_arguments = common_arguments
|
||||||
|
|
||||||
# Use libc++ by default if available instead of libstdc++ when compiling with
|
if cc.get_id() == 'clang'
|
||||||
# clang.
|
# Turn _FORTIFY_SOURCE by default on optimised builds (as it requires -O1
|
||||||
if cc.get_id() == 'clang' and cc.find_library('libc++', required: false).found()
|
# or higher). This is needed on clang only as gcc enables it by default.
|
||||||
cpp_arguments += [
|
if get_option('optimization') != '0'
|
||||||
'-stdlib=libc++',
|
common_arguments += [
|
||||||
]
|
'-D_FORTIFY_SOURCE=2',
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Use libc++ by default if available instead of libstdc++ when compiling
|
||||||
|
# with clang.
|
||||||
|
if cc.find_library('libc++', required: false).found()
|
||||||
|
cpp_arguments += [
|
||||||
|
'-stdlib=libc++',
|
||||||
|
]
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
add_project_arguments(c_arguments, language : 'c')
|
add_project_arguments(c_arguments, language : 'c')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue