Skip to content

Load modules during CfgStrip phase#3871

Merged
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
powerboat9:mod-fix
Jul 21, 2025
Merged

Load modules during CfgStrip phase#3871
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
powerboat9:mod-fix

Conversation

@powerboat9

Copy link
Copy Markdown
Collaborator

TopLevel would ignore just-loaded modules but Early and ExpandVisitor wouldn't. The latter would produce errors when it hit attributes which should have been indirectly CfgStrip'd away.

TopLevel would ignore just-loaded modules but Early and ExpandVisitor
wouldn't. The latter would produce errors when it hit attributes which
should have been indirectly CfgStrip'd away.

gcc/rust/ChangeLog:

	* expand/rust-cfg-strip.cc (CfgStrip::visit): Load unloaded
	modules.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
	Assume modules have been loaded by CfgStrip.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

@CohenArthur CohenArthur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this causes issues with modules being loaded when they should be cfg-stripped, e.g

#[cfg(target_arch = "not_my_stuff")]
mod foo;

when running the compiler on core with this change, we error out much earlier than without, and on a module specifically for the x86 arch.

@CohenArthur

Copy link
Copy Markdown
Member

nevermind my comment - the order just changed and I'm hitting the same error now that I'm progressing on name resolution. so I think this change is probably fine

@CohenArthur CohenArthur added this pull request to the merge queue Jul 21, 2025
Merged via the queue into Rust-GCC:master with commit 48f93dc Jul 21, 2025
13 checks passed
@powerboat9 powerboat9 deleted the mod-fix branch July 21, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants