Skip to content

Commit 15cdb5c

Browse files
Add option to choose the lib type (shared or static)
Add an option to select build lib (shared or static). Fixing linking failure with libbenchmark 1.7 (could need pthreads).
1 parent 87486d1 commit 15cdb5c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

meson.build

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ int main() {
3434
cancompilefp16 = cpp.compiles(fp16code, args:'-march=sapphirerapids')
3535

3636
subdir('lib')
37-
libsimdsort = shared_library('x86simdsortcpp',
37+
if get_option('lib_type') == 'shared'
38+
libsimdsort = shared_library('x86simdsortcpp',
3839
'lib/x86simdsort.cpp',
3940
include_directories : [src, utils, lib],
4041
link_args : [openmpflags],
@@ -43,6 +44,17 @@ libsimdsort = shared_library('x86simdsortcpp',
4344
install : true,
4445
soversion : 1,
4546
)
47+
else
48+
libsimdsort = static_library('x86simdsortcpp',
49+
'lib/x86simdsort.cpp',
50+
include_directories : [src, utils, lib],
51+
link_args : [openmpflags],
52+
link_with : [libtargets],
53+
gnu_symbol_visibility : 'inlineshidden',
54+
install : true,
55+
pic: true,
56+
)
57+
endif
4658

4759
pkg_mod = import('pkgconfig')
4860
pkg_mod.generate(libraries : libsimdsort,
@@ -68,10 +80,11 @@ endif
6880

6981
if get_option('build_benchmarks')
7082
gbench_dep = dependency('benchmark', required : true, static: false)
83+
thread_dep = dependency('threads') # libbenchmark could need pthread_create
7184
subdir('benchmarks')
7285
benchexe = executable('benchexe',
7386
include_directories : [src, lib, utils, bench],
74-
dependencies : [gbench_dep],
87+
dependencies : [gbench_dep, thread_dep],
7588
link_args: ['-lbenchmark_main', ipplink],
7689
link_whole : [libbench],
7790
link_with : libsimdsort,

meson_options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ option('build_vqsortbench', type : 'boolean', value : true,
88
description : 'Add google vqsort to benchmarks (default: "true").')
99
option('use_openmp', type : 'boolean', value : false,
1010
description : 'Use OpenMP to accelerate key-value sort (default: "false").')
11+
option('lib_type', type : 'string', value : 'shared',
12+
description : 'Library type: shared or static (default: "shared").')
13+

0 commit comments

Comments
 (0)