[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/46] meson: move CFI detection code with other compiler flags
From: |
Paolo Bonzini |
Subject: |
[PULL 36/46] meson: move CFI detection code with other compiler flags |
Date: |
Sun, 31 Dec 2023 09:44:52 +0100 |
Keep it together with the other compiler modes, and before dependencies.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 80 ++++++++++++++++++++++++++---------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/meson.build b/meson.build
index efb36c762e9..5c54441a3cd 100644
--- a/meson.build
+++ b/meson.build
@@ -517,6 +517,46 @@ if get_option('fuzzing')
endif
endif
+if get_option('cfi')
+ cfi_flags=[]
+ # Check for dependency on LTO
+ if not get_option('b_lto')
+ error('Selected Control-Flow Integrity but LTO is disabled')
+ endif
+ if enable_modules
+ error('Selected Control-Flow Integrity is not compatible with modules')
+ endif
+ # Check for cfi flags. CFI requires LTO so we can't use
+ # get_supported_arguments, but need a more complex "compiles" which allows
+ # custom arguments
+ if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall'] )
+ cfi_flags += '-fsanitize=cfi-icall'
+ else
+ error('-fsanitize=cfi-icall is not supported by the compiler')
+ endif
+ if cc.compiles('int main () { return 0; }',
+ name: '-fsanitize-cfi-icall-generalize-pointers',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fsanitize-cfi-icall-generalize-pointers'] )
+ cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
+ else
+ error('-fsanitize-cfi-icall-generalize-pointers is not supported by the
compiler')
+ endif
+ if get_option('cfi_debug')
+ if cc.compiles('int main () { return 0; }',
+ name: '-fno-sanitize-trap=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fno-sanitize-trap=cfi-icall'] )
+ cfi_flags += '-fno-sanitize-trap=cfi-icall'
+ else
+ error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
+ endif
+ endif
+ add_global_arguments(cfi_flags, native: false, language: all_languages)
+ add_global_link_arguments(cfi_flags, native: false, language: all_languages)
+endif
+
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
@@ -2009,46 +2049,6 @@ endif
config_host_data.set('CONFIG_AUDIO_DRIVERS',
'"' + '", "'.join(audio_drivers_selected) + '", ')
-if get_option('cfi')
- cfi_flags=[]
- # Check for dependency on LTO
- if not get_option('b_lto')
- error('Selected Control-Flow Integrity but LTO is disabled')
- endif
- if enable_modules
- error('Selected Control-Flow Integrity is not compatible with modules')
- endif
- # Check for cfi flags. CFI requires LTO so we can't use
- # get_supported_arguments, but need a more complex "compiles" which allows
- # custom arguments
- if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall'] )
- cfi_flags += '-fsanitize=cfi-icall'
- else
- error('-fsanitize=cfi-icall is not supported by the compiler')
- endif
- if cc.compiles('int main () { return 0; }',
- name: '-fsanitize-cfi-icall-generalize-pointers',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fsanitize-cfi-icall-generalize-pointers'] )
- cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
- else
- error('-fsanitize-cfi-icall-generalize-pointers is not supported by the
compiler')
- endif
- if get_option('cfi_debug')
- if cc.compiles('int main () { return 0; }',
- name: '-fno-sanitize-trap=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fno-sanitize-trap=cfi-icall'] )
- cfi_flags += '-fno-sanitize-trap=cfi-icall'
- else
- error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
- endif
- endif
- add_global_arguments(cfi_flags, native: false, language: all_languages)
- add_global_link_arguments(cfi_flags, native: false, language: all_languages)
-endif
-
have_host_block_device = (targetos != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
--
2.43.0
- [PULL 39/46] meson: always probe u2f and canokey if the option is enabled, (continued)
- [PULL 39/46] meson: always probe u2f and canokey if the option is enabled, Paolo Bonzini, 2023/12/31
- [PULL 33/46] meson: move option validation together, Paolo Bonzini, 2023/12/31
- [PULL 27/46] meson: use version_compare() to compare version, Paolo Bonzini, 2023/12/31
- [PULL 30/46] configure: unify again the case arms in probe_target_compiler, Paolo Bonzini, 2023/12/31
- [PULL 44/46] meson: rename config_all, Paolo Bonzini, 2023/12/31
- [PULL 43/46] meson: remove CONFIG_ALL, Paolo Bonzini, 2023/12/31
- [PULL 45/46] configure, meson: rename targetos to host_os, Paolo Bonzini, 2023/12/31
- [PULL 26/46] meson: remove unused variable, Paolo Bonzini, 2023/12/31
- [PULL 37/46] meson: move config-host.h definitions together, Paolo Bonzini, 2023/12/31
- [PULL 40/46] meson: remove OS definitions from config_targetos, Paolo Bonzini, 2023/12/31
- [PULL 36/46] meson: move CFI detection code with other compiler flags,
Paolo Bonzini <=
- [PULL 42/46] meson: remove config_targetos, Paolo Bonzini, 2023/12/31
- [PULL 41/46] meson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos, Paolo Bonzini, 2023/12/31
- [PULL 35/46] meson: keep subprojects together, Paolo Bonzini, 2023/12/31
- [PULL 46/46] meson.build: report graphics backends separately, Paolo Bonzini, 2023/12/31