* [PATCH liburing 1/9] add Meson build system
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 2/9] meson: update meson build files for liburing 2.3 Florian Fischer
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Peter Eszlari, Florian Fischer
From: Peter Eszlari <[email protected]>
Meson is a fast and simple build system. Adoption started mainly in the
desktop space (Gnome, X11, Mesa) to replace autotools, but since then,
some low level projects (systemd, qemu) have switched to it too.
Since liburing is a rather small codebase, the difference in
speed and simplicity are not as huge as with other projects.
Nonetheless, there are still some advantages:
* It comes with some nice features (e.g. out-of-source builds),
that one would need to implement in shell otherwise.
* Other projects that use Meson could integrate liburing easily
into their build system by using Meson's subproject() functionality.
* Meson provides some useful editor/IDE integration,
e.g. by generating compile_commands.json for clangd.
* Distribution packagers are provided with a "standard" build system,
with well known options/features/behavior, that is actively developed.
Co-developed-by: Florian Fischer <[email protected]>
Signed-off-by: Peter Eszlari <[email protected]>
Signed-off-by: Florian Fischer <[email protected]>
---
.gitignore | 2 +
examples/meson.build | 17 ++++
man/meson.build | 7 ++
meson.build | 133 ++++++++++++++++++++++++++++
meson_options.txt | 9 ++
src/include/liburing/compat.h.in | 7 ++
src/include/liburing/meson.build | 46 ++++++++++
src/include/meson.build | 3 +
src/meson.build | 17 ++++
test/meson.build | 147 +++++++++++++++++++++++++++++++
10 files changed, 388 insertions(+)
create mode 100644 examples/meson.build
create mode 100644 man/meson.build
create mode 100644 meson.build
create mode 100644 meson_options.txt
create mode 100644 src/include/liburing/compat.h.in
create mode 100644 src/include/liburing/meson.build
create mode 100644 src/include/meson.build
create mode 100644 src/meson.build
create mode 100644 test/meson.build
diff --git a/.gitignore b/.gitignore
index 6e8a2f7..40d3717 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,5 @@ config.log
liburing.pc
cscope.out
+
+/build/
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..becfc02
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,17 @@
+executable('io_uring-cp',
+ 'io_uring-cp.c',
+ dependencies: uring)
+
+executable('io_uring-test',
+ 'io_uring-test.c',
+ dependencies: uring)
+
+executable('link-cp',
+ 'link-cp.c',
+ dependencies: uring)
+
+if has_ucontext
+ executable('ucontext-cp',
+ 'ucontext-cp.c',
+ dependencies: uring)
+endif
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..94e44b3
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,7 @@
+install_man('io_uring.7',
+ 'io_uring_enter.2',
+ 'io_uring_get_sqe.3',
+ 'io_uring_queue_exit.3',
+ 'io_uring_queue_init.3',
+ 'io_uring_register.2',
+ 'io_uring_setup.2')
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..cb7dd9e
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,133 @@
+project('liburing', ['c','cpp'],
+ version: run_command('awk', '/Version:/ { print $2 }', 'liburing.spec').stdout().strip(),
+ license: ['MIT', 'LGPL-2.1-only', 'GPL-2.0-only WITH Linux-syscall-note'],
+ meson_version: '>=0.53.0',
+ default_options: ['default_library=both',
+ 'buildtype=debugoptimized',
+ 'c_std=c11',
+ 'cpp_std=c++11',
+ 'warning_level=3'])
+
+add_project_arguments('-D_GNU_SOURCE',
+ '-D__SANE_USERSPACE_TYPES__',
+ '-include', meson.current_build_dir() + '/config-host.h',
+ '-Wno-unused-parameter',
+ '-Wno-sign-compare',
+ '-fomit-frame-pointer',
+ language: ['c', 'cpp'])
+
+thread_dep = dependency('threads')
+
+cc = meson.get_compiler('c')
+
+code = '''#include <linux/fs.h>
+int main(int argc, char **argv)
+{
+ __kernel_rwf_t x;
+ x = 0;
+ return x;
+}
+'''
+has__kernel_rwf_t = cc.compiles(code, name : '__kernel_rwf_t')
+
+code = '''#include <linux/time.h>
+#include <linux/time_types.h>
+int main(int argc, char **argv)
+{
+ struct __kernel_timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1;
+ return 0;
+}
+'''
+has__kernel_timespec = cc.compiles(code, name : '__kernel_timespec')
+
+code = '''#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+int main(int argc, char **argv)
+{
+ struct open_how how;
+ how.flags = 0;
+ how.mode = 0;
+ how.resolve = 0;
+ return 0;
+}
+'''
+has_open_how = cc.compiles(code, name: 'open_how')
+
+code = '''#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <linux/stat.h>
+int main(int argc, char **argv)
+{
+ struct statx x;
+
+ return memset(&x, 0, sizeof(x)) != NULL;
+}
+'''
+has_statx = cc.compiles(code, name: 'statx')
+
+cpp = meson.get_compiler('cpp')
+
+code = '''#include <iostream>
+int main(int argc, char **argv)
+{
+ std::cout << "Test";
+ return 0;
+}
+'''
+has_cxx = cpp.compiles(code, name: 'C++')
+
+code = '''#include <ucontext.h>
+int main(int argc, char **argv)
+{
+ ucontext_t ctx;
+ getcontext(&ctx);
+ return 0;
+}
+'''
+has_ucontext = cc.compiles(code, name : 'ucontext')
+
+conf_data = configuration_data()
+conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t)
+conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec)
+conf_data.set('CONFIG_HAVE_OPEN_HOW', has_open_how)
+conf_data.set('CONFIG_HAVE_STATX', has_statx)
+conf_data.set('CONFIG_HAVE_CXX', has_cxx)
+conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext)
+configure_file(output: 'config-host.h',
+ configuration: conf_data)
+
+subdir('src')
+subdir('man')
+
+if get_option('examples')
+ subdir('examples')
+endif
+
+if get_option('tests')
+ if get_option('default_library') != 'both'
+ error('default_library=both required to build tests')
+ endif
+ subdir('test')
+endif
+
+pkg_mod = import('pkgconfig')
+pkg_mod.generate(libraries: liburing,
+ name: 'liburing',
+ version: meson.project_version(),
+ description: 'io_uring library',
+ url: 'http://git.kernel.dk/cgit/liburing/')
+
+summary({'bindir': get_option('bindir'),
+ 'libdir': get_option('libdir'),
+ 'datadir': get_option('datadir'),
+ }, section: 'Directories')
+summary({'examples': get_option('examples'),
+ 'tests': get_option('tests')
+ }, section: 'Configuration', bool_yn: true)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..e9f581a
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+option('examples',
+ type : 'boolean',
+ value : false,
+ description : 'Build example programs')
+
+option('tests',
+ type : 'boolean',
+ value : false,
+ description : 'Build test programs')
diff --git a/src/include/liburing/compat.h.in b/src/include/liburing/compat.h.in
new file mode 100644
index 0000000..2e92907
--- /dev/null
+++ b/src/include/liburing/compat.h.in
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: MIT */
+#ifndef LIBURING_COMPAT_H
+#define LIBURING_COMPAT_H
+@__kernel_rwf_t_compat@
+@__kernel_timespec_compat@
+@open_how_compat@
+#endif
diff --git a/src/include/liburing/meson.build b/src/include/liburing/meson.build
new file mode 100644
index 0000000..f60cbc7
--- /dev/null
+++ b/src/include/liburing/meson.build
@@ -0,0 +1,46 @@
+if has__kernel_rwf_t
+ __kernel_rwf_t_compat = ''
+else
+ __kernel_rwf_t_compat = '''typedef int __kernel_rwf_t;
+'''
+endif
+
+if has__kernel_timespec
+ __kernel_timespec_compat = '''#include <linux/time_types.h>
+'''
+else
+ __kernel_timespec_compat = '''#include <stdint.h>
+
+struct __kernel_timespec {
+ int64_t tv_sec;
+ long long tv_nsec;
+};
+'''
+endif
+
+if has_open_how
+ open_how_compat = ''
+else
+ open_how_compat = '''#include <inttypes.h>
+
+struct open_how {
+ uint64_t flags;
+ uint64_t mode;
+ uint64_t resolve;
+};
+'''
+endif
+
+conf_data = configuration_data()
+conf_data.set('__kernel_rwf_t_compat', __kernel_rwf_t_compat)
+conf_data.set('__kernel_timespec_compat', __kernel_timespec_compat)
+conf_data.set('open_how_compat', open_how_compat)
+configure_file(input: 'compat.h.in',
+ output: 'compat.h',
+ configuration: conf_data,
+ install: true,
+ install_dir: get_option('includedir') / 'liburing')
+
+install_headers('barrier.h',
+ 'io_uring.h',
+ subdir: 'liburing')
diff --git a/src/include/meson.build b/src/include/meson.build
new file mode 100644
index 0000000..7d5ddf0
--- /dev/null
+++ b/src/include/meson.build
@@ -0,0 +1,3 @@
+install_headers('liburing.h')
+
+subdir('liburing')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..b3aa751
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,17 @@
+subdir('include')
+
+inc = include_directories(['include'])
+
+liburing = library('uring',
+ 'queue.c',
+ 'register.c',
+ 'setup.c',
+ 'syscall.c',
+ include_directories: inc,
+ link_args: '-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map',
+ link_depends: 'liburing.map',
+ version: meson.project_version(),
+ install: true)
+
+uring = declare_dependency(link_with: liburing,
+ include_directories: inc)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..888b74d
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,147 @@
+all_tests = [['232c93d07b74-test', 'c', thread_dep],
+ ['35fa71a030ca-test', 'c', thread_dep],
+ ['500f9fbadef8-test', 'c', []],
+ ['7ad0e4b2f83c-test', 'c', []],
+ ['8a9973408177-test', 'c', []],
+ ['917257daa0fe-test', 'c', []],
+ ['a0908ae19763-test', 'c', []],
+ ['a4c0b3decb33-test', 'c', []],
+ ['accept', 'c', []],
+ ['accept-link', 'c', thread_dep],
+ ['accept-reuse', 'c', []],
+ ['accept-test', 'c', []],
+ ['across-fork', 'c', thread_dep],
+ ['splice', 'c', []],
+ ['b19062a56726-test', 'c', []],
+ ['b5837bd5311d-test', 'c', []],
+ ['ce593a6c480a-test', 'c', thread_dep],
+ ['close-opath', 'c', []],
+ ['connect', 'c', []],
+ ['cq-full', 'c', []],
+ ['cq-overflow', 'c', []],
+ ['cq-overflow-peek', 'c', []],
+ ['cq-peek-batch', 'c', []],
+ ['cq-ready', 'c', []],
+ ['cq-size', 'c', []],
+ ['d4ae271dfaae-test', 'c', []],
+ ['d77a67ed5f27-test', 'c', []],
+ ['defer', 'c', []],
+ ['double-poll-crash', 'c', []],
+ ['eeed8b54e0df-test', 'c', []],
+ ['eventfd', 'c', []],
+ ['eventfd-disable', 'c', []],
+ ['eventfd-ring', 'c', []],
+ ['fadvise', 'c', []],
+ ['fallocate', 'c', []],
+ ['fc2a85cb02ef-test', 'c', []],
+ ['file-register', 'c', []],
+ ['file-update', 'c', []],
+ ['files-exit-hang-poll', 'c', []],
+ ['files-exit-hang-timeout', 'c', []],
+ ['fixed-link', 'c', []],
+ ['fsync', 'c', []],
+ ['io-cancel', 'c', []],
+ ['io_uring_enter', 'c', []],
+ ['io_uring_register', 'c', []],
+ ['io_uring_setup', 'c', []],
+ ['iopoll', 'c', []],
+ ['lfs-openat', 'c', []],
+ ['lfs-openat-write', 'c', []],
+ ['link', 'c', []],
+ ['link-timeout', 'c', []],
+ ['link_drain', 'c', []],
+ ['madvise', 'c', []],
+ ['nop', 'c', []],
+ ['nop-all-sizes', 'c', []],
+ ['open-close', 'c', []],
+ ['openat2', 'c', []],
+ ['personality', 'c', []],
+ ['pipe-eof', 'c', thread_dep],
+ ['pipe-reuse', 'c', []],
+ ['poll', 'c', []],
+ ['poll-cancel', 'c', []],
+ ['poll-cancel-ton', 'c', []],
+ ['poll-link', 'c', thread_dep],
+ ['poll-many', 'c', []],
+ ['poll-ring', 'c', []],
+ ['poll-v-poll', 'c', thread_dep],
+ ['probe', 'c', []],
+ ['read-write', 'c', []],
+ ['register-restrictions', 'c', []],
+ ['rename', 'c', []],
+ ['ring-leak', 'c', []],
+ ['ring-leak2', 'c', thread_dep],
+ ['self', 'c', []],
+ ['send_recv', 'c', thread_dep],
+ ['send_recvmsg', 'c', thread_dep],
+ ['shared-wq', 'c', []],
+ ['short-read', 'c', []],
+ ['shutdown', 'c', []],
+ ['sigfd-deadlock', 'c', []],
+ ['socket-rw', 'c', []],
+ ['socket-rw-eagain', 'c', []],
+ ['sq-full', 'c', []],
+ ['sq-poll-dup', 'c', []],
+ ['sq-poll-kthread', 'c', []],
+ ['sq-poll-share', 'c', []],
+ ['sqpoll-exit-hang', 'c', []],
+ ['sqpoll-sleep', 'c', []],
+ ['sq-space_left', 'c', []],
+ ['stdout', 'c', []],
+ ['submit-reuse', 'c', thread_dep],
+ ['teardowns', 'c', []],
+ ['thread-exit', 'c', thread_dep],
+ ['timeout', 'c', []],
+ ['timeout-new', 'c', thread_dep],
+ ['timeout-overflow', 'c', []],
+ ['unlink', 'c', []],
+ ['wakeup-hang', 'c', thread_dep]]
+
+if has_statx
+ all_tests += [['statx', 'c', []]]
+endif
+
+if has_cxx
+ all_tests += [['sq-full-cpp', 'cc', []]]
+endif
+
+runtests_sh = find_program('runtests.sh')
+runtests_loop_sh = find_program('runtests-loop.sh')
+
+foreach t : all_tests
+ executable(t[0],
+ t[0] + '.' + t[1],
+ include_directories: inc,
+ link_with: liburing.get_static_lib(),
+ dependencies: t[2],
+ install: true,
+ install_dir: get_option('datadir') / 'liburing-test')
+
+ test(t[0],
+ runtests_sh,
+ args: t[0],
+ workdir : meson.current_build_dir(),
+ suite: 'once')
+
+ test(t[0] + '_loop',
+ runtests_loop_sh,
+ args: t[0],
+ workdir: meson.current_build_dir(),
+ suite: 'loop')
+endforeach
+
+configure_file(input: 'runtests.sh',
+ output: 'runtests.sh',
+ copy: true)
+
+configure_file(input: 'runtests-loop.sh',
+ output: 'runtests-loop.sh',
+ copy: true)
+
+configure_file(input: 'config',
+ output: 'config.local',
+ copy: true)
+
+install_data('runtests.sh',
+ 'runtests-loop.sh',
+ install_dir: get_option('datadir') / 'liburing-test')
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 2/9] meson: update meson build files for liburing 2.3
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 1/9] add Meson build system Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 3/9] meson: update available tests to " Florian Fischer
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
* meson has builtin methods to check if the used compiler supports certain
types and their expected members. Therefore we don't need to check if code
using those types compiles. This makes the build file more readable.
Suggested-By: Nils Tonnätt <[email protected]>
* do not use -Wpedantic like the custom build system
* check if ucontext functions are available. See: b5f2347
* add explicit run_command check kwarg
The default will change in future meson versions causing possible
unexpected behavior.
And the awk command should not fail in the first place.
* set -DLIBURING_INTERNAL introduced in 8be8af4a
* include linux/openat2.h for struct open_how. See: 326ed975
* check if glibc provides struct statx. See: 44b12f5
* use -O3 as default. See: 7d1cce2
* update project CFLAGS. Remove -fomit-frame-pointer (de21479) and
add -fno-stack-protector (2de9832).
Reported-by: Eli Schwartz <[email protected]>
Signed-off-by: Florian Fischer <[email protected]>
---
meson.build | 81 ++++++++++++--------------------
src/include/liburing/meson.build | 7 ++-
src/meson.build | 1 +
test/meson.build | 2 +-
4 files changed, 37 insertions(+), 54 deletions(-)
diff --git a/meson.build b/meson.build
index cb7dd9e..7c91b97 100644
--- a/meson.build
+++ b/meson.build
@@ -1,103 +1,80 @@
project('liburing', ['c','cpp'],
- version: run_command('awk', '/Version:/ { print $2 }', 'liburing.spec').stdout().strip(),
+ version: run_command('awk', '/Version:/ { print $2 }', 'liburing.spec', check: true).stdout().strip(),
license: ['MIT', 'LGPL-2.1-only', 'GPL-2.0-only WITH Linux-syscall-note'],
meson_version: '>=0.53.0',
default_options: ['default_library=both',
'buildtype=debugoptimized',
'c_std=c11',
'cpp_std=c++11',
- 'warning_level=3'])
+ 'optimization=3',
+ 'warning_level=2'])
add_project_arguments('-D_GNU_SOURCE',
'-D__SANE_USERSPACE_TYPES__',
'-include', meson.current_build_dir() + '/config-host.h',
'-Wno-unused-parameter',
'-Wno-sign-compare',
- '-fomit-frame-pointer',
language: ['c', 'cpp'])
thread_dep = dependency('threads')
cc = meson.get_compiler('c')
-code = '''#include <linux/fs.h>
-int main(int argc, char **argv)
-{
- __kernel_rwf_t x;
- x = 0;
- return x;
-}
-'''
-has__kernel_rwf_t = cc.compiles(code, name : '__kernel_rwf_t')
+has__kernel_rwf_t = cc.has_type('__kernel_rwf_t', prefix: '#include <linux/fs.h>')
-code = '''#include <linux/time.h>
-#include <linux/time_types.h>
-int main(int argc, char **argv)
-{
- struct __kernel_timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = 1;
- return 0;
-}
-'''
-has__kernel_timespec = cc.compiles(code, name : '__kernel_timespec')
+has__kernel_timespec = cc.has_members('struct __kernel_timespec',
+ 'tv_sec',
+ 'tv_nsec',
+ prefix: '#include <linux/time.h>')
+
+has_open_how = cc.has_members('struct open_how',
+ 'flags',
+ 'mode',
+ 'resolve',
+ prefix: '#include <linux/openat2.h>')
code = '''#include <sys/types.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <linux/stat.h>
int main(int argc, char **argv)
{
- struct open_how how;
- how.flags = 0;
- how.mode = 0;
- how.resolve = 0;
- return 0;
+ struct statx x;
+
+ return memset(&x, 0, sizeof(x)) != NULL;
}
'''
-has_open_how = cc.compiles(code, name: 'open_how')
+has_statx = cc.compiles(code, name: 'statx')
-code = '''#include <sys/types.h>
-#include <sys/stat.h>
+code= '''#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <linux/stat.h>
-int main(int argc, char **argv)
+main(int argc, char **argv)
{
struct statx x;
return memset(&x, 0, sizeof(x)) != NULL;
}
'''
-has_statx = cc.compiles(code, name: 'statx')
-
-cpp = meson.get_compiler('cpp')
+glibc_statx = cc.compiles(code, name: 'glibc_statx')
-code = '''#include <iostream>
-int main(int argc, char **argv)
-{
- std::cout << "Test";
- return 0;
-}
-'''
-has_cxx = cpp.compiles(code, name: 'C++')
+# Since the project is configured to use C++
+# meson fails if no C++ compiler is available.
+has_cxx = true
-code = '''#include <ucontext.h>
-int main(int argc, char **argv)
-{
- ucontext_t ctx;
- getcontext(&ctx);
- return 0;
-}
-'''
-has_ucontext = cc.compiles(code, name : 'ucontext')
+has_ucontext = (cc.has_type('ucontext_t', prefix: '#include <ucontext.h>')
+ and cc.has_function('makecontext', prefix: '#include <ucontext.h>'))
conf_data = configuration_data()
conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t)
conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec)
conf_data.set('CONFIG_HAVE_OPEN_HOW', has_open_how)
conf_data.set('CONFIG_HAVE_STATX', has_statx)
+conf_data.set('CONFIG_HAVE_GLIBC_STATX', glibc_statx)
conf_data.set('CONFIG_HAVE_CXX', has_cxx)
conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext)
configure_file(output: 'config-host.h',
diff --git a/src/include/liburing/meson.build b/src/include/liburing/meson.build
index f60cbc7..ed5c65b 100644
--- a/src/include/liburing/meson.build
+++ b/src/include/liburing/meson.build
@@ -19,7 +19,7 @@ struct __kernel_timespec {
endif
if has_open_how
- open_how_compat = ''
+ open_how_compat = '#include <linux/openat2.h>'
else
open_how_compat = '''#include <inttypes.h>
@@ -35,6 +35,11 @@ conf_data = configuration_data()
conf_data.set('__kernel_rwf_t_compat', __kernel_rwf_t_compat)
conf_data.set('__kernel_timespec_compat', __kernel_timespec_compat)
conf_data.set('open_how_compat', open_how_compat)
+
+if not glibc_statx and has_statx
+ conf_data.set('no_glibc_statx', '#include <stat/stat.h>')
+endif
+
configure_file(input: 'compat.h.in',
output: 'compat.h',
configuration: conf_data,
diff --git a/src/meson.build b/src/meson.build
index b3aa751..fad0fca 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -8,6 +8,7 @@ liburing = library('uring',
'setup.c',
'syscall.c',
include_directories: inc,
+ c_args: ['-DLIBURING_INTERNAL', '-fno-stack-protector'],
link_args: '-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map',
link_depends: 'liburing.map',
version: meson.project_version(),
diff --git a/test/meson.build b/test/meson.build
index 888b74d..60b50c2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -97,7 +97,7 @@ all_tests = [['232c93d07b74-test', 'c', thread_dep],
['unlink', 'c', []],
['wakeup-hang', 'c', thread_dep]]
-if has_statx
+if has_statx or glibc_statx
all_tests += [['statx', 'c', []]]
endif
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 3/9] meson: update available tests to liburing 2.3
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 1/9] add Meson build system Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 2/9] meson: update meson build files for liburing 2.3 Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 4/9] meson: update installed manpages " Florian Fischer
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
* Update the available tests.
* Check for -Warray-bound and -Wstringop-overflow and use them if available.
Include test/helper.c when building the test executables.
* Bump required meson version from 0.53 to 0.54 to use fs.stem.
* Simplify the meson test definition code by using a plain list of source
files instead of the complex list of lists.
Obtain the test name by stripping the file suffix from the test source
using the meson fs module.
* Link each test with the thread dependency similar to: 664bf78.
* Run tests sequentially to prevent dmesg log intermixing expected
by the test tooling.
Suggested-by: Eli Schwartz <[email protected]>
* Add a 'parallel' test suite to mirror make test-parallel.
Signed-off-by: Florian Fischer <[email protected]>
---
meson.build | 3 +
test/meson.build | 306 ++++++++++++++++++++++++++++-------------------
2 files changed, 187 insertions(+), 122 deletions(-)
diff --git a/meson.build b/meson.build
index 7c91b97..0a63fef 100644
--- a/meson.build
+++ b/meson.build
@@ -20,6 +20,9 @@ thread_dep = dependency('threads')
cc = meson.get_compiler('c')
+has_stringop_overflow = cc.has_argument('-Wstringop-overflow=0')
+has_array_bounds = cc.has_argument('-Warray-bounds=0')
+
has__kernel_rwf_t = cc.has_type('__kernel_rwf_t', prefix: '#include <linux/fs.h>')
has__kernel_timespec = cc.has_members('struct __kernel_timespec',
diff --git a/test/meson.build b/test/meson.build
index 60b50c2..4d9b3f3 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,147 +1,209 @@
-all_tests = [['232c93d07b74-test', 'c', thread_dep],
- ['35fa71a030ca-test', 'c', thread_dep],
- ['500f9fbadef8-test', 'c', []],
- ['7ad0e4b2f83c-test', 'c', []],
- ['8a9973408177-test', 'c', []],
- ['917257daa0fe-test', 'c', []],
- ['a0908ae19763-test', 'c', []],
- ['a4c0b3decb33-test', 'c', []],
- ['accept', 'c', []],
- ['accept-link', 'c', thread_dep],
- ['accept-reuse', 'c', []],
- ['accept-test', 'c', []],
- ['across-fork', 'c', thread_dep],
- ['splice', 'c', []],
- ['b19062a56726-test', 'c', []],
- ['b5837bd5311d-test', 'c', []],
- ['ce593a6c480a-test', 'c', thread_dep],
- ['close-opath', 'c', []],
- ['connect', 'c', []],
- ['cq-full', 'c', []],
- ['cq-overflow', 'c', []],
- ['cq-overflow-peek', 'c', []],
- ['cq-peek-batch', 'c', []],
- ['cq-ready', 'c', []],
- ['cq-size', 'c', []],
- ['d4ae271dfaae-test', 'c', []],
- ['d77a67ed5f27-test', 'c', []],
- ['defer', 'c', []],
- ['double-poll-crash', 'c', []],
- ['eeed8b54e0df-test', 'c', []],
- ['eventfd', 'c', []],
- ['eventfd-disable', 'c', []],
- ['eventfd-ring', 'c', []],
- ['fadvise', 'c', []],
- ['fallocate', 'c', []],
- ['fc2a85cb02ef-test', 'c', []],
- ['file-register', 'c', []],
- ['file-update', 'c', []],
- ['files-exit-hang-poll', 'c', []],
- ['files-exit-hang-timeout', 'c', []],
- ['fixed-link', 'c', []],
- ['fsync', 'c', []],
- ['io-cancel', 'c', []],
- ['io_uring_enter', 'c', []],
- ['io_uring_register', 'c', []],
- ['io_uring_setup', 'c', []],
- ['iopoll', 'c', []],
- ['lfs-openat', 'c', []],
- ['lfs-openat-write', 'c', []],
- ['link', 'c', []],
- ['link-timeout', 'c', []],
- ['link_drain', 'c', []],
- ['madvise', 'c', []],
- ['nop', 'c', []],
- ['nop-all-sizes', 'c', []],
- ['open-close', 'c', []],
- ['openat2', 'c', []],
- ['personality', 'c', []],
- ['pipe-eof', 'c', thread_dep],
- ['pipe-reuse', 'c', []],
- ['poll', 'c', []],
- ['poll-cancel', 'c', []],
- ['poll-cancel-ton', 'c', []],
- ['poll-link', 'c', thread_dep],
- ['poll-many', 'c', []],
- ['poll-ring', 'c', []],
- ['poll-v-poll', 'c', thread_dep],
- ['probe', 'c', []],
- ['read-write', 'c', []],
- ['register-restrictions', 'c', []],
- ['rename', 'c', []],
- ['ring-leak', 'c', []],
- ['ring-leak2', 'c', thread_dep],
- ['self', 'c', []],
- ['send_recv', 'c', thread_dep],
- ['send_recvmsg', 'c', thread_dep],
- ['shared-wq', 'c', []],
- ['short-read', 'c', []],
- ['shutdown', 'c', []],
- ['sigfd-deadlock', 'c', []],
- ['socket-rw', 'c', []],
- ['socket-rw-eagain', 'c', []],
- ['sq-full', 'c', []],
- ['sq-poll-dup', 'c', []],
- ['sq-poll-kthread', 'c', []],
- ['sq-poll-share', 'c', []],
- ['sqpoll-exit-hang', 'c', []],
- ['sqpoll-sleep', 'c', []],
- ['sq-space_left', 'c', []],
- ['stdout', 'c', []],
- ['submit-reuse', 'c', thread_dep],
- ['teardowns', 'c', []],
- ['thread-exit', 'c', thread_dep],
- ['timeout', 'c', []],
- ['timeout-new', 'c', thread_dep],
- ['timeout-overflow', 'c', []],
- ['unlink', 'c', []],
- ['wakeup-hang', 'c', thread_dep]]
+all_tests = [
+ '232c93d07b74.c',
+ '35fa71a030ca.c',
+ '500f9fbadef8.c',
+ '7ad0e4b2f83c.c',
+ '8a9973408177.c',
+ '917257daa0fe.c',
+ 'a0908ae19763.c',
+ 'a4c0b3decb33.c',
+ 'accept.c',
+ 'accept-link.c',
+ 'accept-reuse.c',
+ 'accept-test.c',
+ 'across-fork.c',
+ 'b19062a56726.c',
+ 'b5837bd5311d.c',
+ 'buf-ring.c',
+ 'ce593a6c480a.c',
+ 'close-opath.c',
+ 'connect.c',
+ 'cq-full.c',
+ 'cq-overflow.c',
+ 'cq-peek-batch.c',
+ 'cq-ready.c',
+ 'cq-size.c',
+ 'd4ae271dfaae.c',
+ 'd77a67ed5f27.c',
+ 'defer.c',
+ 'double-poll-crash.c',
+ 'drop-submit.c',
+ 'eeed8b54e0df.c',
+ 'empty-eownerdead.c',
+ 'eventfd.c',
+ 'eventfd-disable.c',
+ 'eventfd-reg.c',
+ 'eventfd-ring.c',
+ 'exec-target.c',
+ 'exit-no-cleanup.c',
+ 'fadvise.c',
+ 'fallocate.c',
+ 'fc2a85cb02ef.c',
+ 'fd-pass.c',
+ 'file-register.c',
+ 'files-exit-hang-poll.c',
+ 'files-exit-hang-timeout.c',
+ 'file-update.c',
+ 'file-verify.c',
+ 'fixed-buf-iter.c',
+ 'fixed-link.c',
+ 'fixed-reuse.c',
+ 'fpos.c',
+ 'fsync.c',
+ 'hardlink.c',
+ 'io-cancel.c',
+ 'iopoll.c',
+ 'io_uring_enter.c',
+ 'io_uring_register.c',
+ 'io_uring_setup.c',
+ 'lfs-openat.c',
+ 'lfs-openat-write.c',
+ 'link.c',
+ 'link_drain.c',
+ 'link-timeout.c',
+ 'madvise.c',
+ 'mkdir.c',
+ 'msg-ring.c',
+ 'multicqes_drain.c',
+ 'nolibc.c',
+ 'nop-all-sizes.c',
+ 'nop.c',
+ 'openat2.c',
+ 'open-close.c',
+ 'open-direct-link.c',
+ 'open-direct-pick.c',
+ 'personality.c',
+ 'pipe-eof.c',
+ 'pipe-reuse.c',
+ 'poll.c',
+ 'poll-cancel.c',
+ 'poll-cancel-all.c',
+ 'poll-cancel-ton.c',
+ 'poll-link.c',
+ 'poll-many.c',
+ 'poll-mshot-overflow.c',
+ 'poll-mshot-update.c',
+ 'poll-ring.c',
+ 'poll-v-poll.c',
+ 'pollfree.c',
+ 'probe.c',
+ 'read-before-exit.c',
+ 'read-write.c',
+ 'recv-msgall.c',
+ 'recv-msgall-stream.c',
+ 'recv-multishot.c',
+ 'register-restrictions.c',
+ 'rename.c',
+ 'ring-leak2.c',
+ 'ring-leak.c',
+ 'rsrc_tags.c',
+ 'rw_merge_test.c',
+ 'self.c',
+ 'send_recv.c',
+ 'sendmsg_fs_cve.c',
+ 'send_recvmsg.c',
+ 'send-zerocopy.c',
+ 'shared-wq.c',
+ 'short-read.c',
+ 'shutdown.c',
+ 'sigfd-deadlock.c',
+ 'single-issuer.c',
+ 'skip-cqe.c',
+ 'socket.c',
+ 'socket-rw.c',
+ 'socket-rw-eagain.c',
+ 'socket-rw-offset.c',
+ 'splice.c',
+ 'sq-full.c',
+ 'sqpoll-cancel-hang.c',
+ 'sqpoll-disable-exit.c',
+ 'sq-poll-dup.c',
+ 'sqpoll-exit-hang.c',
+ 'sq-poll-kthread.c',
+ 'sq-poll-share.c',
+ 'sqpoll-sleep.c',
+ 'sq-space_left.c',
+ 'stdout.c',
+ 'submit-link-fail.c',
+ 'submit-reuse.c',
+ 'symlink.c',
+ 'sync-cancel.c',
+ 'teardowns.c',
+ 'thread-exit.c',
+ 'timeout.c',
+ 'timeout-new.c',
+ 'timeout-overflow.c',
+ 'tty-write-dpoll.c',
+ 'unlink.c',
+ 'wakeup-hang.c',
+ 'xattr.c',
+]
if has_statx or glibc_statx
- all_tests += [['statx', 'c', []]]
+ all_tests += ['statx.c']
endif
if has_cxx
- all_tests += [['sq-full-cpp', 'cc', []]]
+ all_tests += ['sq-full-cpp.cc']
endif
runtests_sh = find_program('runtests.sh')
runtests_loop_sh = find_program('runtests-loop.sh')
+runtests_quiet_sh = find_program('runtests-quiet.sh')
-foreach t : all_tests
- executable(t[0],
- t[0] + '.' + t[1],
+xcflags = []
+if has_stringop_overflow
+ xcflags = xcflags + ['-Wstringop-overflow=0']
+endif
+if has_array_bounds
+ xcflags = xcflags + ['-Warray-bounds=0']
+endif
+
+test_dependencies = [thread_dep]
+
+foreach test_source: all_tests
+ # Tests are not allowed to contain multiple '.' in their name
+ # using the meson filesystem module would solve this restriction
+ # but require to bump our minimum meson version to '>= 0.54'.
+ test_name = test_source.split()[0]
+ executable(test_name,
+ [test_source, 'helpers.c'],
+ c_args: xcflags,
+ cpp_args: xcflags,
include_directories: inc,
link_with: liburing.get_static_lib(),
- dependencies: t[2],
+ dependencies: test_dependencies,
install: true,
install_dir: get_option('datadir') / 'liburing-test')
- test(t[0],
+ test(test_name,
runtests_sh,
- args: t[0],
- workdir : meson.current_build_dir(),
+ args: test_name,
+ is_parallel: false,
+ workdir: meson.current_build_dir(),
suite: 'once')
- test(t[0] + '_loop',
+ test(test_name + '_loop',
runtests_loop_sh,
- args: t[0],
+ args: test_name,
+ is_parallel: false,
workdir: meson.current_build_dir(),
suite: 'loop')
-endforeach
-configure_file(input: 'runtests.sh',
- output: 'runtests.sh',
- copy: true)
+ test(test_name + '_quiet',
+ runtests_quiet_sh,
+ args: test_name,
+ workdir: meson.current_build_dir(),
+ suite: 'parallel')
+endforeach
-configure_file(input: 'runtests-loop.sh',
- output: 'runtests-loop.sh',
- copy: true)
+test_runners = ['runtests.sh', 'runtests-loop.sh', 'runtests-quiet.sh']
-configure_file(input: 'config',
- output: 'config.local',
- copy: true)
+foreach test_runner: test_runners
+ configure_file(input: test_runner,
+ output: test_runner,
+ copy: true)
-install_data('runtests.sh',
- 'runtests-loop.sh',
- install_dir: get_option('datadir') / 'liburing-test')
+ install_data(test_runner,
+ install_dir: get_option('datadir') / 'liburing-test')
+endforeach
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 4/9] meson: update installed manpages to liburing 2.3
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (2 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 3/9] meson: update available tests to " Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 5/9] meson: add default test setup running each test once Florian Fischer
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
Signed-off-by: Florian Fischer <[email protected]>
---
man/meson.build | 123 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 116 insertions(+), 7 deletions(-)
diff --git a/man/meson.build b/man/meson.build
index 94e44b3..8f4ec7e 100644
--- a/man/meson.build
+++ b/man/meson.build
@@ -1,7 +1,116 @@
-install_man('io_uring.7',
- 'io_uring_enter.2',
- 'io_uring_get_sqe.3',
- 'io_uring_queue_exit.3',
- 'io_uring_queue_init.3',
- 'io_uring_register.2',
- 'io_uring_setup.2')
+install_man(
+ 'io_uring.7',
+ 'io_uring_buf_ring_add.3',
+ 'io_uring_buf_ring_advance.3',
+ 'io_uring_buf_ring_cq_advance.3',
+ 'io_uring_buf_ring_init.3',
+ 'io_uring_buf_ring_mask.3',
+ 'io_uring_cq_advance.3',
+ 'io_uring_cqe_get_data.3',
+ 'io_uring_cqe_get_data64.3',
+ 'io_uring_cqe_seen.3',
+ 'io_uring_cq_ready.3',
+ 'io_uring_enter.2',
+ 'io_uring_free_probe.3',
+ 'io_uring_get_probe.3',
+ 'io_uring_get_sqe.3',
+ 'io_uring_opcode_supported.3',
+ 'io_uring_peek_cqe.3',
+ 'io_uring_prep_accept.3',
+ 'io_uring_prep_accept_direct.3',
+ 'io_uring_prep_cancel.3',
+ 'io_uring_prep_close.3',
+ 'io_uring_prep_close_direct.3',
+ 'io_uring_prep_connect.3',
+ 'io_uring_prep_fadvise.3',
+ 'io_uring_prep_fallocate.3',
+ 'io_uring_prep_files_update.3',
+ 'io_uring_prep_fsync.3',
+ 'io_uring_prep_link.3',
+ 'io_uring_prep_linkat.3',
+ 'io_uring_prep_madvise.3',
+ 'io_uring_prep_mkdir.3',
+ 'io_uring_prep_mkdirat.3',
+ 'io_uring_prep_msg_ring.3',
+ 'io_uring_prep_multishot_accept.3',
+ 'io_uring_prep_multishot_accept_direct.3',
+ 'io_uring_prep_openat2.3',
+ 'io_uring_prep_openat2_direct.3',
+ 'io_uring_prep_openat.3',
+ 'io_uring_prep_openat_direct.3',
+ 'io_uring_prep_poll_add.3',
+ 'io_uring_prep_poll_multishot.3',
+ 'io_uring_prep_poll_remove.3',
+ 'io_uring_prep_poll_update.3',
+ 'io_uring_prep_provide_buffers.3',
+ 'io_uring_prep_read.3',
+ 'io_uring_prep_read_fixed.3',
+ 'io_uring_prep_readv2.3',
+ 'io_uring_prep_readv.3',
+ 'io_uring_prep_recv.3',
+ 'io_uring_prep_recv_multishot.3',
+ 'io_uring_prep_recvmsg.3',
+ 'io_uring_prep_recvmsg_multishot.3',
+ 'io_uring_prep_remove_buffers.3',
+ 'io_uring_prep_rename.3',
+ 'io_uring_prep_renameat.3',
+ 'io_uring_prep_send.3',
+ 'io_uring_prep_sendmsg.3',
+ 'io_uring_prep_shutdown.3',
+ 'io_uring_prep_socket.3',
+ 'io_uring_prep_socket_direct.3',
+ 'io_uring_prep_splice.3',
+ 'io_uring_prep_statx.3',
+ 'io_uring_prep_symlink.3',
+ 'io_uring_prep_symlinkat.3',
+ 'io_uring_prep_sync_file_range.3',
+ 'io_uring_prep_tee.3',
+ 'io_uring_prep_timeout.3',
+ 'io_uring_prep_timeout_remove.3',
+ 'io_uring_prep_timeout_update.3',
+ 'io_uring_prep_unlink.3',
+ 'io_uring_prep_unlinkat.3',
+ 'io_uring_prep_write.3',
+ 'io_uring_prep_write_fixed.3',
+ 'io_uring_prep_writev2.3',
+ 'io_uring_prep_writev.3',
+ 'io_uring_queue_exit.3',
+ 'io_uring_queue_init.3',
+ 'io_uring_queue_init_params.3',
+ 'io_uring_recvmsg_cmsg_firsthdr.3',
+ 'io_uring_recvmsg_cmsg_nexthdr.3',
+ 'io_uring_recvmsg_name.3',
+ 'io_uring_recvmsg_out.3',
+ 'io_uring_recvmsg_payload.3',
+ 'io_uring_recvmsg_payload_length.3',
+ 'io_uring_recvmsg_validate.3',
+ 'io_uring_register.2',
+ 'io_uring_register_buffers.3',
+ 'io_uring_register_buf_ring.3',
+ 'io_uring_register_eventfd.3',
+ 'io_uring_register_eventfd_async.3',
+ 'io_uring_register_files.3',
+ 'io_uring_register_iowq_aff.3',
+ 'io_uring_register_iowq_max_workers.3',
+ 'io_uring_register_ring_fd.3',
+ 'io_uring_setup.2',
+ 'io_uring_sqe_set_data.3',
+ 'io_uring_sqe_set_data64.3',
+ 'io_uring_sqe_set_flags.3',
+ 'io_uring_sq_ready.3',
+ 'io_uring_sqring_wait.3',
+ 'io_uring_sq_space_left.3',
+ 'io_uring_submit.3',
+ 'io_uring_submit_and_wait.3',
+ 'io_uring_submit_and_wait_timeout.3',
+ 'io_uring_unregister_buffers.3',
+ 'io_uring_unregister_buf_ring.3',
+ 'io_uring_unregister_eventfd.3',
+ 'io_uring_unregister_files.3',
+ 'io_uring_unregister_iowq_aff.3',
+ 'io_uring_unregister_ring_fd.3',
+ 'io_uring_wait_cqe.3',
+ 'io_uring_wait_cqe_nr.3',
+ 'io_uring_wait_cqes.3',
+ 'io_uring_wait_cqe_timeout.3',
+)
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 5/9] meson: add default test setup running each test once
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (3 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 4/9] meson: update installed manpages " Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 6/9] meson: support building without libc Florian Fischer
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer, Eli Schwartz
With this patch running `meson test` in the build directory behaves like
`make -C test runtests`.
To execute the other test suites (running the tests in a loop or in
parallel) run: `meson test --suite=loop` or `meson test --suite=parallel`.
Suggested-by: Eli Schwartz <[email protected]>
Signed-off-by: Florian Fischer <[email protected]>
---
test/meson.build | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/test/meson.build b/test/meson.build
index 4d9b3f3..af394a4 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -197,6 +197,12 @@ foreach test_source: all_tests
suite: 'parallel')
endforeach
+if meson.version().version_compare('>=0.57')
+ add_test_setup('runtests',
+ exclude_suites: ['loop', 'parallel'],
+ is_default: true)
+endif
+
test_runners = ['runtests.sh', 'runtests-loop.sh', 'runtests-quiet.sh']
foreach test_runner: test_runners
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 6/9] meson: support building without libc
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (4 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 5/9] meson: add default test setup running each test once Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 7/9] meson: add 'raw' test suite Florian Fischer
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
Introduce a new meson option 'nolibc'.
Include the headers in src/arch when building liburing.
Build the src/syscall.c as seperate library for the tests when building
without libc.
Signed-off-by: Florian Fischer <[email protected]>
---
meson.build | 8 +++++++-
meson_options.txt | 5 +++++
src/meson.build | 28 +++++++++++++++++++---------
test/meson.build | 2 +-
4 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/meson.build b/meson.build
index 0a63fef..e88e060 100644
--- a/meson.build
+++ b/meson.build
@@ -72,6 +72,10 @@ has_cxx = true
has_ucontext = (cc.has_type('ucontext_t', prefix: '#include <ucontext.h>')
and cc.has_function('makecontext', prefix: '#include <ucontext.h>'))
+nolibc = get_option('nolibc')
+
+build_tests = get_option('tests')
+
conf_data = configuration_data()
conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t)
conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec)
@@ -80,6 +84,8 @@ conf_data.set('CONFIG_HAVE_STATX', has_statx)
conf_data.set('CONFIG_HAVE_GLIBC_STATX', glibc_statx)
conf_data.set('CONFIG_HAVE_CXX', has_cxx)
conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext)
+conf_data.set('CONFIG_NOLIBC', nolibc)
+conf_data.set('LIBURING_BUILD_TEST', build_tests)
configure_file(output: 'config-host.h',
configuration: conf_data)
@@ -90,7 +96,7 @@ if get_option('examples')
subdir('examples')
endif
-if get_option('tests')
+if build_tests
if get_option('default_library') != 'both'
error('default_library=both required to build tests')
endif
diff --git a/meson_options.txt b/meson_options.txt
index e9f581a..5579b39 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,8 @@ option('tests',
type : 'boolean',
value : false,
description : 'Build test programs')
+
+option('nolibc',
+ type : 'boolean',
+ value : false,
+ description : 'Build liburing without libc')
diff --git a/src/meson.build b/src/meson.build
index fad0fca..8dd8139 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,18 +1,28 @@
subdir('include')
-inc = include_directories(['include'])
+liburing_includes = include_directories(['include'])
+liburing_internal_includes = [liburing_includes]
+
+liburing_sources = ['queue.c', 'register.c', 'setup.c']
+liburing_c_args = ['-DLIBURING_INTERNAL', '-fno-stack-protector']
+liburing_link_args = ['-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map']
+
+if nolibc
+ liburing_internal_includes += include_directories(['arch'])
+
+ liburing_sources += ['nolibc.c']
+ liburing_c_args += ['-nostdlib', '-nodefaultlibs', '-ffreestanding']
+ liburing_link_args += ['-nostdlib', '-nodefaultlibs']
+endif
liburing = library('uring',
- 'queue.c',
- 'register.c',
- 'setup.c',
- 'syscall.c',
- include_directories: inc,
- c_args: ['-DLIBURING_INTERNAL', '-fno-stack-protector'],
- link_args: '-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map',
+ liburing_sources,
+ include_directories: liburing_internal_includes,
+ c_args: liburing_c_args,
+ link_args: liburing_link_args,
link_depends: 'liburing.map',
version: meson.project_version(),
install: true)
uring = declare_dependency(link_with: liburing,
- include_directories: inc)
+ include_directories: liburing_includes)
diff --git a/test/meson.build b/test/meson.build
index af394a4..1537ad9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -170,7 +170,7 @@ foreach test_source: all_tests
[test_source, 'helpers.c'],
c_args: xcflags,
cpp_args: xcflags,
- include_directories: inc,
+ include_directories: liburing_internal_includes,
link_with: liburing.get_static_lib(),
dependencies: test_dependencies,
install: true,
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 7/9] meson: add 'raw' test suite
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (5 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 6/9] meson: support building without libc Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 8/9] github bot: add jobs for meson Florian Fischer
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
The 'raw' test suite runs each compiled test without the runtest*.sh
wrapper scripts.
This is useful to debug tests using meson's gdb support.
To debug a test in gdb run `meson test -C build --suite=raw <testname>_raw`
Signed-off-by: Florian Fischer <[email protected]>
---
test/meson.build | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/test/meson.build b/test/meson.build
index 1537ad9..088b5fa 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -166,15 +166,15 @@ foreach test_source: all_tests
# using the meson filesystem module would solve this restriction
# but require to bump our minimum meson version to '>= 0.54'.
test_name = test_source.split()[0]
- executable(test_name,
- [test_source, 'helpers.c'],
- c_args: xcflags,
- cpp_args: xcflags,
- include_directories: liburing_internal_includes,
- link_with: liburing.get_static_lib(),
- dependencies: test_dependencies,
- install: true,
- install_dir: get_option('datadir') / 'liburing-test')
+ test_exe = executable(test_name,
+ [test_source, 'helpers.c'],
+ c_args: xcflags,
+ cpp_args: xcflags,
+ include_directories: liburing_internal_includes,
+ link_with: liburing.get_static_lib(),
+ dependencies: test_dependencies,
+ install: true,
+ install_dir: get_option('datadir') / 'liburing-test')
test(test_name,
runtests_sh,
@@ -195,6 +195,10 @@ foreach test_source: all_tests
args: test_name,
workdir: meson.current_build_dir(),
suite: 'parallel')
+
+ test(test_name + '_raw',
+ test_exe,
+ suite: 'raw')
endforeach
if meson.version().version_compare('>=0.57')
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 8/9] github bot: add jobs for meson
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (6 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 7/9] meson: add 'raw' test suite Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 9/9] meson: update available examples to liburing 2.3 Florian Fischer
2022-07-27 19:21 ` [PATCH liburing] add additional meson build system support Bart Van Assche
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer, Ammar Faizi
* Use meson CPU family names in matrix
* Install meson and ninja
* Create a cross compilation file
* Build with meson
* Build nolibc variant with meson
* Test installation with meson
Acked-by: Ammar Faizi <[email protected]>
Signed-off-by: Florian Fischer <[email protected]>
---
.github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 333929c..95fd892 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,7 +28,7 @@ jobs:
cxx: clang++
# x86 (32-bit) gcc
- - arch: i686
+ - arch: x86
cc_pkg: gcc-i686-linux-gnu
cxx_pkg: g++-i686-linux-gnu
cc: i686-linux-gnu-gcc
@@ -49,14 +49,14 @@ jobs:
cxx: arm-linux-gnueabi-g++
# powerpc64
- - arch: powerpc64
+ - arch: ppc64
cc_pkg: gcc-powerpc64-linux-gnu
cxx_pkg: g++-powerpc64-linux-gnu
cc: powerpc64-linux-gnu-gcc
cxx: powerpc64-linux-gnu-g++
# powerpc
- - arch: powerpc
+ - arch: ppc
cc_pkg: gcc-powerpc-linux-gnu
cxx_pkg: g++-powerpc-linux-gnu
cc: powerpc-linux-gnu-gcc
@@ -85,6 +85,8 @@ jobs:
env:
FLAGS: -g -O3 -Wall -Wextra -Werror
+ MESON_BUILDDIR: build
+ MESON_CROSS_FILE: /tmp/cross-env.txt
steps:
- name: Checkout source
@@ -114,7 +116,7 @@ jobs:
- name: Build nolibc
run: |
- if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "i686" || "${{matrix.arch}}" == "aarch64" ]]; then \
+ if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "x86" || "${{matrix.arch}}" == "aarch64" ]]; then \
make clean; \
./configure --cc=${{matrix.cc}} --cxx=${{matrix.cxx}} --nolibc; \
make -j$(nproc) V=1 CPPFLAGS="-Werror" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS"; \
@@ -125,3 +127,38 @@ jobs:
- name: Test install command
run: |
sudo make install;
+
+ - name: Install meson
+ run: |
+ sudo apt-get update -y;
+ sudo apt-get install -y meson;
+
+ - name: Generate meson cross file
+ run: |
+ { \
+ echo -e "[host_machine]\nsystem = 'linux'"; \
+ echo "cpu_family = '${{matrix.arch}}'"; \
+ echo "cpu = '${{matrix.arch}}'"; \
+ echo "endian = 'big'"; \
+ echo -e "[binaries]\nc = '/usr/bin/${{matrix.cc}}'"; \
+ echo "cpp = '/usr/bin/${{matrix.cxx}}'"; \
+ } > "$MESON_CROSS_FILE"
+
+ - name: Build with meson
+ run: |
+ meson setup "$MESON_BUILDDIR" -Dtests=true -Dexamples=true --cross-file "$MESON_CROSS_FILE";
+ ninja -C "$MESON_BUILDDIR";
+
+ - name: Build nolibc with meson
+ run: |
+ if [[ "${{matrix.arch}}" == "x86_64" || "${{matrix.arch}}" == "x86" || "${{matrix.arch}}" == "aarch64" ]]; then \
+ rm -r "$MESON_BUILDDIR"; \
+ meson setup "$MESON_BUILDDIR" -Dnolibc=true -Dtests=true -Dexamples=true --cross-file "$MESON_CROSS_FILE"; \
+ ninja -C "$MESON_BUILDDIR"; \
+ else \
+ echo "Skipping nolibc build, this arch doesn't support building liburing without libc"; \
+ fi;
+
+ - name: Test meson install
+ run: |
+ sudo meson install -C "$MESON_BUILDDIR"
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH liburing 9/9] meson: update available examples to liburing 2.3
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (7 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 8/9] github bot: add jobs for meson Florian Fischer
@ 2022-07-27 15:27 ` Florian Fischer
2022-07-27 19:21 ` [PATCH liburing] add additional meson build system support Bart Van Assche
9 siblings, 0 replies; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 15:27 UTC (permalink / raw)
To: io-uring; +Cc: Florian Schmaus, Florian Fischer
Use an array of sources instead of declaring each example individually.
Add examples introduced by Pavel and Dylan in 82001392, c1d15e78 and 61d472b.
Signed-off-by: Florian Fischer <[email protected]>
---
examples/meson.build | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/examples/meson.build b/examples/meson.build
index becfc02..e7f5daf 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,17 +1,19 @@
-executable('io_uring-cp',
- 'io_uring-cp.c',
- dependencies: uring)
-
-executable('io_uring-test',
- 'io_uring-test.c',
- dependencies: uring)
-
-executable('link-cp',
- 'link-cp.c',
- dependencies: uring)
+example_sources = [
+ 'io_uring-cp.c',
+ 'io_uring-test.c',
+ 'io_uring-udp.c',
+ 'link-cp.c',
+ 'poll-bench.c',
+ 'send-zerocopy.c',
+]
if has_ucontext
- executable('ucontext-cp',
- 'ucontext-cp.c',
- dependencies: uring)
+ example_sources += ['ucontext-cp.c']
endif
+
+foreach source: example_sources
+ name = source.split('.')[0]
+ executable(name,
+ source,
+ dependencies: uring)
+endforeach
--
2.37.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH liburing] add additional meson build system support
2022-07-27 15:27 [PATCH liburing] add additional meson build system support Florian Fischer
` (8 preceding siblings ...)
2022-07-27 15:27 ` [PATCH liburing 9/9] meson: update available examples to liburing 2.3 Florian Fischer
@ 2022-07-27 19:21 ` Bart Van Assche
2022-07-27 20:53 ` Florian Fischer
9 siblings, 1 reply; 13+ messages in thread
From: Bart Van Assche @ 2022-07-27 19:21 UTC (permalink / raw)
To: Florian Fischer, io-uring; +Cc: Florian Schmaus
On 7/27/22 08:27, Florian Fischer wrote:
> 11 files changed, 619 insertions(+), 4 deletions(-)
To me this diffstat tells me that this patch series adds a lot of
complexity instead of removing complexity. That leaves me wondering what
the advantages of this patch series are?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH liburing] add additional meson build system support
2022-07-27 19:21 ` [PATCH liburing] add additional meson build system support Bart Van Assche
@ 2022-07-27 20:53 ` Florian Fischer
2022-07-29 7:47 ` Florian Schmaus
0 siblings, 1 reply; 13+ messages in thread
From: Florian Fischer @ 2022-07-27 20:53 UTC (permalink / raw)
To: Bart Van Assche; +Cc: io-uring, Florian Schmaus
On 27.07.2022 12:21, Bart Van Assche wrote:
> On 7/27/22 08:27, Florian Fischer wrote:
> > 11 files changed, 619 insertions(+), 4 deletions(-)
>
> To me this diffstat tells me that this patch series adds a lot of complexity
> instead of removing complexity.
That's because Jens wants to keep both build systems in the repository.
.github/workflows/build.yml | 44 +++++--
.gitignore | 2 +
Makefile | 84 ------------
Makefile.common | 6 -
Makefile.quiet | 11 --
configure | 467 -----------------------------------------------------------------
examples/Makefile | 41 ------
examples/meson.build | 19 +++
man/meson.build | 116 ++++++++++++++++
meson.build | 119 +++++++++++++++++
meson_options.txt | 14 ++
src/Makefile | 87 ------------
src/include/liburing/compat.h.in | 7 +
src/include/liburing/meson.build | 51 +++++++
src/include/meson.build | 3 +
src/meson.build | 28 ++++
test/Makefile | 238 ---------------------------------
test/meson.build | 219 +++++++++++++++++++++++++++++++
18 files changed, 609 insertions(+), 947 deletions(-)
This is what the diffstat could look like if we would remove the old build system.
> That leaves me wondering what the advantages of this patch series are?
The most notable advantages of having a meson-based build system are highlighted
in the cover mail.
For me the by far most important feature and why I maintained the initial meson
code from 2021 is the interoperability with other meson-based projects.
Everything needed to consume liburing is to have a wrap file for liburing in your
subprojects directory and use it in your meson build logic.
subprojects/liburing.wrap:
[wrap-git]
url = https://git.kernel.dk/liburing
revision = master
And use the following lines in your meson code:
liburing_proj = subproject('emper')
liburing_dep = liburing_proj/get_variable('uring')
# somehow use the dependency object
---
Florian Fischer
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH liburing] add additional meson build system support
2022-07-27 20:53 ` Florian Fischer
@ 2022-07-29 7:47 ` Florian Schmaus
0 siblings, 0 replies; 13+ messages in thread
From: Florian Schmaus @ 2022-07-29 7:47 UTC (permalink / raw)
To: Bart Van Assche, io-uring
On 27.07.22 22:53, Florian Fischer wrote:
> On 27.07.2022 12:21, Bart Van Assche wrote:
>> On 7/27/22 08:27, Florian Fischer wrote:
>>> 11 files changed, 619 insertions(+), 4 deletions(-)
>>
>> To me this diffstat tells me that this patch series adds a lot of complexity
>> instead of removing complexity.
>
> That's because Jens wants to keep both build systems in the repository.
>
> .github/workflows/build.yml | 44 +++++--
> .gitignore | 2 +
> Makefile | 84 ------------
> Makefile.common | 6 -
> Makefile.quiet | 11 --
> configure | 467 -----------------------------------------------------------------
> examples/Makefile | 41 ------
> examples/meson.build | 19 +++
> man/meson.build | 116 ++++++++++++++++
> meson.build | 119 +++++++++++++++++
> meson_options.txt | 14 ++
> src/Makefile | 87 ------------
> src/include/liburing/compat.h.in | 7 +
> src/include/liburing/meson.build | 51 +++++++
> src/include/meson.build | 3 +
> src/meson.build | 28 ++++
> test/Makefile | 238 ---------------------------------
> test/meson.build | 219 +++++++++++++++++++++++++++++++
> 18 files changed, 609 insertions(+), 947 deletions(-)
>
> This is what the diffstat could look like if we would remove the old build system.
To point this out explicitly:
old Makefile-based build system: 947 LoC
new Meson-based build system: 609 LoC
That is a significant reduction in build-system complexity, while the
new Meson-based build system has more features, e.g., out-of-source
builds and a sensible test framework. For further features, see the
cover-letter of this patch set.
- Flow
^ permalink raw reply [flat|nested] 13+ messages in thread