aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2021-01-13 21:25:20 +0800
committerSimplyTheOther <simplytheother@gmail.com>2021-01-13 21:25:20 +0800
commitb3a39d99c1d6f45890dbac33a9d17c8dd464654e (patch)
tree8dd6eab91e751b6ead8d1066bff353f5a0a28810 /gcc
parentbc94b7de4614100b63e17a50692a23feab1c139f (diff)
parent05b9f235566d7d361709c5bc44e7c36598515946 (diff)
downloadgcc-b3a39d99c1d6f45890dbac33a9d17c8dd464654e.zip
gcc-b3a39d99c1d6f45890dbac33a9d17c8dd464654e.tar.gz
gcc-b3a39d99c1d6f45890dbac33a9d17c8dd464654e.tar.bz2
Merge branch 'master' of https://github.com/redbrain/gccrs
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-item.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index e042ccb..c5fe9a2 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -138,10 +138,24 @@ public:
// convert to the actual function type
auto compiled_fn_type = TyTyCompile::compile (ctx->get_backend (), fnType);
+ unsigned int flags = 0;
+ bool is_main_fn = function.function_name.compare ("main") == 0;
+
+ // if its the main fn or pub visibility mark its as DECL_PUBLIC
+ // please see https://github.com/Rust-GCC/gccrs/pull/137
+ if (is_main_fn || function.has_visibility ())
+ flags |= Backend::function_is_visible;
+
+ std::string asm_name = function.function_name;
+ if (!is_main_fn)
+ {
+ // FIXME need name mangling
+ asm_name = "__" + function.function_name;
+ }
+
Bfunction *fndecl
= ctx->get_backend ()->function (compiled_fn_type, function.function_name,
- "" /* asm_name */, 0 /* flags */,
- function.get_locus ());
+ asm_name, flags, function.get_locus ());
ctx->insert_function_decl (function.get_mappings ().get_hirid (), fndecl);
// setup the params