File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -138,10 +138,24 @@ class CompileItem : public HIRCompileBase
138138 // convert to the actual function type
139139 auto compiled_fn_type = TyTyCompile::compile (ctx->get_backend (), fnType);
140140
141+ unsigned int flags = 0 ;
142+ bool is_main_fn = function.function_name .compare (" main" ) == 0 ;
143+
144+ // if its the main fn or pub visibility mark its as DECL_PUBLIC
145+ // please see https://github.com/Rust-GCC/gccrs/pull/137
146+ if (is_main_fn || function.has_visibility ())
147+ flags |= Backend::function_is_visible;
148+
149+ std::string asm_name = function.function_name ;
150+ if (!is_main_fn)
151+ {
152+ // FIXME need name mangling
153+ asm_name = " __" + function.function_name ;
154+ }
155+
141156 Bfunction *fndecl
142157 = ctx->get_backend ()->function (compiled_fn_type, function.function_name ,
143- " " /* asm_name */ , 0 /* flags */ ,
144- function.get_locus ());
158+ asm_name, flags, function.get_locus ());
145159 ctx->insert_function_decl (function.get_mappings ().get_hirid (), fndecl);
146160
147161 // setup the params
You can’t perform that action at this time.
0 commit comments