File tree 1 file changed +16
-2
lines changed
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
138
138
// convert to the actual function type
139
139
auto compiled_fn_type = TyTyCompile::compile (ctx->get_backend (), fnType);
140
140
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
+
141
156
Bfunction *fndecl
142
157
= 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 ());
145
159
ctx->insert_function_decl (function.get_mappings ().get_hirid (), fndecl);
146
160
147
161
// setup the params
You can’t perform that action at this time.
0 commit comments