Repository: mesonbuild/meson

Issue:
0.51.0 testsuite failure
Updating from 0.50.1 to 0.51.0 adds a new testsuite failure:

```
Mesonlogs of failing tests

Build started at 2019-06-17T14:15:45.999777
Main binary: /usr/bin/python3
Python system: Linux
The Meson build system
Version: 0.51.0
Source dir: /build/meson/src/meson-0.51.0/test cases/cuda/5 threads
Build dir: /build/meson/src/meson-0.51.0/b f0de5ce3c0
Build type: native build
Project name: simple
Project version: 1.0.0
No CUFLAGS in the environment, not changing global flags.
No LDFLAGS in the environment, not changing global flags.
Sanity testing Cuda compiler: nvcc
Is cross compiler: None.
Sanity check compiler command line:  nvcc -w -cudart static /build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.cu -o /build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.exe
Sanity check compile stdout: 

-----
Sanity check compile stderr:

-----
Sanity check run command line:  nvcc --run "/build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.exe"
Sanity check run stdout: 

-----
Sanity check run stderr:
100

-----
cudaGetDeviceCount() returned 100

Cuda compiler for the build machine: nvcc (nvcc 10.1.168)
No CUFLAGS in the environment, not changing global flags.
No LDFLAGS in the environment, not changing global flags.
Sanity testing Cuda compiler: nvcc
Is cross compiler: None.
Sanity check compiler command line:  nvcc -w -cudart static /build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.cu -o /build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.exe
Sanity check compile stdout: 

-----
Sanity check compile stderr:

-----
Sanity check run command line:  nvcc --run "/build/meson/src/meson-0.51.0/b f0de5ce3c0/meson-private/sanitycheckcuda.exe"
Sanity check run stdout: 

-----
Sanity check run stderr:
100

-----
cudaGetDeviceCount() returned 100

Cuda compiler for the host machine: nvcc (nvcc 10.1.168)
Build machine cpu family: x86_64
Build machine cpu: x86_64
 

Traceback (most recent call last):
  File "/build/meson/src/meson-0.51.0/mesonbuild/mesonmain.py", line 127, in run
    return options.run_func(options)
  File "/build/meson/src/meson-0.51.0/mesonbuild/msetup.py", line 240, in run
    app.generate()
  File "/build/meson/src/meson-0.51.0/mesonbuild/msetup.py", line 158, in generate
    self._generate(env)
  File "/build/meson/src/meson-0.51.0/mesonbuild/msetup.py", line 187, in _generate
    intr.run()
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreter.py", line 3917, in run
    super().run()
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 407, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 431, in evaluate_codeblock
    raise e
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 425, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 438, in evaluate_statement
    return self.assignment(cur)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 1048, in assignment
    value = self.evaluate_statement(node.value)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 436, in evaluate_statement
    return self.function_call(cur)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 773, in function_call
    return func(node, posargs, kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 285, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 285, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 285, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  [Previous line repeated 1 more time]
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 155, in wrapped
    ret = f(*wrapped_args, **wrapped_kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreterbase.py", line 174, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreter.py", line 3028, in func_dependency
    d = self.dependency_impl(name, display_name, kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/interpreter.py", line 3075, in dependency_impl
    dep = dependencies.find_external_dependency(name, self.environment, kwargs)
  File "/build/meson/src/meson-0.51.0/mesonbuild/dependencies/base.py", line 2516, in find_external_dependency
    d = c()
  File "/build/meson/src/meson-0.51.0/mesonbuild/dependencies/misc.py", line 391, in __init__
    self.compile_args = self.clib_compiler.thread_flags(environment)
AttributeError: 'NoneType' object has no attribute 'thread_flags'
```

Arch Linux


Discussion:

Resolving patch:
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -388,8 +388,14 @@ def __init__(self, environment, kwargs):
         super().__init__('threads', environment, None, kwargs)
         self.name = 'threads'
         self.is_found = True
-        self.compile_args = self.clib_compiler.thread_flags(environment)
-        self.link_args = self.clib_compiler.thread_link_flags(environment)
+        # Happens if you are using a language with threads
+        # concept without C, such as plain Cuda.
+        if self.clib_compiler is None:
+            self.compile_args = []
+            self.link_args = []
+        else:
+            self.compile_args = self.clib_compiler.thread_flags(environment)
+            self.link_args = self.clib_compiler.thread_link_flags(environment)
 
 
 class Python3Dependency(ExternalDependency):


Test patch: