aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-17 11:42:15 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2020-03-17 14:41:09 +0300
commit35976f064a5fa790d7b9655a9dfd422703255cb7 (patch)
tree5a3ba7e667e3cfa87280531318c205fa20419eae
parentff5c508e1678e2e8a02544cd71c5560bb59f313c (diff)
Fix backlinking code to follow symlinks in hardlink targets
-rw-r--r--libbuild2/algorithm.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 1ecf4de..34283f9 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -1241,7 +1241,16 @@ namespace build2
// Fall through.
case mode::symbolic: mksymlink (p, l, d); break;
- case mode::hard: mkhardlink (p, l, d); break;
+ case mode::hard:
+ {
+ // The target can be a symlink (or a symlink chain) with a
+ // relative target that, unless the (final) symlink and the
+ // hardlink are in the same directory, will result in a dangling
+ // link.
+ //
+ mkhardlink (followsymlink (p), l, d);
+ break;
+ }
case mode::copy:
case mode::overwrite:
{
@@ -1252,7 +1261,7 @@ namespace build2
// only used to "link" a Windows DLL assembly with only files
// inside. We also have to use hard links; see the relevant
// comment in cc/link-rule for details. Maybe we can invent a
- // special "assembly link" for this).
+ // special Windows-only "assembly link" for this).
//
dir_path fr (path_cast<dir_path> (p));
dir_path to (path_cast<dir_path> (l));