Skip to content

Load modules during CfgStrip phase #3871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged

Conversation

powerboat9
Copy link
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 <[email protected]>
Copy link
Member

@CohenArthur CohenArthur left a comment

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
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