diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-09 22:08:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-09 22:08:00 +0200 |
commit | dfd368d4054bfe067545112717a5bd21bc37aca7 (patch) | |
tree | 0de531ef07c66ae08e527f24b757a89ec399396f | |
parent | de8018a17d9b84b2a57761ad624cc669c4e136a4 (diff) | |
parent | 62fc6e7412ec340b230e604437eb67861553bb91 (diff) | |
download | meson-dfd368d4054bfe067545112717a5bd21bc37aca7.zip meson-dfd368d4054bfe067545112717a5bd21bc37aca7.tar.gz meson-dfd368d4054bfe067545112717a5bd21bc37aca7.tar.bz2 |
Merge pull request #2803 from dcbaker/wip/freebsd-fixes
various BSD fixes
22 files changed, 144 insertions, 36 deletions
diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index 8e048dc..ee3b8c2 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -57,6 +57,9 @@ These are provided by the `.system()` method call. | windows | Any version of Windows | | cygwin | The Cygwin environment for Windows | | haiku | | +| freebsd | FreeBSD and it's derivatives | +| dragonfly | DragonFly BSD | +| netbsd | | Any string not listed above is not guaranteed to remain stable in future releases. diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b14074b..2602d14 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -855,7 +855,15 @@ class Compiler: paths = padding else: paths = paths + ':' + padding - args = ['-Wl,-rpath,' + paths] + args = [] + if mesonlib.is_dragonflybsd(): + # This argument instructs the compiler to record the value of + # ORIGIN in the .dynamic section of the elf. On Linux this is done + # by default, but is not on dragonfly for some reason. Without this + # $ORIGIN in the runtime path will be undefined and any binaries + # linked against local libraries will fail to resolve them. + args.append('-Wl,-z,origin') + args.append('-Wl,-rpath,' + paths) if get_compiler_is_linuxlike(self): # Rpaths to use while linking must be absolute. These are not # written to the binary. Needed only with GNU ld: diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 91414d5..25316df 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -17,11 +17,10 @@ import os import re -import shutil from .. import mlog from .. import mesonlib -from ..mesonlib import version_compare, Popen_safe, stringlistify, extract_as_list +from ..mesonlib import version_compare, stringlistify, extract_as_list from .base import ( DependencyException, ExternalDependency, PkgConfigDependency, strip_system_libdirs, ConfigToolDependency, @@ -171,9 +170,37 @@ class LLVMDependency(ConfigToolDependency): else: self._set_old_link_args() self.link_args = strip_system_libdirs(environment, self.link_args) + self.link_args = self.__fix_bogus_link_args(self.link_args) + + @staticmethod + def __fix_bogus_link_args(args): + """This function attempts to fix bogus link arguments that llvm-config + generates. + + Currently it works around the following: + - FreeBSD: when statically linking -l/usr/lib/libexecinfo.so will + be generated, strip the -l in cases like this. + """ + new_args = [] + for arg in args: + if arg.startswith('-l') and arg.endswith('.so'): + new_args.append(arg.lstrip('-l')) + else: + new_args.append(arg) + return new_args def _set_new_link_args(self): """How to set linker args for LLVM versions >= 3.9""" + if ((mesonlib.is_dragonflybsd() or mesonlib.is_freebsd()) and not + self.static and version_compare(self.version, '>= 4.0')): + # llvm-config on DragonFly BSD and FreeBSD for versions 4.0, 5.0, + # and 6.0 have an error when generating arguments for shared mode + # linking, even though libLLVM.so is installed, because for some + # reason the tool expects to find a .so for each static library. + # This works around that. + self.link_args = self.get_config_value(['--ldflags'], 'link_args') + self.link_args.append('-lLLVM') + return link_args = ['--link-static', '--system-libs'] if self.static else ['--link-shared'] self.link_args = self.get_config_value( ['--libs', '--ldflags'] + link_args + list(self.required_modules), diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index de83e90..4871bf7 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -296,6 +296,12 @@ def is_cygwin(): def is_debianlike(): return os.path.isfile('/etc/debian_version') +def is_dragonflybsd(): + return platform.system().lower() == 'dragonfly' + +def is_freebsd(): + return platform.system().lower() == 'freebsd' + def for_windows(is_cross, env): """ Host machine is windows? diff --git a/run_project_tests.py b/run_project_tests.py index 74e4ca7..d191e28 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -448,20 +448,28 @@ def have_objc_compiler(): env = environment.Environment(None, build_dir, None, get_fake_options('/'), []) try: objc_comp = env.detect_objc_compiler(False) - except: + except mesonlib.MesonException: return False if not objc_comp: return False try: objc_comp.sanity_check(env.get_scratch_dir(), env) - objcpp_comp = env.detect_objc_compiler(False) - except: + except mesonlib.MesonException: + return False + return True + +def have_objcpp_compiler(): + with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir: + env = environment.Environment(None, build_dir, None, get_fake_options('/'), []) + try: + objcpp_comp = env.detect_objcpp_compiler(False) + except mesonlib.MesonException: return False if not objcpp_comp: return False try: objcpp_comp.sanity_check(env.get_scratch_dir(), env) - except: + except mesonlib.MesonException: return False return True @@ -488,6 +496,7 @@ def detect_tests_to_run(): ('rust', 'rust', backend is not Backend.ninja or not shutil.which('rustc')), ('d', 'd', backend is not Backend.ninja or not have_d_compiler()), ('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or mesonlib.is_windows() or not have_objc_compiler()), + ('objective c++', 'objcpp', backend not in (Backend.ninja, Backend.xcode) or mesonlib.is_windows() or not have_objcpp_compiler()), ('fortran', 'fortran', backend is not Backend.ninja or not shutil.which('gfortran')), ('swift', 'swift', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('swiftc')), ('python3', 'python3', backend is not Backend.ninja), diff --git a/run_unittests.py b/run_unittests.py index 08ad632..f61544f 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -34,8 +34,10 @@ import mesonbuild.environment import mesonbuild.mesonlib import mesonbuild.coredata from mesonbuild.interpreter import ObjectHolder -from mesonbuild.mesonlib import is_linux, is_windows, is_osx, is_cygwin, windows_proof_rmtree -from mesonbuild.mesonlib import python_command, meson_command, version_compare +from mesonbuild.mesonlib import ( + is_linux, is_windows, is_osx, is_cygwin, is_dragonflybsd, + windows_proof_rmtree, python_command, meson_command, version_compare, +) from mesonbuild.environment import Environment, detect_ninja from mesonbuild.mesonlib import MesonException, EnvironmentException from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram @@ -1386,12 +1388,24 @@ int main(int argc, char **argv) { for each in ('prog', 'subdir/liblib1.so', ): rpath = get_rpath(os.path.join(self.builddir, each)) self.assertTrue(rpath) - for path in rpath.split(':'): + if is_dragonflybsd(): + # DragonflyBSD will prepend /usr/lib/gccVERSION to the rpath, + # so ignore that. + self.assertTrue(rpath.startswith('/usr/lib/gcc')) + rpaths = rpath.split(':')[1:] + else: + rpaths = rpath.split(':') + for path in rpaths: self.assertTrue(path.startswith('$ORIGIN'), msg=(each, path)) # These two don't link to anything else, so they do not need an rpath entry. for each in ('subdir/subdir2/liblib2.so', 'subdir/subdir3/liblib3.so'): rpath = get_rpath(os.path.join(self.builddir, each)) - self.assertTrue(rpath is None) + if is_dragonflybsd(): + # The rpath should be equal to /usr/lib/gccVERSION + self.assertTrue(rpath.startswith('/usr/lib/gcc')) + self.assertEqual(len(rpath.split(':')), 1) + else: + self.assertTrue(rpath is None) def test_dash_d_dedup(self): testdir = os.path.join(self.unit_test_dir, '10 d dedup') diff --git a/test cases/common/135 generated assembly/square-arm.S.in b/test cases/common/135 generated assembly/square-arm.S.in index 168c980..d2fb7ac 100644 --- a/test cases/common/135 generated assembly/square-arm.S.in +++ b/test cases/common/135 generated assembly/square-arm.S.in @@ -2,8 +2,8 @@ .text .globl SYMBOL_NAME(square_unsigned) -/* Only supported on Linux with GAS */ -# ifdef __linux__ +/* Only supported with GAS */ +# if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) .type square_unsigned,%function #endif diff --git a/test cases/common/135 generated assembly/square-x86.S.in b/test cases/common/135 generated assembly/square-x86.S.in index 19dd9f5..ee77b81 100644 --- a/test cases/common/135 generated assembly/square-x86.S.in +++ b/test cases/common/135 generated assembly/square-x86.S.in @@ -21,8 +21,8 @@ END .text .globl SYMBOL_NAME(square_unsigned) -/* Only supported on Linux with GAS */ -# ifdef __linux__ +/* Only supported with GAS */ +# if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) .type square_unsigned,@function # endif diff --git a/test cases/common/135 generated assembly/square-x86_64.S.in b/test cases/common/135 generated assembly/square-x86_64.S.in index 0834f16..856af13 100644 --- a/test cases/common/135 generated assembly/square-x86_64.S.in +++ b/test cases/common/135 generated assembly/square-x86_64.S.in @@ -18,8 +18,8 @@ END .text .globl SYMBOL_NAME(square_unsigned) -/* Only supported on Linux with GAS */ -# ifdef __linux__ +/* Only supported with GAS */ +# if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) .type square_unsigned,@function # endif diff --git a/test cases/common/140 get define/meson.build b/test cases/common/140 get define/meson.build index e23b7de..fd87177 100644 --- a/test cases/common/140 get define/meson.build +++ b/test cases/common/140 get define/meson.build @@ -19,6 +19,19 @@ foreach lang : ['c', 'cpp'] elif host_system == 'haiku' d = cc.get_define('__HAIKU__') assert(d == '1', '__HAIKU__ value is @0@ instead of 1'.format(d)) + elif host_system == 'freebsd' + # the __FreeBSD__ define will be equal to the major version of the release + # (ex, in FreeBSD 11.x, __FreeBSD__ == 11). To make the test robust when + # being run on various versions of FreeBSD, just test that the define is + # set. + d = cc.get_define('__FreeBSD__') + assert(d != '', '__FreeBSD__ value is unset') + elif host_system == 'dragonfly' + d = cc.get_define('__DragonFly__') + assert(d == '1', '__DragonFly__ value is @0@ instead of 1'.format(d)) + elif host_system == 'netbsd' + d = cc.get_define('__NetBSD__') + assert(d == '1', '__NetBSD__ value is @0@ instead of 1'.format(d)) else error('Please report a bug and help us improve support for this platform') endif @@ -28,8 +41,16 @@ foreach lang : ['c', 'cpp'] # found in the compiler's default search path, GCC inserts an extra comment # between the delimiter and the define which causes a parsing error. # https://github.com/mesonbuild/meson/issues/1726 - ver = cc.get_define('ZLIB_VER_MAJOR', prefix : '#include <zlib.h>') - assert(ver == '1', 'ZLIB_VER_MAJOR value is "@0@" instead of "1"'.format(ver)) + if host_machine.system() == 'netbsd' + # NetBSD's zlib doesn't is version 1.2.3 and doesn't have a + # ZLIB_VER_MAJOR, but it does have a ZLIB_VERSION (which is a string), so + # check the first non-quote character of that. + ver = cc.get_define('ZLIB_VERSION', prefix : '#include <zlib.h>')[1] + assert(ver == '1', 'ZLIB_VERSION (major) value is "@0@" instead of "1"'.format(ver)) + else + ver = cc.get_define('ZLIB_VER_MAJOR', prefix : '#include <zlib.h>') + assert(ver == '1', 'ZLIB_VER_MAJOR value is "@0@" instead of "1"'.format(ver)) + endif endif # Check that an undefined value is empty. diff --git a/test cases/frameworks/15 llvm/meson.build b/test cases/frameworks/15 llvm/meson.build index 5211006..549adce 100644 --- a/test cases/frameworks/15 llvm/meson.build +++ b/test cases/frameworks/15 llvm/meson.build @@ -20,17 +20,19 @@ foreach static : [true, false] 'llvm', modules : ['bitwriter', 'asmprinter', 'executionengine', 'target', 'mcjit', 'nativecodegen'], - required : true, + required : false, static : static, ) - name = static ? 'static' : 'dynamic' - executable( - 'sum-@0@'.format(name), - 'sum.c', - dependencies : [ - llvm_dep, dep_tinfo, - dependency('zlib'), - meson.get_compiler('c').find_library('dl', required : false), - ] - ) + if llvm_dep.found() + name = static ? 'static' : 'dynamic' + executable( + 'sum-@0@'.format(name), + 'sum.c', + dependencies : [ + llvm_dep, dep_tinfo, + dependency('zlib'), + meson.get_compiler('c').find_library('dl', required : false), + ] + ) + endif endforeach diff --git a/test cases/frameworks/17 mpi/meson.build b/test cases/frameworks/17 mpi/meson.build index 17acd71..01ad61d 100644 --- a/test cases/frameworks/17 mpi/meson.build +++ b/test cases/frameworks/17 mpi/meson.build @@ -6,7 +6,10 @@ if build_machine.system() == 'windows' and cc.get_id() != 'msvc' error('MESON_SKIP_TEST: MPI not available on Windows without MSVC.') endif -mpic = dependency('mpi', language : 'c') +mpic = dependency('mpi', language : 'c', required : false) +if not mpic.found() + error('MESON_SKIP_TEST: MPI not found, skipping.') +endif exec = executable('exec', 'main.c', dependencies : [mpic]) diff --git a/test cases/frameworks/18 vulkan/meson.build b/test cases/frameworks/18 vulkan/meson.build index 54f1d47..e98854e 100644 --- a/test cases/frameworks/18 vulkan/meson.build +++ b/test cases/frameworks/18 vulkan/meson.build @@ -1,6 +1,9 @@ project('vulkan test', 'c') -vulkan_dep = dependency('vulkan') +vulkan_dep = dependency('vulkan', required : false) +if not vulkan_dep.found() + error('MESON_SKIP_TEST: vulkan not found.') +endif e = executable('vulkanprog', 'vulkanprog.c', dependencies : vulkan_dep) diff --git a/test cases/frameworks/2 gtest/meson.build b/test cases/frameworks/2 gtest/meson.build index 419f451..e5418e9 100644 --- a/test cases/frameworks/2 gtest/meson.build +++ b/test cases/frameworks/2 gtest/meson.build @@ -1,6 +1,9 @@ project('gtest', 'cpp') -gtest = dependency('gtest', main : true) +gtest = dependency('gtest', main : true, required : false) +if not gtest.found() + error('MESON_SKIP_TEST: gtest not installed.') +endif gtest_nomain = dependency('gtest', main : false) e = executable('testprog', 'test.cc', dependencies : gtest) diff --git a/test cases/frameworks/3 gmock/meson.build b/test cases/frameworks/3 gmock/meson.build index 341f9d7..516547f 100644 --- a/test cases/frameworks/3 gmock/meson.build +++ b/test cases/frameworks/3 gmock/meson.build @@ -3,8 +3,14 @@ project('gmock test', 'cpp') # Using gmock without gtest is a pain so just # don't support that then. -gtest = dependency('gtest', main : true) -gmock = dependency('gmock') +gtest = dependency('gtest', main : true, required : false) +if not gtest.found() + error('MESON_SKIP_TEST: gtest not installed.') +endif +gmock = dependency('gmock', required : false) +if not gmock.found() + error('MESON_SKIP_TEST: gmock not installed.') +endif e = executable('gmocktest', 'gmocktest.cc', dependencies : [gtest, gmock]) test('gmock test', e) diff --git a/test cases/objc/2 nsstring/meson.build b/test cases/objc/2 nsstring/meson.build index a877d74..7f2483f 100644 --- a/test cases/objc/2 nsstring/meson.build +++ b/test cases/objc/2 nsstring/meson.build @@ -5,7 +5,10 @@ if host_machine.system() == 'darwin' elif host_machine.system() == 'cygwin' error('MESON_SKIP_TEST GNUstep is not packaged for Cygwin.') else - dep = dependency('gnustep') + dep = dependency('gnustep', required : false) + if not dep.found() + error('MESON_SKIP_TEST: GNUstep is not installed') + endif if host_machine.system() == 'linux' and meson.get_compiler('objc').get_id() == 'clang' error('MESON_SKIP_TEST: GNUstep is broken on Linux with Clang') endif diff --git a/test cases/objc/4 objc args/meson.build b/test cases/objc/3 objc args/meson.build index 8887d96..8887d96 100644 --- a/test cases/objc/4 objc args/meson.build +++ b/test cases/objc/3 objc args/meson.build diff --git a/test cases/objc/4 objc args/prog.m b/test cases/objc/3 objc args/prog.m index bfd686a..bfd686a 100644 --- a/test cases/objc/4 objc args/prog.m +++ b/test cases/objc/3 objc args/prog.m diff --git a/test cases/objc/3 objc++/meson.build b/test cases/objcpp/1 simple/meson.build index 7d91884..7d91884 100644 --- a/test cases/objc/3 objc++/meson.build +++ b/test cases/objcpp/1 simple/meson.build diff --git a/test cases/objc/3 objc++/prog.mm b/test cases/objcpp/1 simple/prog.mm index 927e810..927e810 100644 --- a/test cases/objc/3 objc++/prog.mm +++ b/test cases/objcpp/1 simple/prog.mm diff --git a/test cases/objc/5 objc++ args/meson.build b/test cases/objcpp/2 objc++ args/meson.build index e0e34b0..e0e34b0 100644 --- a/test cases/objc/5 objc++ args/meson.build +++ b/test cases/objcpp/2 objc++ args/meson.build diff --git a/test cases/objc/5 objc++ args/prog.mm b/test cases/objcpp/2 objc++ args/prog.mm index 3decaf2..3decaf2 100644 --- a/test cases/objc/5 objc++ args/prog.mm +++ b/test cases/objcpp/2 objc++ args/prog.mm |