From fb80595725054c5f592b0348c0d4457d1a835963 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Thu, 17 Nov 2022 11:25:45 +0100 Subject: [PATCH] [Build] Add option to build with lto to meson. Fix error in test. Issue: #1743 --- meson.build | 7 +++++++ meson_options.txt | 1 + test/box-test.c | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 5aa3d483..185224a3 100644 --- a/meson.build +++ b/meson.build @@ -30,6 +30,13 @@ foreach f : flags endif endforeach +if get_option('lto') + add_project_arguments('-flto', language: 'c') + add_project_arguments('-Werror=odr', language: 'c') + add_project_arguments('-Werror=lto-type-mismatch', language: 'c') + add_project_arguments('-Werror=strict-aliasing', language: 'c') +endif + plugindir = join_paths(get_option('libdir'), meson.project_name()) themedir = join_paths(get_option('datadir'), meson.project_name(), 'themes') desktop_install_dir = join_paths(get_option('datadir'), 'applications') diff --git a/meson_options.txt b/meson_options.txt index 9ca68fc6..09e89b5a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,3 +2,4 @@ option('drun', type: 'boolean', value: true, description: 'Desktop file mode') option('window', type: 'boolean', value: true, description: 'Window switcher mode') option('check', type: 'feature', description: 'Build and run libcheck-based tests') option('imdkit', type: 'boolean', value: true, description: 'IMDKit support') +option('lto', type: 'boolean', value: false, description: 'Compile with lto') diff --git a/test/box-test.c b/test/box-test.c index dafc526f..12b83200 100644 --- a/test/box-test.c +++ b/test/box-test.c @@ -97,8 +97,8 @@ char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) { } void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {} void rofi_add_warning_message(G_GNUC_UNUSED GString *msg) {} -int textbox_get_estimated_char_height(void); -int textbox_get_estimated_char_height(void) { return 16; } +double textbox_get_estimated_char_height(void); +double textbox_get_estimated_char_height(void) { return 16; } double textbox_get_estimated_ch(void); double textbox_get_estimated_ch(void) { return 8; } void rofi_view_get_current_monitor(G_GNUC_UNUSED int *width,