From 44e94f72d7280294f92d9f2305bdf2bbd0f9ff7c Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Sat, 5 Jan 2019 16:38:10 +0100 Subject: [PATCH 01/18] First stab add adding a Meson build system Add meson.build and try to convert this to use Meson rather than CMake as a build system. This is still experimental. Get a .pc file as part of the Meson build system. --- meson.build | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..5cd7480 --- /dev/null +++ b/meson.build @@ -0,0 +1,64 @@ +project('libepoll-shim', 'c', + version : '0.0.1', + license : 'MIT', + default_options : [ 'c_std=c11' ], + meson_version : '>=0.40.0' ) + +libepollshim_version = meson.project_version().split('.') + +dir_data = join_paths(get_option('prefix'), get_option('datadir')) +dir_sysconf = join_paths(get_option('prefix'), get_option('sysconfdir')) +dir_libexec = join_paths(get_option('prefix'), get_option('libexecdir')) +dir_lib = join_paths(get_option('prefix'), get_option('libdir')) +dir_include = join_paths(get_option('prefix'), get_option('includedir'), 'libepoll-shim/sys') +dir_src_test = join_paths(meson.source_root(), 'test') +dir_src = join_paths(meson.source_root(), 'src') + +# Compiler setup +cc = meson.get_compiler('c') +cflags = ['-Wall', '-Wextra', '-Werror', '-fvisibility=hidden'] +add_project_arguments(cflags, language: 'c') + +#-Wno-missing-prototypes -Wno-padded -Wno-missing-variable-declarations -Wno-thread-safety-analysis + +libepollshim_so_version = '0.0.0' + +# Dependencies +thread_dep = dependency('threads') +pkgconfig = import('pkgconfig') + +# Include directories +includes_include = include_directories('include') + +header_libepollshim = [ 'include/sys/epoll.h', + 'include/sys/timerfd.h', + 'include/sys/signalfd.h' +] + +install_headers(header_libepollshim, subdir : 'libepoll-shim/sys') + +src_libepollshim = [ 'src/epoll.c', + 'src/timerfd.c', + 'src/signalfd.c', + 'src/common.c' +] + +src_libepollshim += header_libepollshim + +deps_libepollshim = [ thread_dep ] + +lib_libepollshim = shared_library('epoll-shim', + src_libepollshim, + include_directories : includes_include, + dependencies : deps_libepollshim, + version : libepollshim_so_version, + install : true +) + +pkgconfig.generate( + filebase : 'libepoll-shim', + name : 'libepoll-shim', + description : 'small epoll implementation using kqueue', + version : meson.project_version(), + libraries : lib_libepollshim +) From eea70d63f94d696534df43b9e020bc9de40d209d Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Sat, 5 Jan 2019 17:05:34 +0100 Subject: [PATCH 02/18] Add -lrt dependency --- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 5cd7480..1dbcb46 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,7 @@ libepollshim_so_version = '0.0.0' # Dependencies thread_dep = dependency('threads') pkgconfig = import('pkgconfig') +rt_dep = cc.find_library('rt') # Include directories includes_include = include_directories('include') @@ -45,7 +46,9 @@ src_libepollshim = [ 'src/epoll.c', src_libepollshim += header_libepollshim -deps_libepollshim = [ thread_dep ] +deps_libepollshim = [ thread_dep, + rt_dep + ] lib_libepollshim = shared_library('epoll-shim', src_libepollshim, From 6a7ed0c66ff0b4474918b81327fd26203b4053a7 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Sun, 6 Jan 2019 00:14:18 +0100 Subject: [PATCH 03/18] Add static library build as well --- meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meson.build b/meson.build index 1dbcb46..475e4c0 100644 --- a/meson.build +++ b/meson.build @@ -58,6 +58,13 @@ lib_libepollshim = shared_library('epoll-shim', install : true ) +lib_libepollshima = static_library('epoll-shim', + src_libepollshim, + include_directories : includes_include, + dependencies : deps_libepollshim, + install : true +) + pkgconfig.generate( filebase : 'libepoll-shim', name : 'libepoll-shim', From b75e275e1868baf8bef4f0d4a9caf926a3bbdd8d Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Sun, 6 Jan 2019 20:18:14 +0100 Subject: [PATCH 04/18] Switch name from libepoll-shim to epoll-shim Switch name from libepoll-shim to epoll-shim, to match the name used in the CMake build. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 475e4c0..646ef36 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('libepoll-shim', 'c', +project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', default_options : [ 'c_std=c11' ], From d235496dc9199c6884c4a5a3e7e315ef4d34994a Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 18:46:53 +0100 Subject: [PATCH 05/18] whitespace fix --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 646ef36..ce2ff9a 100644 --- a/meson.build +++ b/meson.build @@ -48,7 +48,7 @@ src_libepollshim += header_libepollshim deps_libepollshim = [ thread_dep, rt_dep - ] +] lib_libepollshim = shared_library('epoll-shim', src_libepollshim, From da84fda8427964ad062a120ceac17126188e4e45 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 19:01:54 +0100 Subject: [PATCH 06/18] Use both_libraries to build both .so and .a Use both_libraries to build both shared and static libraries. The libraries are built from the same metadata, so instead of having separate build instructions, just merge it and build both types of libraries from the same information. --- meson.build | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/meson.build b/meson.build index ce2ff9a..ec38a2f 100644 --- a/meson.build +++ b/meson.build @@ -50,7 +50,7 @@ deps_libepollshim = [ thread_dep, rt_dep ] -lib_libepollshim = shared_library('epoll-shim', +lib_libepollshim = both_libraries('epoll-shim', src_libepollshim, include_directories : includes_include, dependencies : deps_libepollshim, @@ -58,13 +58,6 @@ lib_libepollshim = shared_library('epoll-shim', install : true ) -lib_libepollshima = static_library('epoll-shim', - src_libepollshim, - include_directories : includes_include, - dependencies : deps_libepollshim, - install : true -) - pkgconfig.generate( filebase : 'libepoll-shim', name : 'libepoll-shim', From ccc2a1af2f456e47ccaed2136922467ce0819cb9 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 19:06:35 +0100 Subject: [PATCH 07/18] Update how we generate .pc file Update how we generate pkg-config files. Use the library object as a base for the .pc file, this gives us some information for the .pc file for free. Add URL. Update include directory since we install headers in a subdir (this was broken before) Require a newver version of meson that includes support for this way of generating .pc files. --- meson.build | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index ec38a2f..4a28905 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', default_options : [ 'c_std=c11' ], - meson_version : '>=0.40.0' ) + meson_version : '>=0.46.0' ) libepollshim_version = meson.project_version().split('.') @@ -58,10 +58,8 @@ lib_libepollshim = both_libraries('epoll-shim', install : true ) -pkgconfig.generate( - filebase : 'libepoll-shim', - name : 'libepoll-shim', +pkgconfig.generate(lib_libepollshim, + url : 'https://github.com/FreeBSDDesktop/epoll-shim', description : 'small epoll implementation using kqueue', - version : meson.project_version(), - libraries : lib_libepollshim + subdirs : 'epoll-shim' ) From 395c368af58620df685d0e6bde9ae30cde77baa4 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 19:10:05 +0100 Subject: [PATCH 08/18] Fiddle with build options Fiddle with build options, use a default warning level, and a default build type of debugoptimized. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 4a28905..869befe 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', - default_options : [ 'c_std=c11' ], + default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11' ], meson_version : '>=0.46.0' ) libepollshim_version = meson.project_version().split('.') From 483e6b33a41a0f170408cd214597c52d29962d4c Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 19:10:48 +0100 Subject: [PATCH 09/18] Chance CI to run meson build as well Change the CI to run the meson build as well as the make build. --- .cirrus.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 20fe346..18fb9e0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,6 +10,9 @@ task: install_script: - sed -i.bak -e 's,pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly,pkg+http://pkg.FreeBSD.org/\${ABI}/latest,' /etc/pkg/FreeBSD.conf - pkg upgrade -y - - script: | + - pkg install -y meson ninja + make_script: make -j 4 + meson_script: + - meson _build + - ninja -C _build From a2138c0e3e0fd06e3778405c816dd03d1fc84513 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 19:30:34 +0100 Subject: [PATCH 10/18] First pass at using the Symbol map First pass at using the Symbol map to hide symbols. This is a little clunky in meson, since there's no built in support for this yet. What we do is we define the path to the version map, and the linker flags to use it, and then test if the compiler is OK with this. If it is, then all is good, otherwise, we abort and complain. The linker flags are also added to to library build step. --- meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meson.build b/meson.build index 869befe..7fe4e98 100644 --- a/meson.build +++ b/meson.build @@ -31,6 +31,16 @@ rt_dep = cc.find_library('rt') # Include directories includes_include = include_directories('include') +# Symbol map +libepollshim_sym_path = meson.current_source_dir() + '/Version.map' +libepollshim_sym_ldflag = '-Wl,--version-script=' + libepollshim_sym_path + +if cc.links('', name: '-Wl,--version-script', args: ['-shared', libepollshim_sym_ldflag]) + link_args = [libepollshim_sym_ldflag] +else + error('Linker doesn\'t support --version-script') +endif + header_libepollshim = [ 'include/sys/epoll.h', 'include/sys/timerfd.h', 'include/sys/signalfd.h' @@ -55,6 +65,7 @@ lib_libepollshim = both_libraries('epoll-shim', include_directories : includes_include, dependencies : deps_libepollshim, version : libepollshim_so_version, + link_args : '-Wl,--version-script=' + libepollshim_sym_path, install : true ) From a6d47cc1b52311b02494253a2f9e7a5e0733a061 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 20:04:52 +0100 Subject: [PATCH 11/18] Don't hide *ALL* symbols. Don't use -fvisibility=hidden to hide *all* symbols. Then we can't link against this library. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 7fe4e98..2f19bd4 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,7 @@ dir_src = join_paths(meson.source_root(), 'src') # Compiler setup cc = meson.get_compiler('c') -cflags = ['-Wall', '-Wextra', '-Werror', '-fvisibility=hidden'] +cflags = ['-Wall', '-Wextra', '-Werror'] add_project_arguments(cflags, language: 'c') #-Wno-missing-prototypes -Wno-padded -Wno-missing-variable-declarations -Wno-thread-safety-analysis From dd9d8a5bf37c4ce207795bbc0dd484fb3800bef2 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 20:08:45 +0100 Subject: [PATCH 12/18] Whitespace --- Version.map | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Version.map b/Version.map index e9ed66f..b46b38a 100644 --- a/Version.map +++ b/Version.map @@ -9,5 +9,6 @@ signalfd; timerfd_create; timerfd_settime; - local: *; + local: + *; }; From 884d235e13b0907a238443f396415b3118722e8f Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Tue, 12 Mar 2019 22:20:02 +0100 Subject: [PATCH 13/18] Remove old build system --- CMakeLists.txt | 8 -------- Makefile | 17 ----------------- test/CMakeLists.txt | 9 --------- 3 files changed, 34 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 91590d3..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -project(epoll-shim C) - -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_EXTENSIONS ON) - -add_subdirectory(src) -add_subdirectory(test) diff --git a/Makefile b/Makefile deleted file mode 100644 index df3f17f..0000000 --- a/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -LIB= epoll-shim -SHLIB_MAJOR= 0 -SRCS= src/epoll.c src/timerfd.c src/signalfd.c src/common.c -INCS= include/sys/epoll.h include/sys/timerfd.h include/sys/signalfd.h -VERSION_MAP= Version.map - -LIBDIR= /usr/local/lib -INCSDIR= /usr/local/include/libepoll-shim/sys - -CFLAGS+= -I${.CURDIR}/include -pthread -Wall -Wextra -Wno-missing-prototypes -Wno-padded -Wno-missing-variable-declarations -Wno-thread-safety-analysis -LDFLAGS+= -pthread -lrt - -distrib-dirs: - mkdir -p "${DESTDIR}/${LIBDIR}" - mkdir -p "${DESTDIR}/${INCSDIR}" - -.include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index dbac513..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_executable(epoll-test epoll-test.c) -target_link_libraries(epoll-test PRIVATE epoll-shim) - -add_executable(expire-five expire-five.c) -target_link_libraries(expire-five PRIVATE epoll-shim) - -add_executable(kqueue-state kqueue-state.c) -target_include_directories(kqueue-state PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../include") From 84dcc706cdfc5b165d77ded6571595dcc5a26b53 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Wed, 13 Mar 2019 07:30:31 +0100 Subject: [PATCH 14/18] FIx Cflags include dir in .pc file Fix the Cflags include dir in .pc file, headers are installed in ${includedir}/libepoll-shim, not ${includedir}/epoll-shim. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2f19bd4..25698ce 100644 --- a/meson.build +++ b/meson.build @@ -72,5 +72,5 @@ lib_libepollshim = both_libraries('epoll-shim', pkgconfig.generate(lib_libepollshim, url : 'https://github.com/FreeBSDDesktop/epoll-shim', description : 'small epoll implementation using kqueue', - subdirs : 'epoll-shim' + subdirs : 'libepoll-shim' ) From 7a30ce55ff272566139a3bb7ac7297d54992913e Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Wed, 13 Mar 2019 07:53:35 +0100 Subject: [PATCH 15/18] Fix compiler warning flags Move -Werror to default options so that it can be overridden if needed. Remove our special flags, -Wall -Wextra are added by default, no need to add them ourselves. --- meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 25698ce..69e5bcc 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', - default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11' ], + default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11', 'c_args=-Werror' ], meson_version : '>=0.46.0' ) libepollshim_version = meson.project_version().split('.') @@ -16,10 +16,6 @@ dir_src = join_paths(meson.source_root(), 'src') # Compiler setup cc = meson.get_compiler('c') -cflags = ['-Wall', '-Wextra', '-Werror'] -add_project_arguments(cflags, language: 'c') - -#-Wno-missing-prototypes -Wno-padded -Wno-missing-variable-declarations -Wno-thread-safety-analysis libepollshim_so_version = '0.0.0' From b89595fb950a3542ec110e5e1cf7425445a13f3b Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Wed, 13 Mar 2019 07:54:52 +0100 Subject: [PATCH 16/18] Remove make build from CI Remove make build from CI, this should have been done in 884d235. --- .cirrus.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 18fb9e0..a97f955 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -11,8 +11,6 @@ task: - sed -i.bak -e 's,pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly,pkg+http://pkg.FreeBSD.org/\${ABI}/latest,' /etc/pkg/FreeBSD.conf - pkg upgrade -y - pkg install -y meson ninja - make_script: - make -j 4 meson_script: - meson _build - ninja -C _build From 5574899811c006ac8c1c54e3d835837c1e4442ab Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Wed, 13 Mar 2019 08:00:02 +0100 Subject: [PATCH 17/18] Better way to hande -Werror --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 69e5bcc..5dfa695 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', - default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11', 'c_args=-Werror' ], + default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11', 'werror=true' ], meson_version : '>=0.46.0' ) libepollshim_version = meson.project_version().split('.') From c6f1afce07d84485d294278e760ef2d26d387a98 Mon Sep 17 00:00:00 2001 From: Niclas Zeising Date: Wed, 13 Mar 2019 08:02:03 +0100 Subject: [PATCH 18/18] Format default_options better Format default_options better, to avoid overly long lines. --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 5dfa695..102d762 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,11 @@ project('epoll-shim', 'c', version : '0.0.1', license : 'MIT', - default_options : [ 'buildtype=debugoptimized', 'warning_level=3', 'c_std=c11', 'werror=true' ], + default_options : [ + 'buildtype=debugoptimized', + 'warning_level=3', + 'c_std=c11', + 'werror=true' ], meson_version : '>=0.46.0' ) libepollshim_version = meson.project_version().split('.')