From: Florian Fischer <[email protected]>
To: [email protected]
Cc: Florian Schmaus <[email protected]>,
Florian Fischer <[email protected]>
Subject: [PATCH liburing 6/9] meson: support building without libc
Date: Wed, 27 Jul 2022 17:27:20 +0200 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
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
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 ` [PATCH liburing 2/9] meson: update meson build files for liburing 2.3 Florian Fischer
2022-07-27 15:27 ` [PATCH liburing 3/9] meson: update available tests to " 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 ` Florian Fischer [this message]
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-7-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