From: Florian Fischer <[email protected]>
To: [email protected]
Cc: Florian Schmaus <[email protected]>,
Florian Fischer <[email protected]>
Subject: [PATCH liburing 2/9] meson: update meson build files for liburing 2.3
Date: Wed, 27 Jul 2022 17:27:16 +0200 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
* 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
next prev parent reply other threads:[~2022-07-27 15:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-07-27 15:27 ` [PATCH liburing 3/9] meson: update available tests to liburing 2.3 Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 4/9] meson: update installed manpages " Florian Fischer
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 ` [PATCH liburing 6/9] meson: support building without libc Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 7/9] meson: add 'raw' test suite Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 8/9] github bot: add jobs for meson 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
2022-07-27 20:53 ` Florian Fischer
2022-07-29 7:47 ` Florian Schmaus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220727152723.3320169-3-florian.fischer@muhq.space \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox