Skip to content
Merged
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
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,49 @@ jobs:
${{matrix.build_args.cxx}} -x c++ -o a.out $TEST_FILE -luring $SANITIZE_FLAGS;


out-of-source-build:
needs: get_commit_list
runs-on: ubuntu-24.04
strategy:
matrix:
commit: ${{ fromJson(needs.get_commit_list.outputs.commit_list) }}

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout commit
run: |
git checkout ${{ matrix.commit }};

- name: Out-of-source build
run: |
mkdir build && cd build;
../configure;
make -j$(nproc) V=1;

- name: Test install from out-of-source build
run: |
cd build;
sudo make install;

- name: Test build against the installed liburing
run: |
gcc -x c -o a.out .github/workflows/test_build.c -luring;
gcc -x c++ -o a.out .github/workflows/test_build.c -luring;

- name: Verify source tree is clean
run: |
dirty=$(git ls-files --others --exclude-standard --ignored -- ':!build');
if [ -n "$dirty" ]; then
echo "Out-of-source build leaked into source tree:";
echo "$dirty";
exit 1;
fi


alpine-musl-build:
needs: get_commit_list
runs-on: ubuntu-24.04
Expand Down
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include Makefile.common
root ?= .
include $(root)/Makefile.common

VPATH = $(root)

RPMBUILD=$(shell `which rpmbuild >&/dev/null` && echo "rpmbuild" || echo "rpm")

Expand All @@ -24,10 +27,10 @@ runtests-loop: all
runtests-parallel: all
@$(MAKE) -C test runtests-parallel

