Skip to content

Conversation

@powerboat9
Copy link
Collaborator

Unless I'm mistaken, we don't need to put no_mangle in DECL_ATTRIBUTES (fndecl), right? Since we do all of the mangling, and gcc doesn't seem to have a no_mangle attribute?

@powerboat9
Copy link
Collaborator Author

Fixes #3867

Copy link
Member

@philberty philberty 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 is partly there but there is special handling for the function declarations in: ust-compile-extern.h: void visit (HIR::ExternalFunctionItem &function) override

@philberty
Copy link
Member

Also you should put the Fixes into the commit message too since this is almost it finished

@powerboat9
Copy link
Collaborator Author

Now depends on #4044

@powerboat9
Copy link
Collaborator Author

powerboat9 commented Sep 14, 2025

It looks like link_name isn't supposed to affect non-extern items, and extern items aren't mangled regardless of ABI

Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

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

Small nit otherwise LGTM

gcc/rust/ChangeLog:

	* backend/rust-compile-extern.h: Add includes.
	(CompileExternItem::visit): Use get_link_name.
	(CompileExternItem::get_link_name): New static member function.
	* util/rust-attribute-values.h (Attributes::LINK_NAME): New
	static constexpr member variable.
	* util/rust-attributes.cc (__definitions): New entry for
	LINK_NAME.
	* util/rust-ggc.cc: Include "rust-ast.h".
	(Ident::Ident): Add overload for Rust::Identifier.
	* util/rust-ggc.h (class Identifier): Forward declare.
	(Ident::Ident): Add overload for Rust::Identifier.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/link-name.rs: New test.

Signed-off-by: Owen Avery <[email protected]>
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

LGTM

@philberty philberty added this pull request to the merge queue Sep 30, 2025
Merged via the queue into Rust-GCC:master with commit 18ad440 Sep 30, 2025
13 checks passed
@powerboat9 powerboat9 deleted the extra-mangle branch September 30, 2025 22:14
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.

3 participants