aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index fa07235..05427d3 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2328,8 +2328,12 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
bargs = []
return (sargs, bargs)
- @lru_cache(maxsize=None)
def _generate_single_compile(self, target, compiler, is_generated=False):
+ commands = self._generate_single_compile_base_args(target, compiler, is_generated)
+ commands += self._generate_single_compile_target_args(target, compiler, is_generated)
+ return commands
+
+ def _generate_single_compile_base_args(self, target, compiler, is_generated):
base_proxy = self.get_base_options_for_target(target)
# Create an empty commands list, and start adding arguments from
# various sources in the order in which they must override each other
@@ -2341,12 +2345,16 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# These have the lowest priority.
commands += compilers.get_base_compile_args(base_proxy,
compiler)
+ return commands
+
+ @lru_cache(maxsize=None)
+ def _generate_single_compile_target_args(self, target, compiler, is_generated):
# The code generated by valac is usually crap and has tons of unused
# variables and such, so disable warnings for Vala C sources.
no_warn_args = (is_generated == 'vala')
# Add compiler args and include paths from several sources; defaults,
# build options, external dependencies, etc.
- commands += self.generate_basic_compiler_args(target, compiler, no_warn_args)
+ commands = self.generate_basic_compiler_args(target, compiler, no_warn_args)
# Add custom target dirs as includes automatically, but before
# target-specific include directories.
if target.implicit_include_directories:
@@ -2410,7 +2418,14 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
raise AssertionError(f'BUG: sources should not contain headers {src!r}')
compiler = get_compiler_for_source(target.compilers.values(), src)
- commands = self._generate_single_compile(target, compiler, is_generated)
+ commands = self._generate_single_compile_base_args(target, compiler, is_generated)
+
+ # Include PCH header as first thing as it must be the first one or it will be
+ # ignored by gcc https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462
+ if self.environment.coredata.options.get(OptionKey('b_pch')) and is_generated != 'pch':
+ commands += self.get_pch_include_args(compiler, target)
+
+ commands += self._generate_single_compile_target_args(target, compiler, is_generated)
commands = commands.compiler.compiler_args(commands)
# Create introspection information
@@ -2441,7 +2456,6 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# PCH handling
if self.environment.coredata.options.get(OptionKey('b_pch')):
- commands += self.get_pch_include_args(compiler, target)
pchlist = target.get_pch(compiler.language)
else:
pchlist = []