authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-13 00:50:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-13 11:28:42-08:00
log225fe6ddbfae016395762850e0cd5c51f9e7751c
tree6af50dcc12e3eb85d913e63f59eec286bc29a4cf
parent4574dea13a4b1d38c97fe73c257d895f605b78ca

Compilation: remove parent_compilation_link_libc

This option is not needed since the link_libc flag can be set directly when creating compiler_rt. This fixes a problem where an immutable flag was being mutated in Sema.

3 files changed, 4 insertions(+), 19 deletions(-)

src/Compilation.zig+3-15
......@@ -958,7 +958,6 @@ pub const InitOptions = struct {
958958 /// building such dependencies themselves, this flag must be set to avoid
959959 /// infinite recursion.
960960 skip_linker_dependencies: bool = false,
961 parent_compilation_link_libc: bool = false,
962961 hash_style: link.HashStyle = .both,
963962 entry: ?[]const u8 = null,
964963 force_undefined_symbols: std.StringArrayHashMapUnmanaged(void) = .{},
......@@ -1547,7 +1546,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
15471546 hash.addOptionalBytes(options.test_filter);
15481547 hash.addOptionalBytes(options.test_name_prefix);
15491548 hash.add(options.skip_linker_dependencies);
1550 hash.add(options.parent_compilation_link_libc);
15511549 hash.add(formatted_panics);
15521550 hash.add(options.emit_h != null);
15531551 hash.add(error_limit);
......@@ -1945,7 +1943,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
19451943 .error_return_tracing = error_return_tracing,
19461944 .llvm_cpu_features = llvm_cpu_features,
19471945 .skip_linker_dependencies = options.skip_linker_dependencies,
1948 .parent_compilation_link_libc = options.parent_compilation_link_libc,
19491946 .each_lib_rpath = options.each_lib_rpath orelse options.is_native_os,
19501947 .build_id = build_id,
19511948 .cache_mode = cache_mode,
......@@ -2747,7 +2744,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
27472744 man.hash.addOptionalBytes(comp.test_filter);
27482745 man.hash.addOptionalBytes(comp.test_name_prefix);
27492746 man.hash.add(comp.bin_file.options.skip_linker_dependencies);
2750 man.hash.add(comp.bin_file.options.parent_compilation_link_libc);
27512747 man.hash.add(comp.formatted_panics);
27522748 man.hash.add(mod.emit_h != null);
27532749 man.hash.add(mod.error_limit);
......@@ -6654,14 +6650,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
66546650 }
66556651 try buffer.appendSlice("};\n");
66566652
6657 // This is so that compiler_rt and libc.zig libraries know whether they
6658 // will eventually be linked with libc. They make different decisions
6659 // about what to export depending on whether another libc will be linked
6660 // in. For example, compiler_rt will not export the __chkstk symbol if it
6661 // knows libc will provide it, and likewise c.zig will not export memcpy.
6662 const link_libc = comp.bin_file.options.link_libc or
6663 (comp.bin_file.options.skip_linker_dependencies and comp.bin_file.options.parent_compilation_link_libc);
6664
66656653 try buffer.writer().print(
66666654 \\pub const target = std.Target{{
66676655 \\ .cpu = cpu,
......@@ -6685,7 +6673,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
66856673 , .{
66866674 std.zig.fmtId(@tagName(target.ofmt)),
66876675 std.zig.fmtId(@tagName(comp.bin_file.options.optimize_mode)),
6688 link_libc,
6676 comp.bin_file.options.link_libc,
66896677 comp.bin_file.options.link_libcpp,
66906678 comp.bin_file.options.error_return_tracing,
66916679 comp.bin_file.options.valgrind,
......@@ -6833,7 +6821,7 @@ fn buildOutputFromZig(
68336821 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
68346822 .clang_passthrough_mode = comp.clang_passthrough_mode,
68356823 .skip_linker_dependencies = true,
6836 .parent_compilation_link_libc = comp.bin_file.options.link_libc,
6824 .link_libc = comp.bin_file.options.link_libc,
68376825 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,
68386826 });
68396827 defer sub_compilation.destroy();
......@@ -6914,7 +6902,7 @@ pub fn build_crt_file(
69146902 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
69156903 .clang_passthrough_mode = comp.clang_passthrough_mode,
69166904 .skip_linker_dependencies = true,
6917 .parent_compilation_link_libc = comp.bin_file.options.link_libc,
6905 .link_libc = comp.bin_file.options.link_libc,
69186906 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,
69196907 });
69206908 defer sub_compilation.destroy();
src/Sema.zig+1-3
......@@ -9076,7 +9076,7 @@ fn handleExternLibName(
90769076 const target = mod.getTarget();
90779077 log.debug("extern fn symbol expected in lib '{s}'", .{lib_name});
90789078 if (target_util.is_libc_lib_name(target, lib_name)) {
9079 if (!comp.bin_file.options.link_libc and !comp.bin_file.options.parent_compilation_link_libc) {
9079 if (!comp.bin_file.options.link_libc) {
90809080 return sema.fail(
90819081 block,
90829082 src_loc,
......@@ -9084,7 +9084,6 @@ fn handleExternLibName(
90849084 .{},
90859085 );
90869086 }
9087 comp.bin_file.options.link_libc = true;
90889087 break :blk;
90899088 }
90909089 if (target_util.is_libcpp_lib_name(target, lib_name)) {
......@@ -9096,7 +9095,6 @@ fn handleExternLibName(
90969095 .{},
90979096 );
90989097 }
9099 comp.bin_file.options.link_libcpp = true;
91009098 break :blk;
91019099 }
91029100 if (mem.eql(u8, lib_name, "unwind")) {
src/link.zig-1
......@@ -184,7 +184,6 @@ pub const Options = struct {
184184 dll_export_fns: bool,
185185 error_return_tracing: bool,
186186 skip_linker_dependencies: bool,
187 parent_compilation_link_libc: bool,
188187 each_lib_rpath: bool,
189188 build_id: BuildId,
190189 disable_lld_caching: bool,