diff --git a/src/link/Lld.zig b/src/link/Lld.zig index c7d428e209e169a8a580b2dfea6648019c6417eb..598b49b05a12e8d2555b3bfbbb67f576352b70c0 100644 --- a/src/link/Lld.zig +++ b/src/link/Lld.zig @@ -1029,8 +1029,10 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { try argv.append("-shared"); } - if (comp.config.pie and output_mode == .Exe) { - try argv.append("-pie"); + if (output_mode == .Exe) { + // Always be explicit: some lld builds (e.g. OpenBSD's) default + // to PIE, which breaks non-PIE executables for other targets. + try argv.append(if (comp.config.pie) "-pie" else "-no-pie"); } if (is_exe_or_dyn_lib and target.os.tag == .netbsd) {