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.
This commit is contained in:
King_DuckZ 2022-06-03 11:25:48 +02:00
parent d71229fc07
commit 9566553856
5 changed files with 33 additions and 14 deletions

View file

@ -40,16 +40,9 @@ elif os == 'gnu' and arch == 'aarch64'
func_ptr_size = 8 func_ptr_size = 8
endif endif
compiler_opts = [] global_compiler_opts = []
if get_option('wrenpp_with_name_guessing') if get_option('wrenpp_with_name_guessing')
compiler_opts += ['-DWRENPP_WITH_NAME_GUESSING'] global_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
endif endif
conf.set('POINTER_SIZE', ptr_size) conf.set('POINTER_SIZE', ptr_size)

24
src/crc32/meson.build Normal file
View file

@ -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,
)

View file

@ -1,3 +1,6 @@
src_incl = include_directories('.')
subdir('crc32')
project_config_file = configure_file( project_config_file = configure_file(
input: 'pvt_config.h.in', input: 'pvt_config.h.in',
output: 'pvt_config.h', output: 'pvt_config.h',
@ -16,17 +19,16 @@ wrenpp = library(meson.project_name(),
'callback_manager.cpp', 'callback_manager.cpp',
'class_manager.cpp', 'class_manager.cpp',
'wren_class_name_from_type.cpp', 'wren_class_name_from_type.cpp',
'crc32.cpp',
'module_and_name.cpp', 'module_and_name.cpp',
dependencies: [wren_dep], dependencies: [wren_dep, crc32_dep],
include_directories: public_incl, include_directories: public_incl,
install: (not meson.is_subproject() or get_option('default_library')=='shared'), install: (not meson.is_subproject() or get_option('default_library')=='shared'),
c_args: compiler_opts, c_args: global_compiler_opts,
cpp_args: compiler_opts, cpp_args: global_compiler_opts,
) )
wrenpp_dep = declare_dependency( wrenpp_dep = declare_dependency(
link_with: wrenpp, link_with: wrenpp,
include_directories: public_incl, include_directories: public_incl,
compile_args: compiler_opts, compile_args: global_compiler_opts,
) )