@@ -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
@@ -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')
@@ -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)
@@ -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,
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 <florian.fischer@muhq.space> --- meson.build | 8 +++++++- meson_options.txt | 5 +++++ src/meson.build | 28 +++++++++++++++++++--------- test/meson.build | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-)