Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meson based buildsystem v2 #622

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"; \
Expand All @@ -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 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ config.log
liburing.pc

cscope.out

/build/
19 changes: 19 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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
example_sources += ['ucontext-cp.c']
endif

foreach source: example_sources
name = source.split('.')[0]
executable(name,
source,
dependencies: uring)
endforeach
116 changes: 116 additions & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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',
)
119 changes: 119 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
project('liburing', ['c','cpp'],
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',
'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',
language: ['c', 'cpp'])

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',
'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 statx x;

return memset(&x, 0, sizeof(x)) != NULL;
}
'''
has_statx = cc.compiles(code, name: 'statx')

code= '''#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <linux/stat.h>
main(int argc, char **argv)
{
struct statx x;

return memset(&x, 0, sizeof(x)) != NULL;
}
'''
glibc_statx = cc.compiles(code, name: 'glibc_statx')

# Since the project is configured to use C++
# meson fails if no C++ compiler is available.
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)
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)
conf_data.set('CONFIG_NOLIBC', nolibc)
conf_data.set('LIBURING_BUILD_TEST', build_tests)
configure_file(output: 'config-host.h',
configuration: conf_data)

subdir('src')
subdir('man')

if get_option('examples')
subdir('examples')
endif

if build_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)
14 changes: 14 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
option('examples',
type : 'boolean',
value : false,
description : 'Build example programs')

option('tests',
type : 'boolean',
value : false,
description : 'Build test programs')

option('nolibc',
type : 'boolean',
value : false,
description : 'Build liburing without libc')
7 changes: 7 additions & 0 deletions src/include/liburing/compat.h.in
Original file line number Diff line number Diff line change
@@ -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
Loading