From 13840225f01b5000e726b27ad2cca1f4837e0a4d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Feb 2024 08:28:35 +0200 Subject: Deal with libs{} being member of group in windows_rpath_timestamp() Fixes GH issue #366. --- libbuild2/algorithm.cxx | 1 - libbuild2/cc/windows-rpath.cxx | 15 ++++++++++++++- libbuild2/target.hxx | 12 ++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 36d45b2..7fde2a9 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -2840,7 +2840,6 @@ namespace build2 // s.recipe_group_action may be used further (see, for example, // group_state()) and should retain its value. // - // if (!s.recipe_keep) s.recipe = nullptr; diff --git a/libbuild2/cc/windows-rpath.cxx b/libbuild2/cc/windows-rpath.cxx index bd5a928..eb62ad1 100644 --- a/libbuild2/cc/windows-rpath.cxx +++ b/libbuild2/cc/windows-rpath.cxx @@ -45,6 +45,8 @@ namespace build2 // Return the greatest (newest) timestamp of all the DLLs that we will be // adding to the assembly or timestamp_nonexistent if there aren't any. // + // Note: called during the execute phase. + // timestamp link_rule:: windows_rpath_timestamp (const file& t, const scope& bs, @@ -88,7 +90,18 @@ namespace build2 // if (l->is_a () && !l->path ().empty ()) // Also covers binless. { - timestamp t (l->load_mtime ()); + // Handle the case where the library is a member of a group (for + // example, people are trying to hack something up with pre-built + // libraries; see GH issue #366). + // + timestamp t; + if (l->group_state (action () /* inner */)) + { + t = l->group->is_a ()->mtime (); + assert (t != timestamp_unknown); + } + else + t = l->load_mtime (); if (t > r) r = t; diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index b97d562..0d4eece 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1058,6 +1058,12 @@ namespace build2 target_state executed_state (action, bool fail = true) const; + // Return true if the state comes from the group. Target must be at least + // matched except for ad hoc group members during the execute phase. + // + bool + group_state (action) const; + protected: // Version that should be used during match after the target has been // matched for this action. @@ -1074,12 +1080,6 @@ namespace build2 target_state executed_state_impl (action) const; - // Return true if the state comes from the group. Target must be at least - // matched except for ad hoc group members during the execute phase. - // - bool - group_state (action) const; - public: // Targets to which prerequisites resolve for this action. Note that // unlike prerequisite::target, these can be resolved to group members. -- cgit v1.1