Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,24 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {

const sysroot = options.sysroot orelse libc_dirs.sysroot;

const must_pie = target_util.requiresPIE(options.target);
const pie: bool = if (options.want_pie) |explicit| pie: {
if (!explicit and must_pie) {
return error.TargetRequiresPIE;
const pie: bool = pie: {
if (options.output_mode != .Exe) {
if (options.want_pie == true) return error.OutputModeForbidsPie;
break :pie false;
}
break :pie explicit;
} else must_pie or tsan;
if (target_util.requiresPIE(options.target)) {
if (options.want_pie == false) return error.TargetRequiresPie;
break :pie true;
}
if (tsan) {
if (options.want_pie == false) return error.TsanRequiresPie;
break :pie true;
}
if (options.want_pie) |want_pie| {
break :pie want_pie;
}
break :pie false;
};

const must_pic: bool = b: {
if (target_util.requiresPIC(options.target, link_libc))
Expand Down Expand Up @@ -6533,7 +6544,7 @@ fn buildOutputFromZig(
.want_tsan = false,
.want_unwind_tables = comp.bin_file.options.eh_frame_hdr,
.want_pic = comp.bin_file.options.pic,
.want_pie = comp.bin_file.options.pie,
.want_pie = null,
.emit_h = null,
.strip = comp.compilerRtStrip(),
.is_native_os = comp.bin_file.options.is_native_os,
Expand Down Expand Up @@ -6608,7 +6619,7 @@ pub fn build_crt_file(
.want_valgrind = false,
.want_tsan = false,
.want_pic = comp.bin_file.options.pic,
.want_pie = comp.bin_file.options.pie,
.want_pie = null,
.want_lto = switch (output_mode) {
.Lib => comp.bin_file.options.lto,
.Obj, .Exe => false,
Expand Down
4 changes: 2 additions & 2 deletions src/libcxx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.want_valgrind = false,
.want_tsan = comp.bin_file.options.tsan,
.want_pic = comp.bin_file.options.pic,
.want_pie = comp.bin_file.options.pie,
.want_pie = null,
.want_lto = comp.bin_file.options.lto,
.function_sections = comp.bin_file.options.function_sections,
.emit_h = null,
Expand Down Expand Up @@ -411,7 +411,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.want_valgrind = false,
.want_tsan = comp.bin_file.options.tsan,
.want_pic = comp.bin_file.options.pic,
.want_pie = comp.bin_file.options.pie,
.want_pie = null,
.want_lto = comp.bin_file.options.lto,
.function_sections = comp.bin_file.options.function_sections,
.emit_h = null,
Expand Down
2 changes: 1 addition & 1 deletion src/libunwind.zig
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
.want_valgrind = false,
.want_tsan = false,
.want_pic = comp.bin_file.options.pic,
.want_pie = comp.bin_file.options.pie,
.want_pie = null,
// Disable LTO to avoid https://github.com/llvm/llvm-project/issues/56825
.want_lto = false,
.function_sections = comp.bin_file.options.function_sections,
Expand Down