aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2023-07-05 01:10:58 +0300
committerGitHub <noreply@github.com>2023-07-05 01:10:58 +0300
commitd391e5281c982899e17c7a5ceeca30262f1640ea (patch)
tree17d134e2b037d66f4e75468e552587b7d9b0b95d /mesonbuild/backend
parent7fe6e18a02129d788cd29e6861b331341265f4c7 (diff)
parentff86e799a4d1119f51d7e7715944a2c87eaef509 (diff)
downloadmeson-d391e5281c982899e17c7a5ceeca30262f1640ea.zip
meson-d391e5281c982899e17c7a5ceeca30262f1640ea.tar.gz
meson-d391e5281c982899e17c7a5ceeca30262f1640ea.tar.bz2
Merge pull request #11742 from xclaesse/link-whole-cases
Fix niche cases when linking static libs
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py18
-rw-r--r--mesonbuild/backend/ninjabackend.py2
2 files changed, 17 insertions, 3 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index d425f06..3b87623 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -858,6 +858,8 @@ class Backend:
def _determine_ext_objs(self, extobj: 'build.ExtractedObjects', proj_dir_to_build_root: str) -> T.List[str]:
result: T.List[str] = []
+ targetdir = self.get_target_private_dir(extobj.target)
+
# Merge sources and generated sources
raw_sources = list(extobj.srclist)
for gensrc in extobj.genlist:
@@ -874,12 +876,18 @@ class Backend:
elif self.environment.is_object(s):
result.append(s.relative_name())
+ # MSVC generate an object file for PCH
+ if extobj.pch:
+ for lang, pch in extobj.target.pch.items():
+ compiler = extobj.target.compilers[lang]
+ if compiler.get_argument_syntax() == 'msvc':
+ objname = self.get_msvc_pch_objname(lang, pch)
+ result.append(os.path.join(proj_dir_to_build_root, targetdir, objname))
+
# extobj could contain only objects and no sources
if not sources:
return result
- targetdir = self.get_target_private_dir(extobj.target)
-
# With unity builds, sources don't map directly to objects,
# we only support extracting all the objects in this mode,
# so just return all object files.
@@ -914,6 +922,12 @@ class Backend:
args += compiler.get_pch_use_args(pchpath, p[0])
return includeargs + args
+ def get_msvc_pch_objname(self, lang: str, pch: T.List[str]) -> str:
+ if len(pch) == 1:
+ # Same name as in create_msvc_pch_implementation() below.
+ return f'meson_pch-{lang}.obj'
+ return os.path.splitext(pch[1])[0] + '.obj'
+
def create_msvc_pch_implementation(self, target: build.BuildTarget, lang: str, pch_header: str) -> str:
# We have to include the language in the file name, otherwise
# pch.c and pch.cpp will both end up as pch.obj in VS backends.
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 27be9a9..108aa72 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -3203,7 +3203,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
extradep = None
pch_objects += objs
rulename = self.compiler_to_pch_rule_name(compiler)
- elem = NinjaBuildElement(self.all_outputs, dst, rulename, src)
+ elem = NinjaBuildElement(self.all_outputs, objs + [dst], rulename, src)
if extradep is not None:
elem.add_dep(extradep)
self.add_header_deps(target, elem, header_deps)