From 956655385658a27182fc4e221da66c4753432918 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 3 Jun 2022 11:25:48 +0200 Subject: [PATCH] Extract crc32 code into a separate static lib Following what's been suggested on IRC libera.chat #mesonbuild, this is so that the -march=generic+crc option only applies to the code it should apply to and not to the entire code base. --- meson.build | 11 ++--------- src/{ => crc32}/crc32.cpp | 0 src/crc32/meson.build | 24 ++++++++++++++++++++++++ src/{ => crc32}/sse2neon.h | 0 src/meson.build | 12 +++++++----- 5 files changed, 33 insertions(+), 14 deletions(-) rename src/{ => crc32}/crc32.cpp (100%) create mode 100644 src/crc32/meson.build rename src/{ => crc32}/sse2neon.h (100%) diff --git a/meson.build b/meson.build index dce5f6e..c57f4ab 100644 --- a/meson.build +++ b/meson.build @@ -40,16 +40,9 @@ elif os == 'gnu' and arch == 'aarch64' func_ptr_size = 8 endif -compiler_opts = [] +global_compiler_opts = [] if get_option('wrenpp_with_name_guessing') - compiler_opts += ['-DWRENPP_WITH_NAME_GUESSING'] -endif -if get_option('wrenpp_with_sse42') - if arch == 'amd64' - compiler_opts += ['-msse4.2'] - elif arch == 'aarch64' - compiler_opts += ['-mcpu=generic+crc'] - endif + global_compiler_opts += ['-DWRENPP_WITH_NAME_GUESSING'] endif conf.set('POINTER_SIZE', ptr_size) diff --git a/src/crc32.cpp b/src/crc32/crc32.cpp similarity index 100% rename from src/crc32.cpp rename to src/crc32/crc32.cpp diff --git a/src/crc32/meson.build b/src/crc32/meson.build new file mode 100644 index 0000000..88b408a --- /dev/null +++ b/src/crc32/meson.build @@ -0,0 +1,24 @@ +compiler_opts = [] + +if get_option('wrenpp_with_sse42') + if arch == 'amd64' + compiler_opts += ['-msse4.2'] + elif arch == 'aarch64' + #gcc options here: + #https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/AArch64-Options.html + compiler_opts += ['-mcpu=generic+crc'] + endif +endif + +crc32 = static_library('crc32', + 'crc32.cpp', + include_directories: [public_incl, src_incl], + install: false, + cpp_args: compiler_opts + global_compiler_opts, +) + +crc32_dep = declare_dependency( + include_directories: public_incl, + link_with: crc32, + compile_args: global_compiler_opts, +) diff --git a/src/sse2neon.h b/src/crc32/sse2neon.h similarity index 100% rename from src/sse2neon.h rename to src/crc32/sse2neon.h diff --git a/src/meson.build b/src/meson.build index 2f9d2b0..e6bc345 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,3 +1,6 @@ +src_incl = include_directories('.') +subdir('crc32') + project_config_file = configure_file( input: 'pvt_config.h.in', output: 'pvt_config.h', @@ -16,17 +19,16 @@ wrenpp = library(meson.project_name(), 'callback_manager.cpp', 'class_manager.cpp', 'wren_class_name_from_type.cpp', - 'crc32.cpp', 'module_and_name.cpp', - dependencies: [wren_dep], + dependencies: [wren_dep, crc32_dep], include_directories: public_incl, install: (not meson.is_subproject() or get_option('default_library')=='shared'), - c_args: compiler_opts, - cpp_args: compiler_opts, + c_args: global_compiler_opts, + cpp_args: global_compiler_opts, ) wrenpp_dep = declare_dependency( link_with: wrenpp, include_directories: public_incl, - compile_args: compiler_opts, + compile_args: global_compiler_opts, )