https://gcc.gnu.org/g:6dcbbcd27c534df3a4b8d0d0d0319677b8edee08

commit r15-9440-g6dcbbcd27c534df3a4b8d0d0d0319677b8edee08
Author: Arthur Cohen <arthur.co...@embecosm.com>
Date:   Fri Apr 4 14:18:33 2025 +0200

    gccrs: nr2.0: Do not resolve modules this run if they are unloaded
    
    Instead, mark the visitor as dirty and wait for the next round of the fixed 
point to take care of
    them. This avoids issues with module items being loaded while not being 
stripped yet.
    
    gcc/rust/ChangeLog:
    
            * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): 
Return if module
            is unloaded.

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 8863be768a1a..ba37dee88faf 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -113,7 +113,17 @@ TopLevel::visit (AST::Module &module)
   // This was copied from the old early resolver method
   // 'accumulate_escaped_macros'
   if (module.get_kind () == AST::Module::UNLOADED)
-    module.load_items ();
+    {
+      module.load_items ();
+
+      // If the module was previously unloaded, then we don't want to visit it
+      // this time around as the CfgStrip hasn't run on its inner items yet.
+      // Skip it for now, mark the visitor as dirty and try again
+
+      dirty = true;
+
+      return;
+    }
 
   DefaultResolver::visit (module);

Reply via email to