From a0e2979d91d50b175b08b3f35cda7f75fc10bbac Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Aug 2019 15:21:03 +0200 Subject: Fix bug in mkanylink() usage --- build2/cc/link-rule.cxx | 10 +++++----- libbuild2/install/rule.cxx | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx index e627aff..4be3c3f 100644 --- a/build2/cc/link-rule.cxx +++ b/build2/cc/link-rule.cxx @@ -2855,7 +2855,7 @@ namespace build2 if (file_exists (l, false /* follow_symlinks */)) try_rmfile (l); - mkanylink (f, l, true /* copy */); + mkanylink (f, l, true /* copy */, true /* relative */); } catch (system_error& e) { @@ -2883,10 +2883,10 @@ namespace build2 const path* f (paths.real); - if (!in.empty ()) {ln (f->leaf (), in); f = ∈} - if (!so.empty ()) {ln (f->leaf (), so); f = &so;} - if (!ld.empty ()) {ln (f->leaf (), ld); f = &ld;} - if (!lk.empty ()) {ln (f->leaf (), lk);} + if (!in.empty ()) {ln (*f, in); f = ∈} + if (!so.empty ()) {ln (*f, so); f = &so;} + if (!ld.empty ()) {ln (*f, ld); f = &ld;} + if (!lk.empty ()) {ln (*f, lk);} } else if (lt.static_library ()) { diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx index 90ee7cb..fdbbffa 100644 --- a/libbuild2/install/rule.cxx +++ b/libbuild2/install/rule.cxx @@ -873,7 +873,15 @@ namespace build2 if (file_exists (target, false /* follow_symlinks */)) try_rmfile (target); - mkanylink (target, rell, true /* copy */); + // We have to go the roundabout way by adding directory to the + // target and then asking for a relative symlink because it may be a + // hardlink in which case the target path will be interpreted from + // CWD. + // + mkanylink (rell.directory () / target, + rell, + true /* copy */, + true /* relative */); } catch (system_error& e) { -- cgit v1.1