From: Zbigniew Jędrzejewski-Szmek Date: Fri, 12 Jan 2018 04:47:17 +0000 (+0100) Subject: meson: detect pcre2 dep X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0f1d716b718891f3e3cc85e76ed1504a8bbc196f;p=elogind.git meson: detect pcre2 dep --- diff --git a/meson.build b/meson.build index 81a414fcb..3c0ae8f71 100644 --- a/meson.build +++ b/meson.build @@ -323,27 +323,11 @@ substs.set('VARLOGDIR', varlogdir) cc = meson.get_compiler('c') pkgconfig = import('pkgconfig') check_compilation_sh = find_program('tools/meson-check-compilation.sh') -meson_build_sh = find_program('tools/meson-build.sh') -if get_option('tests') != 'false' - cxx = find_program('c++', required : false) - if cxx.found() - # Used only for tests - add_languages('cpp') - endif -endif - -want_ossfuzz = get_option('oss-fuzz') -want_libfuzzer = get_option('llvm-fuzz') -fuzzer_build = want_ossfuzz or want_libfuzzer -if want_ossfuzz and want_libfuzzer - error('only one of oss-fuzz and llvm-fuzz can be specified') -endif -if want_libfuzzer - fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer') -endif -if want_ossfuzz - fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine') +cxx = find_program('c++', required : false) +if cxx.found() + # Used only for tests + add_languages('cpp') endif foreach arg : ['-Wextra', @@ -380,6 +364,7 @@ foreach arg : ['-Wextra', '-fvisibility=hidden', '-fstack-protector', '-fstack-protector-strong', + '-fPIE', '--param=ssp-buffer-size=4', ] if cc.has_argument(arg) @@ -387,14 +372,6 @@ foreach arg : ['-Wextra', endif endforeach -# the oss-fuzz fuzzers are not built with -fPIE, so don't -# enable it when we are linking against them -if not fuzzer_build - if cc.has_argument('-fPIE') - add_project_arguments('-fPIE', language : 'c') - endif -endif - # "negative" arguments: gcc on purpose does not return an error for "-Wno-" # arguments, just emits a warnings. So test for the "positive" version instead. foreach arg : ['unused-parameter', @@ -445,22 +422,8 @@ foreach arg : ['-Wl,-z,relro', cc.cmd_array(), '-x', 'c', arg, '-include', link_test_c).returncode() == 0 message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no')) - if have and (arg != '-pie' or not fuzzer_build) - add_project_link_arguments(arg, language : 'c') - endif -endforeach - -# Check if various sanitizers are supported -sanitizers = [] -foreach arg : ['address'] - - have = run_command(check_compilation_sh, - cc.cmd_array(), '-x', 'c', - '-fsanitize=@0@'.format(arg), - '-include', link_test_c).returncode() == 0 - message('@0@ sanitizer supported: @1@'.format(arg, have ? 'yes' : 'no')) if have - sanitizers += arg + add_project_link_arguments(arg, language : 'c') endif endforeach @@ -596,7 +559,6 @@ awk = find_program('awk') m4 = find_program('m4') stat = find_program('stat') git = find_program('git', required : false) -env = find_program('env') meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh' #if 1 /// Needed by elogind @@ -925,11 +887,10 @@ endif #if 0 /// UNNEEDED by elogind # libmount = dependency('mount', -# version : '>= 2.30', -# required : not fuzzer_build) +# version : '>= 2.30') # # want_seccomp = get_option('seccomp') -# if want_seccomp != 'false' and not fuzzer_build +# if want_seccomp != 'false' # libseccomp = dependency('libseccomp', # version : '>= 2.3.1', # required : want_seccomp == 'true') @@ -945,7 +906,7 @@ conf.set10('HAVE_SECCOMP', have) m4_defines += have ? ['-DHAVE_SECCOMP'] : [] want_selinux = get_option('selinux') -if want_selinux != 'false' and not fuzzer_build +if want_selinux != 'false' libselinux = dependency('libselinux', version : '>= 2.1.9', required : want_selinux == 'true') @@ -959,7 +920,7 @@ m4_defines += have ? ['-DHAVE_SELINUX'] : [] #if 0 /// UNNEEDED by elogind # want_apparmor = get_option('apparmor') -# if want_apparmor != 'false' and not fuzzer_build +# if want_apparmor != 'false' # libapparmor = dependency('libapparmor', # required : want_apparmor == 'true') # have = libapparmor.found() @@ -982,7 +943,7 @@ endif want_polkit = get_option('polkit') install_polkit = false install_polkit_pkla = false -if want_polkit != 'false' and not fuzzer_build +if want_polkit != 'false' install_polkit = true libpolkit = dependency('polkit-gobject-1', @@ -995,7 +956,7 @@ endif conf.set10('ENABLE_POLKIT', install_polkit) want_acl = get_option('acl') -if want_acl != 'false' and not fuzzer_build +if want_acl != 'false' libacl = cc.find_library('acl', required : want_acl == 'true') have = libacl.found() else @@ -1006,7 +967,7 @@ conf.set10('HAVE_ACL', have) m4_defines += have ? ['-DHAVE_ACL'] : [] want_audit = get_option('audit') -if want_audit != 'false' and not fuzzer_build +if want_audit != 'false' libaudit = dependency('audit', required : want_audit == 'true') have = libaudit.found() else @@ -1017,7 +978,7 @@ conf.set10('HAVE_AUDIT', have) #if 0 /// UNNEEDED by elogind # want_blkid = get_option('blkid') -# if want_blkid != 'false' and not fuzzer_build +# if want_blkid != 'false' # libblkid = dependency('blkid', required : want_blkid == 'true') # have = libblkid.found() # else @@ -1027,7 +988,7 @@ conf.set10('HAVE_AUDIT', have) # conf.set10('HAVE_BLKID', have) # # want_kmod = get_option('kmod') -# if want_kmod != 'false' and not fuzzer_build +# if want_kmod != 'false' # libkmod = dependency('libkmod', # version : '>= 15', # required : want_kmod == 'true') @@ -1043,7 +1004,7 @@ libkmod = [] #endif // 0 want_pam = get_option('pam') -if want_pam != 'false' and not fuzzer_build +if want_pam != 'false' libpam = cc.find_library('pam', required : want_pam == 'true') libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true') have = libpam.found() and libpam_misc.found() @@ -1057,7 +1018,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] #if 0 /// UNNEEDED by elogind # want_microhttpd = get_option('microhttpd') -# if want_microhttpd != 'false' and not fuzzer_build +# if want_microhttpd != 'false' # libmicrohttpd = dependency('libmicrohttpd', # version : '>= 0.9.33', # required : want_microhttpd == 'true') @@ -1070,7 +1031,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # m4_defines += have ? ['-DHAVE_MICROHTTPD'] : [] # # want_libcryptsetup = get_option('libcryptsetup') -# if want_libcryptsetup != 'false' and not fuzzer_build +# if want_libcryptsetup != 'false' # libcryptsetup = dependency('libcryptsetup', # version : '>= 1.6.0', # required : want_libcryptsetup == 'true') @@ -1082,7 +1043,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_LIBCRYPTSETUP', have) # # want_libcurl = get_option('libcurl') -# if want_libcurl != 'false' and not fuzzer_build +# if want_libcurl != 'false' # libcurl = dependency('libcurl', # version : '>= 7.32.0', # required : want_libcurl == 'true') @@ -1100,7 +1061,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # error('libidn and libidn2 cannot be requested simultaneously') # endif # -# if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build +# if want_libidn != 'false' and want_libidn2 != 'true' # libidn = dependency('libidn', # required : want_libidn == 'true') # have = libidn.found() @@ -1110,7 +1071,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # endif # conf.set10('HAVE_LIBIDN', have) # m4_defines += have ? ['-DHAVE_LIBIDN'] : [] -# if not have and want_libidn2 != 'false' and not fuzzer_build +# if not have and want_libidn2 != 'false' # # libidn is used for both libidn and libidn2 objects # libidn = dependency('libidn2', # required : want_libidn2 == 'true') @@ -1122,7 +1083,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # m4_defines += have ? ['-DHAVE_LIBIDN2'] : [] # # want_libiptc = get_option('libiptc') -# if want_libiptc != 'false' and not fuzzer_build +# if want_libiptc != 'false' # libiptc = dependency('libiptc', # required : want_libiptc == 'true') # have = libiptc.found() @@ -1134,7 +1095,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # m4_defines += have ? ['-DHAVE_LIBIPTC'] : [] # # want_qrencode = get_option('qrencode') -# if want_qrencode != 'false' and not fuzzer_build +# if want_qrencode != 'false' # libqrencode = dependency('libqrencode', # required : want_qrencode == 'true') # have = libqrencode.found() @@ -1145,7 +1106,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_QRENCODE', have) # # want_gcrypt = get_option('gcrypt') -# if want_gcrypt != 'false' and not fuzzer_build +# if want_gcrypt != 'false' # libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true') # libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true') # have = libgcrypt.found() and libgpg_error.found() @@ -1160,7 +1121,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_GCRYPT', have) # # want_gnutls = get_option('gnutls') -# if want_gnutls != 'false' and not fuzzer_build +# if want_gnutls != 'false' # libgnutls = dependency('gnutls', # version : '>= 3.1.4', # required : want_gnutls == 'true') @@ -1172,7 +1133,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_GNUTLS', have) # # want_elfutils = get_option('elfutils') -# if want_elfutils != 'false' and not fuzzer_build +# if want_elfutils != 'false' # libdw = dependency('libdw', # required : want_elfutils == 'true') # have = libdw.found() @@ -1183,7 +1144,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_ELFUTILS', have) # # want_zlib = get_option('zlib') -# if want_zlib != 'false' and not fuzzer_build +# if want_zlib != 'false' # libz = dependency('zlib', # required : want_zlib == 'true') # have = libz.found() @@ -1194,7 +1155,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_ZLIB', have) # # want_bzip2 = get_option('bzip2') -# if want_bzip2 != 'false' and not fuzzer_build +# if want_bzip2 != 'false' # libbzip2 = cc.find_library('bz2', # required : want_bzip2 == 'true') # have = libbzip2.found() @@ -1205,7 +1166,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_BZIP2', have) # # want_xz = get_option('xz') -# if want_xz != 'false' and not fuzzer_build +# if want_xz != 'false' # libxz = dependency('liblzma', # required : want_xz == 'true') # have = libxz.found() @@ -1216,7 +1177,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_XZ', have) # # want_lz4 = get_option('lz4') -# if want_lz4 != 'false' and not fuzzer_build +# if want_lz4 != 'false' # liblz4 = dependency('liblz4', # required : want_lz4 == 'true') # have = liblz4.found() @@ -1227,7 +1188,7 @@ m4_defines += have ? ['-DHAVE_PAM'] : [] # conf.set10('HAVE_LZ4', have) # # want_xkbcommon = get_option('xkbcommon') -# if want_xkbcommon != 'false' and not fuzzer_build +# if want_xkbcommon != 'false' # libxkbcommon = dependency('xkbcommon', # version : '>= 0.3.0', # required : want_xkbcommon == 'true') @@ -1255,8 +1216,19 @@ libxkbcommon = [] #endif // 0 conf.set10('HAVE_XKBCOMMON', have) +want_pcre2 = get_option('pcre2') +if want_pcre2 != 'false' + libpcre2 = dependency('libpcre2-8', + required : want_pcre2 == 'true') + have = libpcre2.found() +else + have = false + libpcre2 = [] +endif +conf.set10('HAVE_PCRE2', have) + want_glib = get_option('glib') -if want_glib != 'false' and not fuzzer_build +if want_glib != 'false' libglib = dependency('glib-2.0', version : '>= 2.22.0', required : want_glib == 'true') @@ -1275,7 +1247,7 @@ endif conf.set10('HAVE_GLIB', have) want_dbus = get_option('dbus') -if want_dbus != 'false' and not fuzzer_build +if want_dbus != 'false' libdbus = dependency('dbus-1', version : '>= 1.3.2', required : want_dbus == 'true') @@ -1288,9 +1260,6 @@ conf.set10('HAVE_DBUS', have) #if 0 /// UNNEEDED by elogind # default_dnssec = get_option('default-dnssec') -# if fuzzer_build -# default_dnssec = 'no' -# endif # if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0 # message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.') # default_dnssec = 'no' @@ -1375,11 +1344,9 @@ endforeach want_tests = get_option('tests') install_tests = get_option('install-tests') -slow_tests = get_option('slow-tests') tests = [] -fuzzers = [] -conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests) +conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', get_option('slow-tests')) ##################################################################### @@ -1550,7 +1517,6 @@ subdir('src/shared') #endif // 0 subdir('src/test') -subdir('src/fuzz') #if 0 /// UNNEEDED in elogind # subdir('rules') # subdir('test') @@ -2738,9 +2704,8 @@ foreach tuple : tests timeout = type.split('=')[1].to_int() type = '' endif - if want_tests == 'false' - message('Not compiling @0@ because tests is set to false'.format(name)) - elif condition == '' or conf.get(condition) == 1 + + if condition == '' or conf.get(condition) == 1 exe = executable( name, sources, @@ -2790,36 +2755,6 @@ endforeach # # ############################################################ # -# fuzzer_exes = [] -# -# foreach tuple : fuzzers -# sources = tuple[0] -# link_with = tuple[1].length() > 0 ? tuple[1] : [libshared] -# dependencies = tuple[2] -# defs = tuple.length() >= 4 ? tuple[3] : [] -# incs = tuple.length() >= 5 ? tuple[4] : includes -# -# if fuzzer_build -# dependencies += fuzzing_engine -# else -# sources += 'src/fuzz/fuzz-main.c' -# endif -# -# name = sources[0].split('/')[-1].split('.')[0] -# -# fuzzer_exes += executable( -# name, -# sources, -# include_directories : [incs, include_directories('src/fuzz')], -# link_with : link_with, -# dependencies : dependencies, -# c_args : defs, -# install : false) -# endforeach -# -# run_target('fuzzers', -# depends : fuzzer_exes, -# command : ['true']) #else test_libelogind_sym = executable( 'test-libelogind-sym', @@ -2831,9 +2766,6 @@ test_libelogind_sym = executable( test('test-libelogind-sym', test_libelogind_sym) #endif // 0 - -############################################################ - make_directive_index_py = find_program('tools/make-directive-index.py') make_man_index_py = find_program('tools/make-man-index.py') xml_helper_py = find_program('tools/xml_helper.py') @@ -2900,50 +2832,6 @@ endforeach ############################################################ -prev = '' -foreach p : fuzz_regression_tests - a = p.split('/')[-3] - b = p.split('/')[-2] - c = p.split('/')[-1] - - if a == 'address' - build = sanitize_address - else - error('unknown sanitizer @0@'.format(a)) - endif - - name = '@1@:@0@'.format(a, b) - - if name != prev - if want_tests == 'false' - message('Not compiling @0@ because tests is set to false'.format(name)) - elif not sanitizers.contains(a) - message('Not compiling @0@ because @1@ sanitizer is not available'.format(name, a)) - elif slow_tests - exe = custom_target( - name, - output : name, - depends : build, - command : [env, 'ln', '-fs', - join_paths(build.full_path(), b), - '@OUTPUT@'], - build_by_default : true) - else - message('Not compiling @0@ because slow-tests is set to false'.format(name)) - endif - endif - prev = name - - if want_tests != 'false' and slow_tests - test(c, env, args : [exe.full_path(), - join_paths(meson.source_root(), - 'test/fuzz-regressions', - p)]) - endif -endforeach - -############################################################ - if git.found() all_files = run_command( git, @@ -2955,11 +2843,11 @@ if git.found() custom_target( 'tags', output : 'tags', - command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files) + command : ['env', 'etags', '-o', '@0@/TAGS'.format(meson.current_source_dir())] + all_files) custom_target( 'ctags', output : 'ctags', - command : [env, 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files) + command : ['env', 'ctags', '-o', '@0@/tags'.format(meson.current_source_dir())] + all_files) endif #if 0 /// UNNEEDED by elogind @@ -3154,6 +3042,7 @@ foreach tuple : [ # ['gnu-efi', have_gnu_efi], # ['kmod'], # ['xkbcommon'], +# ['pcre2'], # ['blkid'], #endif // 0 ['dbus'], diff --git a/meson_options.txt b/meson_options.txt index 20cdb9fe6..dc2067c98 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -319,6 +319,8 @@ option('pam', type : 'combo', choices : ['auto', 'true', 'false'], # option('xkbcommon', type : 'combo', choices : ['auto', 'true', 'false'], # description : 'xkbcommon keymap support') #endif // 0 +option('pcre2', type : 'combo', choices : ['auto', 'true', 'false'], + description : 'regexp matching support using pcre2') option('glib', type : 'combo', choices : ['auto', 'true', 'false'], description : 'libglib support (for tests only)') option('dbus', type : 'combo', choices : ['auto', 'true', 'false'], @@ -346,14 +348,9 @@ option('bashcompletiondir', type : 'string', option('zshcompletiondir', type : 'string', description : 'directory for zsh completion scripts ["no" disables]') -option('tests', type : 'combo', choices : ['true', 'unsafe', 'false'], +option('tests', type : 'combo', choices : ['true', 'unsafe'], description : 'enable extra tests with =unsafe') option('slow-tests', type : 'boolean', value : 'false', description : 'run the slow tests by default') option('install-tests', type : 'boolean', value : 'false', description : 'install test executables') - -option('oss-fuzz', type : 'boolean', value : 'false', - description : 'build against oss-fuzz') -option('llvm-fuzz', type : 'boolean', value : 'false', - description : 'build against LLVM libFuzzer') diff --git a/src/basic/build.h b/src/basic/build.h index b887e8e90..61968d59e 100644 --- a/src/basic/build.h +++ b/src/basic/build.h @@ -143,6 +143,12 @@ #if HAVE_LIBIDN #define _IDN_FEATURE_ "+IDN" + +#if HAVE_PCRE2 +#define _PCRE2_FEATURE_ "+PCRE2" +#else +#define _PCRE2_FEATURE_ "-PCRE2" +#endif #else #define _IDN_FEATURE_ "-IDN" #endif @@ -172,6 +178,7 @@ _KMOD_FEATURE_ " " \ _IDN2_FEATURE_ " " \ _IDN_FEATURE_ " " \ + _PCRE2_FEATURE_ " " \ _CGROUP_HIEARCHY_ #else #define SYSTEMD_FEATURES \