diff --git a/lib/zig.h b/lib/zig.h index 14b50aea47fb..ec8f50b13ab1 100644 --- a/lib/zig.h +++ b/lib/zig.h @@ -130,6 +130,12 @@ typedef char bool; #define zig_restrict #endif +#if zig_has_attribute(no_builtin) +#define zig_no_builtin __attribute__((no_builtin)) +#else +#define zig_no_builtin +#endif + #if zig_has_attribute(aligned) #define zig_under_align(alignment) __attribute__((aligned(alignment))) #elif _MSC_VER diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 56466b439597..02ffad54e52a 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1790,8 +1790,17 @@ pub const DeclGen = struct { else => unreachable, } } - if (fn_val.getFunction(zcu)) |func| if (func.analysisUnordered(ip).branch_hint == .cold) - try w.writeAll("zig_cold "); + + if (fn_val.getFunction(zcu)) |func| { + const func_analysis = func.analysisUnordered(ip); + + if (func_analysis.branch_hint == .cold) + try w.writeAll("zig_cold "); + + if (kind == .complete and func_analysis.disable_intrinsics or dg.mod.no_builtin) + try w.writeAll("zig_no_builtin "); + } + if (fn_info.return_type == .noreturn_type) try w.writeAll("zig_noreturn "); var trailing = try renderTypePrefix(dg.pass, &dg.ctype_pool, zcu, w, fn_ctype, .suffix, .{});