authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-11-05 00:27:08-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-11-05 20:34:13-05:00
log26dabbf301ce4cd950cd66373dc17f0747c1e813
tree712d1971bf81fc0dc1bb5aaf3003ef555d658cdd
parent192e9a315d92133b27d757f18bd4fd619976b755

cbe: handle underscore prexfix on macos, don't mangle extern function names


2 files changed, 5 insertions(+), 1 deletions(-)

lib/zig.h+4
...@@ -203,7 +203,11 @@ typedef char bool;...@@ -203,7 +203,11 @@ typedef char bool;
203 __pragma(comment(linker, "/alternatename:_" #symbol "=_" #name ))203 __pragma(comment(linker, "/alternatename:_" #symbol "=_" #name ))
204#endif /*_M_X64 */204#endif /*_M_X64 */
205#else205#else
206#if __APPLE__
207#define zig_import(sig, symbol, name) zig_extern sig __asm("_" #name);
208#else /* __APPLE__ */
206#define zig_import(sig, symbol, name) zig_extern sig __asm(#name);209#define zig_import(sig, symbol, name) zig_extern sig __asm(#name);
210#endif /* __APPLE__ */
207#endif211#endif
208212
209#define zig_expand_import(sig, symbol, name) zig_import(sig, symbol, name)213#define zig_expand_import(sig, symbol, name) zig_import(sig, symbol, name)
src/codegen/c.zig+1-1
...@@ -1978,7 +1978,7 @@ pub const DeclGen = struct {...@@ -1978,7 +1978,7 @@ pub const DeclGen = struct {
1978 if (mod.decl_exports.get(decl_index)) |exports| {1978 if (mod.decl_exports.get(decl_index)) |exports| {
1979 try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(exports.items[export_index].opts.name))});1979 try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(exports.items[export_index].opts.name))});
1980 } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| {1980 } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| {
1981 try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(extern_decl_index).name))});1981 try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)});
1982 } else {1982 } else {
1983 // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case),1983 // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case),
1984 // expand to 3x the length of its input, but let's cut it off at a much shorter limit.1984 // expand to 3x the length of its input, but let's cut it off at a much shorter limit.