Skip to content

Extern prelude handling - #4758

Draft
P-E-P wants to merge 8 commits into
Rust-GCC:masterfrom
P-E-P:extern_prelude_2
Draft

Extern prelude handling#4758
P-E-P wants to merge 8 commits into
Rust-GCC:masterfrom
P-E-P:extern_prelude_2

Conversation

@P-E-P

@P-E-P P-E-P commented Aug 4, 2026

Copy link
Copy Markdown
Member

No description provided.

@P-E-P
P-E-P force-pushed the extern_prelude_2 branch from 458859f to 047b08a Compare August 4, 2026 10:31
P-E-P added 8 commits August 18, 2026 23:48
We usually test components independently, this means we did not test for
lang item declaration within external crate. This commit introduces a new
test directory to test external crate boundary.

gcc/testsuite/ChangeLog:

	* rust/minicore/extern_lang_items.rs: New test.
	* rust/minicore/extern_lang_items_core/lib.rs: New test.
	* rust/minicore/minicore.exp: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Macros are already emitted by the AST dump within metadata files, we no
longer require a separate export pass from within the metadata exporter.

gcc/rust/ChangeLog:

	* metadata/rust-export-metadata.cc (PublicInterface::gather_export_data):
	Do not emit macros separately anymore.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Add a few crates from the linux kernel to make sure core crate
interactions does not break in the future.

gcc/testsuite/ChangeLog:

	* rust/minicore/build_error.rs: New test.
	* rust/minicore/build_error_core/lib.rs: New test.
	* rust/minicore/compiler_builtins.rs: New test.
	* rust/minicore/compiler_builtins_core/lib.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Return the injected crate's node id.

gcc/rust/ChangeLog:

	* ast/rust-ast.cc (Crate::inject_extern_crate): Return the injected
	crate's node id.
	* ast/rust-ast.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Kernel and core related tests as well as their core crate needs to be
compiled with a matching rust edition. In order to enforce that we
control the edition from the testsuite instead of relying on a per crate
edition change. Moreover, the kernel and core 1.49 is meant to be
compiled with rust edition 2018, using this edition will make things
easier for us.

gcc/testsuite/ChangeLog:

	* rust/minicore/minicore.exp: Enforce crate edition at test top level.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Node streaming started from the root and did not walk through the
different preludes within the forever stack. This enables a more complete
representation of the forever stack.

gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx: Stream extern and lang prelude nodes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
This data structure is complex, when using the debug dump within a
debugger we often need to know what is the current state and where new
nodes will be pushed within the forever stack.

gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.hxx: Debug the forever stack cursor
	position.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
We did not assign any node id to neither extern and lang prelude nodes
and this was confusing and could lead to unexpected behaviors (duplicate
ids).

gcc/rust/ChangeLog:

	* resolve/rust-forever-stack.h: Assign a node id to extern and lang
	nodes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@P-E-P
P-E-P force-pushed the extern_prelude_2 branch 2 times, most recently from 7142fb2 to b8dd134 Compare August 20, 2026 11:00
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.

1 participant