config-host.mak: configure
config-host.mak: $(root)/configure
+@if [ ! -e "$@" ]; then \
echo "Running configure ..."; \
./configure; \
$(root)/configure; \
else \
echo "$@ is out-of-date, running configure"; \
sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \
Expand All @@ -54,11 +57,11 @@ install: $(NAME).pc $(NAME)-ffi.pc
$(INSTALL) -D -m 644 $(NAME).pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME).pc
$(INSTALL) -D -m 644 $(NAME)-ffi.pc $(DESTDIR)$(libdevdir)/pkgconfig/$(NAME)-ffi.pc
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man2
$(INSTALL) -m 644 man/*.2 $(DESTDIR)$(mandir)/man2
$(INSTALL) -m 644 $(root)/man/*.2 $(DESTDIR)$(mandir)/man2
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 644 man/*.3 $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 644 $(root)/man/*.3 $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man7
$(INSTALL) -m 644 man/*.7 $(DESTDIR)$(mandir)/man7
$(INSTALL) -m 644 $(root)/man/*.7 $(DESTDIR)$(mandir)/man7

uninstall:
@$(MAKE) -C src uninstall prefix=$(DESTDIR)$(prefix) datadir=$(DESTDIR)$(datadir)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
NAME=liburing
SPECFILE=$(TOP)/$(NAME).spec
VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE))
Expand Down
8 changes: 8 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ Building liburing

See './configure --help' for more information about build config options.

Out-of-source builds are also supported, keeping the source tree clean, and
allowing you to have different configurations side-by-side:

mkdir build && cd build
../configure
make -j$(nproc)
sudo make install


FFI support
-----------
Expand Down
21 changes: 20 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set -e
cc=${CC:-gcc}
cxx=${CXX:-g++}

# Determine source directory (where this configure script lives)
root=$(cd "$(dirname "$0")" && pwd)
builddir=$(pwd)

for opt do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true)
case "$opt" in
Expand Down Expand Up @@ -85,6 +89,20 @@ EOF
exit 0
fi

# Set up out-of-source build if needed
if test "$root" != "$builddir"; then
mkdir -p src/include/liburing test examples

for dir in . src test examples; do
cat > "$dir/Makefile" << MEOF
root := $root
include \$(root)/$dir/Makefile
MEOF
done
else
mkdir -p src/include/liburing
fi

TMP_DIRECTORY="$(mktemp -d)"
TMPC="$TMP_DIRECTORY/liburing-conf.c"
TMPC2="$TMP_DIRECTORY/liburing-conf-2.c"
Expand Down Expand Up @@ -636,11 +654,12 @@ print_config "CC" "$cc"
echo "CXX=$cxx" >> $config_host_mak
echo "BUILD_CFLAGS=$BUILD_CFLAGS" >> $config_host_mak
print_config "CXX" "$cxx"
echo "root=$root" >> $config_host_mak

# generate io_uring_version.h
# Reset MAKEFLAGS
MAKEFLAGS=
MAKE_PRINT_VARS="include Makefile.common\nprint-%%: ; @echo \$(\$*)\n"
MAKE_PRINT_VARS="include $root/Makefile.common\nprint-%%: ; @echo \$(\$*)\n"
VERSION_MAJOR=$(printf "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MAJOR)
VERSION_MINOR=$(printf "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MINOR)
io_uring_version_h="src/include/liburing/io_uring_version.h"
Expand Down
8 changes: 6 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
root ?= ..

CPPFLAGS ?=
override CPPFLAGS += -D_GNU_SOURCE -I../src/include/
override CPPFLAGS += -D_GNU_SOURCE -I../src/include/ -I$(root)/src/include/
CFLAGS ?= -g -O2 -Wall
LDFLAGS ?=
override LDFLAGS += -L../src/ -luring

include ../Makefile.quiet
include $(root)/Makefile.quiet

ifneq ($(MAKECMDGOALS),clean)
include ../config-host.mak
endif

VPATH = $(root)/examples

LDFLAGS ?=
override LDFLAGS += -L../src/ -luring -lpthread

Expand Down
28 changes: 16 additions & 12 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include ../Makefile.common
root ?= ..
include $(root)/Makefile.common

prefix ?= /usr
includedir ?= $(prefix)/include
Expand All @@ -8,8 +9,11 @@ libdevdir ?= $(prefix)/lib
LIBURING_CFLAGS ?=
CPPFLAGS ?=
override CPPFLAGS += -D_GNU_SOURCE \
-Iinclude/ -include ../config-host.h \
-Iinclude/ -I$(root)/src/include/ \
-include ../config-host.h \
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

VPATH = $(root)/src
CFLAGS ?= -O3 -Wall -Wextra -fno-stack-protector
override CFLAGS += -Wno-unused-parameter \
-DLIBURING_INTERNAL \
Expand All @@ -32,7 +36,7 @@ all_targets += $(libname)
all_targets += $(ffi_libname)
endif

include ../Makefile.quiet
include $(root)/Makefile.quiet

ifneq ($(MAKECMDGOALS),clean)
include ../config-host.mak
Expand Down Expand Up @@ -95,20 +99,20 @@ liburing-ffi.a: $(liburing_objs) $(liburing_ffi_objs)
$(QUIET_AR)$(AR) r liburing-ffi.a $^
$(QUIET_RANLIB)$(RANLIB) liburing-ffi.a

$(libname): $(liburing_sobjs) liburing.map
$(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=liburing.map -Wl,-soname=$(soname) -o $@ $(liburing_sobjs) $(LINK_FLAGS)
$(libname): $(liburing_sobjs) $(root)/src/liburing.map
$(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=$(root)/src/liburing.map -Wl,-soname=$(soname) -o $@ $(liburing_sobjs) $(LINK_FLAGS)

$(ffi_libname): $(liburing_ffi_objs) $(liburing_ffi_sobjs) $(liburing_sobjs) liburing-ffi.map
$(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=liburing-ffi.map -Wl,-soname=$(ffi_soname) -o $@ $(liburing_sobjs) $(liburing_ffi_sobjs) $(LINK_FLAGS)
$(ffi_libname): $(liburing_ffi_objs) $(liburing_ffi_sobjs) $(liburing_sobjs) $(root)/src/liburing-ffi.map
$(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=$(root)/src/liburing-ffi.map -Wl,-soname=$(ffi_soname) -o $@ $(liburing_sobjs) $(liburing_ffi_sobjs) $(LINK_FLAGS)

install: $(all_targets)
install -D -m 644 include/liburing/io_uring.h $(includedir)/liburing/io_uring.h
install -D -m 644 include/liburing.h $(includedir)/liburing.h
install -D -m 644 $(root)/src/include/liburing/io_uring.h $(includedir)/liburing/io_uring.h
install -D -m 644 $(root)/src/include/liburing.h $(includedir)/liburing.h
install -D -m 644 include/liburing/compat.h $(includedir)/liburing/compat.h
install -D -m 644 include/liburing/barrier.h $(includedir)/liburing/barrier.h
install -D -m 644 $(root)/src/include/liburing/barrier.h $(includedir)/liburing/barrier.h
install -D -m 644 include/liburing/io_uring_version.h $(includedir)/liburing/io_uring_version.h
install -D -m 644 include/liburing/io_uring/query.h $(includedir)/liburing/io_uring/query.h
install -D -m 644 include/liburing/io_uring/bpf_filter.h $(includedir)/liburing/io_uring/bpf_filter.h
install -D -m 644 $(root)/src/include/liburing/io_uring/query.h $(includedir)/liburing/io_uring/query.h
install -D -m 644 $(root)/src/include/liburing/io_uring/bpf_filter.h $(includedir)/liburing/io_uring/bpf_filter.h
install -D -m 644 liburing.a $(libdevdir)/liburing.a
install -D -m 644 liburing-ffi.a $(libdevdir)/liburing-ffi.a
ifeq ($(ENABLE_SHARED),1)
Expand Down
21 changes: 13 additions & 8 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
root ?= ..

prefix ?= /usr
datadir ?= $(prefix)/share

CLANG ?= clang
BPFTOOL ?= $(or $(shell command -v bpftool 2>/dev/null), \
$(shell command -v /usr/sbin/bpftool 2>/dev/null), \
bpfool)
BPF_PROGS_DIR = bpf-progs
BPF_PROGS_DIR = $(root)/test/bpf-progs
BPF_OUTPUT = output/bpf

INSTALL=install
Expand All @@ -20,9 +22,12 @@ override CPPFLAGS += \
-D_GNU_SOURCE \
-D__SANE_USERSPACE_TYPES__ \
-I../src/include/ \
-I$(root)/src/include/ \
-include ../config-host.h \
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

VPATH = $(root)/test

CFLAGS ?= -g -O3 -Wall -Wextra
XCFLAGS = -Wno-unused-parameter -Wno-sign-compare

Expand Down Expand Up @@ -303,7 +308,7 @@ asan_test_srcs := \
# EOL

all_targets :=
include ../Makefile.quiet
include $(root)/Makefile.quiet

ifeq ($(CONFIG_NOLIBC),y)
test_srcs += nolibc.c
Expand Down Expand Up @@ -385,11 +390,11 @@ $(BPF_OUTPUT)/%.bpf.o: $(BPF_PROGS_DIR)/%.bpf.c $(wildcard %.h)
$(BPF_OUTPUT)/%.skel.h: $(BPF_OUTPUT)/%.bpf.o
$(BPFTOOL) gen skeleton $< > $@

install: $(test_targets) runtests.sh runtests-loop.sh
install: $(test_targets) $(root)/test/runtests.sh $(root)/test/runtests-loop.sh
$(INSTALL) -D -d -m 755 $(datadir)/liburing-test/
$(INSTALL) -D -m 755 $(test_targets) $(datadir)/liburing-test/
$(INSTALL) -D -m 755 runtests.sh $(datadir)/liburing-test/
$(INSTALL) -D -m 755 runtests-loop.sh $(datadir)/liburing-test/
$(INSTALL) -D -m 755 $(root)/test/runtests.sh $(datadir)/liburing-test/
$(INSTALL) -D -m 755 $(root)/test/runtests-loop.sh $(datadir)/liburing-test/

uninstall:
@rm -rf $(datadir)/liburing-test/
Expand All @@ -399,13 +404,13 @@ clean:
@rm -rf output/

runtests: all
@./runtests.sh $(test_targets) $(asan_test_targets)
@$(root)/test/runtests.sh $(test_targets) $(asan_test_targets)

runtests-loop: all
@./runtests-loop.sh $(test_targets) $(asan_test_targets)
@$(root)/test/runtests-loop.sh $(test_targets) $(asan_test_targets)

%.run_test: %.t
@./runtests-quiet.sh $<
@$(root)/test/runtests-quiet.sh $<

runtests-parallel: $(run_test_targets)
@echo "All tests passed"
Expand Down
Loading