diff options
-rw-r--r-- | docs/markdown/snippets/vala_unity_builds_disabled.md | 7 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 2 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 25 |
3 files changed, 20 insertions, 14 deletions
diff --git a/docs/markdown/snippets/vala_unity_builds_disabled.md b/docs/markdown/snippets/vala_unity_builds_disabled.md new file mode 100644 index 0000000..80e6523 --- /dev/null +++ b/docs/markdown/snippets/vala_unity_builds_disabled.md @@ -0,0 +1,7 @@ +## Unity build with Vala disabled + +The approach that meson has used for Vala unity builds is incorrect, we +combine the generated C files like we would any other C file. This is very +fragile however, as the Vala compiler generates helper functions and macros +which work fine when each file is a separate translation unit, but fail when +they are combined. diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index f95ca4d..233173f 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -49,7 +49,7 @@ if T.TYPE_CHECKING: # Languages that can mix with C or C++ but don't support unity builds yet # because the syntax we use for unity builds is specific to C/++/ObjC/++. # Assembly files cannot be unitified and neither can LLVM IR files -LANGS_CANT_UNITY = ('d', 'fortran') +LANGS_CANT_UNITY = ('d', 'fortran', 'vala') class TestProtocol(enum.Enum): diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 949b59d..ca17f19 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -812,25 +812,24 @@ int dummy; # Generate compilation targets for C sources generated from Vala # sources. This can be extended to other $LANG->C compilers later if # necessary. This needs to be separate for at least Vala + # + # Do not try to unity-build the generated c files from vala, as these + # often contain duplicate symbols and will fail to compile properly vala_generated_source_files = [] for src in vala_generated_sources: dirpart, fnamepart = os.path.split(src) raw_src = File(True, dirpart, fnamepart) - if is_unity: - unity_src.append(os.path.join(self.environment.get_build_dir(), src)) + # Generated targets are ordered deps because the must exist + # before the sources compiling them are used. After the first + # compile we get precise dependency info from dep files. + # This should work in all cases. If it does not, then just + # move them from orderdeps to proper deps. + if self.environment.is_header(src): header_deps.append(raw_src) else: - # Generated targets are ordered deps because the must exist - # before the sources compiling them are used. After the first - # compile we get precise dependency info from dep files. - # This should work in all cases. If it does not, then just - # move them from orderdeps to proper deps. - if self.environment.is_header(src): - header_deps.append(raw_src) - else: - # We gather all these and generate compile rules below - # after `header_deps` (above) is fully generated - vala_generated_source_files.append(raw_src) + # We gather all these and generate compile rules below + # after `header_deps` (above) is fully generated + vala_generated_source_files.append(raw_src) for src in vala_generated_source_files: # Passing 'vala' here signifies that we want the compile # arguments to be specialized for C code generated by |