aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-11-12 16:40:00 +0100
committerGitHub <noreply@github.com>2024-11-12 16:40:00 +0100
commit1db8cade5ab5c05fa3c6a884e50947633ebcf065 (patch)
tree5a74083c154ad53748440fa85c75a16b009043d9 /src/codegen/llvm.zig
parentbbbc95afd0d035224047443d56ed2252d8f47cb9 (diff)
parentc9052ef93105107bd20bd52ee51197d55e7ace34 (diff)
downloadzig-1db8cade5ab5c05fa3c6a884e50947633ebcf065.tar.gz
zig-1db8cade5ab5c05fa3c6a884e50947633ebcf065.zip
Merge pull request #21920 from alexrp/nobuiltin
compiler: Improve handling of `-fno-builtin` and compiler-rt options
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 3a8fde75da..fb20d4d622 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -3222,8 +3222,6 @@ pub const Object = struct {
owner_mod: *Package.Module,
omit_frame_pointer: bool,
) Allocator.Error!void {
- const comp = o.pt.zcu.comp;
-
if (!owner_mod.red_zone) {
try attributes.addFnAttr(.noredzone, &o.builder);
}
@@ -3242,8 +3240,7 @@ pub const Object = struct {
if (owner_mod.unwind_tables) {
try attributes.addFnAttr(.{ .uwtable = Builder.Attribute.UwTable.default }, &o.builder);
}
- const target = owner_mod.resolved_target.result;
- if (comp.skip_linker_dependencies or comp.no_builtin or target.cpu.arch.isBpf()) {
+ if (owner_mod.no_builtin) {
// The intent here is for compiler-rt and libc functions to not generate
// infinite recursion. For example, if we are compiling the memcpy function,
// and llvm detects that the body is equivalent to memcpy, it may replace the
@@ -3258,6 +3255,7 @@ pub const Object = struct {
try attributes.addFnAttr(.minsize, &o.builder);
try attributes.addFnAttr(.optsize, &o.builder);
}
+ const target = owner_mod.resolved_target.result;
if (target.cpu.model.llvm_name) |s| {
try attributes.addFnAttr(.{ .string = .{
.kind = try o.builder.string("target-cpu"),
@@ -5578,6 +5576,10 @@ pub const FuncGen = struct {
var attributes: Builder.FunctionAttributes.Wip = .{};
defer attributes.deinit(&o.builder);
+ if (self.ng.ownerModule().no_builtin) {
+ try attributes.addFnAttr(.nobuiltin, &o.builder);
+ }
+
switch (modifier) {
.auto, .never_tail, .always_tail => {},
.never_inline => try attributes.addFnAttr(.@"noinline", &o.builder),
@@ -12728,6 +12730,8 @@ fn backendSupportsF16(target: std.Target) bool {
.mips64,
.mips64el,
.s390x,
+ .sparc,
+ .sparc64,
=> false,
.arm,
.armeb,