diff options
-rw-r--r-- | gcc/rust/backend/rust-compile-extern.h | 11 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.cc | 6 | ||||
-rw-r--r-- | gcc/rust/rust-object-export.h | 2 | ||||
-rw-r--r-- | gcc/rust/util/rust-hir-map.cc | 4 |
4 files changed, 21 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index c24437d..ddad350 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -130,6 +130,17 @@ public: tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); std::string ir_symbol_name = function.get_item_name (); std::string asm_name = function.get_item_name (); + if (fntype->get_abi () == ABI::RUST) + { + // then we need to get the canonical path of it and mangle it + const Resolver::CanonicalPath *canonical_path = nullptr; + bool ok = ctx->get_mappings ()->lookup_canonical_path ( + function.get_mappings ().get_nodeid (), &canonical_path); + rust_assert (ok); + + ir_symbol_name = canonical_path->get () + fntype->subst_as_string (); + asm_name = ctx->mangle_item (fntype, *canonical_path); + } const unsigned int flags = Backend::function_is_declaration; tree fndecl diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 244bf64..75bd2e1 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -1027,6 +1027,12 @@ void ResolveExternItem::visit (AST::ExternalFunctionItem &function) { NodeId scope_node_id = function.get_node_id (); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_identifier ()); + auto path = prefix.append (decl); + auto cpath = canonical_prefix.append (decl); + + mappings->insert_canonical_path (function.get_node_id (), cpath); resolve_visibility (function.get_visibility ()); diff --git a/gcc/rust/rust-object-export.h b/gcc/rust/rust-object-export.h index 1704f59..fcede54 100644 --- a/gcc/rust/rust-object-export.h +++ b/gcc/rust/rust-object-export.h @@ -19,6 +19,8 @@ #ifndef RUST_OBJECT_EXPORT_H #define RUST_OBJECT_EXPORT_H +#include "rust-system.h" + extern unsigned int rust_field_alignment (tree t); diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 7d23717..c7bf182 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -263,7 +263,7 @@ Mappings::insert_ast_crate (std::unique_ptr<AST::Crate> &&crate, rust_assert (it == ast_crate_mappings.end ()); // store it - ast_crate_mappings.insert ({crate_num, crate.get ()}); + ast_crate_mappings.insert ({crate_num, crate.release ()}); // return the reference to it it = ast_crate_mappings.find (crate_num); @@ -300,7 +300,7 @@ Mappings::insert_hir_crate (std::unique_ptr<HIR::Crate> &&crate) insert_node_to_hir (crate->get_mappings ().get_nodeid (), crate->get_mappings ().get_hirid ()); - hir_crate_mappings.insert ({crateNum, crate.get ()}); + hir_crate_mappings.insert ({crateNum, crate.release ()}); it = hir_crate_mappings.find (crateNum); rust_assert (it != hir_crate_mappings.end ()); |