Skip to content

Commit

Permalink
Always use posix paths when retrieving link name
Browse files Browse the repository at this point in the history
This commit modifies the get_target_filename_for_linking function to
always return POSIX-style paths, even on Windows systems. This is
necessary because the Ninja generator can have issues with Windows-style
paths when using the `/WHOLEARCHIVE:` flag.

This is consistent with the syntax accepted by the cl and clang-cl
compilers, as documented in the Microsoft documentation:
https: //learn.microsoft.com/en-us/cpp/build/reference/cl-filename-syntax?view=msvc-170

Fixes: 12534
  • Loading branch information
pokowaka authored and nirbheek committed Dec 19, 2023
1 parent cfa9322 commit 1cfca06
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,16 @@ def get_target_filename_for_linking(self, target: T.Union[build.Target, build.Cu
# In AIX, if we archive .so, the blibpath must link to archived shared library otherwise to the .so file.
if mesonlib.is_aix() and target.aix_so_archive:
link_lib = re.sub('[.][a]([.]?([0-9]+))*([.]?([a-z]+))*', '.a', link_lib.replace('.so', '.a'))
return os.path.join(self.get_target_dir(target), link_lib)
return Path(self.get_target_dir(target), link_lib).as_posix()
elif isinstance(target, build.StaticLibrary):
return os.path.join(self.get_target_dir(target), target.get_filename())
return Path(self.get_target_dir(target), target.get_filename()).as_posix()
elif isinstance(target, (build.CustomTarget, build.CustomTargetIndex)):
if not target.is_linkable_target():
raise MesonException(f'Tried to link against custom target "{target.name}", which is not linkable.')
return os.path.join(self.get_target_dir(target), target.get_filename())
return Path(self.get_target_dir(target), target.get_filename()).as_posix()
elif isinstance(target, build.Executable):
if target.import_filename:
return os.path.join(self.get_target_dir(target), target.get_import_filename())
return Path(self.get_target_dir(target), target.get_import_filename()).as_posix()
else:
return None
raise AssertionError(f'BUG: Tried to link to {target!r} which is not linkable')
Expand Down

0 comments on commit 1cfca06

Please sign in to comment.