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 {...@@ -958,7 +958,6 @@ pub const InitOptions = struct {
958 /// building such dependencies themselves, this flag must be set to avoid958 /// building such dependencies themselves, this flag must be set to avoid
959 /// infinite recursion.959 /// infinite recursion.
960 skip_linker_dependencies: bool = false,960 skip_linker_dependencies: bool = false,
961 parent_compilation_link_libc: bool = false,
962 hash_style: link.HashStyle = .both,961 hash_style: link.HashStyle = .both,
963 entry: ?[]const u8 = null,962 entry: ?[]const u8 = null,
964 force_undefined_symbols: std.StringArrayHashMapUnmanaged(void) = .{},963 force_undefined_symbols: std.StringArrayHashMapUnmanaged(void) = .{},
...@@ -1547,7 +1546,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1547,7 +1546,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1547 hash.addOptionalBytes(options.test_filter);1546 hash.addOptionalBytes(options.test_filter);
1548 hash.addOptionalBytes(options.test_name_prefix);1547 hash.addOptionalBytes(options.test_name_prefix);
1549 hash.add(options.skip_linker_dependencies);1548 hash.add(options.skip_linker_dependencies);
1550 hash.add(options.parent_compilation_link_libc);
1551 hash.add(formatted_panics);1549 hash.add(formatted_panics);
1552 hash.add(options.emit_h != null);1550 hash.add(options.emit_h != null);
1553 hash.add(error_limit);1551 hash.add(error_limit);
...@@ -1945,7 +1943,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1945,7 +1943,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1945 .error_return_tracing = error_return_tracing,1943 .error_return_tracing = error_return_tracing,
1946 .llvm_cpu_features = llvm_cpu_features,1944 .llvm_cpu_features = llvm_cpu_features,
1947 .skip_linker_dependencies = options.skip_linker_dependencies,1945 .skip_linker_dependencies = options.skip_linker_dependencies,
1948 .parent_compilation_link_libc = options.parent_compilation_link_libc,
1949 .each_lib_rpath = options.each_lib_rpath orelse options.is_native_os,1946 .each_lib_rpath = options.each_lib_rpath orelse options.is_native_os,
1950 .build_id = build_id,1947 .build_id = build_id,
1951 .cache_mode = cache_mode,1948 .cache_mode = cache_mode,
...@@ -2747,7 +2744,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes...@@ -2747,7 +2744,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
2747 man.hash.addOptionalBytes(comp.test_filter);2744 man.hash.addOptionalBytes(comp.test_filter);
2748 man.hash.addOptionalBytes(comp.test_name_prefix);2745 man.hash.addOptionalBytes(comp.test_name_prefix);
2749 man.hash.add(comp.bin_file.options.skip_linker_dependencies);2746 man.hash.add(comp.bin_file.options.skip_linker_dependencies);
2750 man.hash.add(comp.bin_file.options.parent_compilation_link_libc);
2751 man.hash.add(comp.formatted_panics);2747 man.hash.add(comp.formatted_panics);
2752 man.hash.add(mod.emit_h != null);2748 man.hash.add(mod.emit_h != null);
2753 man.hash.add(mod.error_limit);2749 man.hash.add(mod.error_limit);
...@@ -6654,14 +6650,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca...@@ -6654,14 +6650,6 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
6654 }6650 }
6655 try buffer.appendSlice("};\n");6651 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
6665 try buffer.writer().print(6653 try buffer.writer().print(
6666 \\pub const target = std.Target{{6654 \\pub const target = std.Target{{
6667 \\ .cpu = cpu,6655 \\ .cpu = cpu,
...@@ -6685,7 +6673,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca...@@ -6685,7 +6673,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
6685 , .{6673 , .{
6686 std.zig.fmtId(@tagName(target.ofmt)),6674 std.zig.fmtId(@tagName(target.ofmt)),
6687 std.zig.fmtId(@tagName(comp.bin_file.options.optimize_mode)),6675 std.zig.fmtId(@tagName(comp.bin_file.options.optimize_mode)),
6688 link_libc,6676 comp.bin_file.options.link_libc,
6689 comp.bin_file.options.link_libcpp,6677 comp.bin_file.options.link_libcpp,
6690 comp.bin_file.options.error_return_tracing,6678 comp.bin_file.options.error_return_tracing,
6691 comp.bin_file.options.valgrind,6679 comp.bin_file.options.valgrind,
...@@ -6833,7 +6821,7 @@ fn buildOutputFromZig(...@@ -6833,7 +6821,7 @@ fn buildOutputFromZig(
6833 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,6821 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
6834 .clang_passthrough_mode = comp.clang_passthrough_mode,6822 .clang_passthrough_mode = comp.clang_passthrough_mode,
6835 .skip_linker_dependencies = true,6823 .skip_linker_dependencies = true,
6836 .parent_compilation_link_libc = comp.bin_file.options.link_libc,6824 .link_libc = comp.bin_file.options.link_libc,
6837 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,6825 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,
6838 });6826 });
6839 defer sub_compilation.destroy();6827 defer sub_compilation.destroy();
...@@ -6914,7 +6902,7 @@ pub fn build_crt_file(...@@ -6914,7 +6902,7 @@ pub fn build_crt_file(
6914 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,6902 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
6915 .clang_passthrough_mode = comp.clang_passthrough_mode,6903 .clang_passthrough_mode = comp.clang_passthrough_mode,
6916 .skip_linker_dependencies = true,6904 .skip_linker_dependencies = true,
6917 .parent_compilation_link_libc = comp.bin_file.options.link_libc,6905 .link_libc = comp.bin_file.options.link_libc,
6918 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,6906 .want_structured_cfg = comp.bin_file.options.want_structured_cfg,
6919 });6907 });
6920 defer sub_compilation.destroy();6908 defer sub_compilation.destroy();
src/Sema.zig+1-3
...@@ -9076,7 +9076,7 @@ fn handleExternLibName(...@@ -9076,7 +9076,7 @@ fn handleExternLibName(
9076 const target = mod.getTarget();9076 const target = mod.getTarget();
9077 log.debug("extern fn symbol expected in lib '{s}'", .{lib_name});9077 log.debug("extern fn symbol expected in lib '{s}'", .{lib_name});
9078 if (target_util.is_libc_lib_name(target, lib_name)) {9078 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) {
9080 return sema.fail(9080 return sema.fail(
9081 block,9081 block,
9082 src_loc,9082 src_loc,
...@@ -9084,7 +9084,6 @@ fn handleExternLibName(...@@ -9084,7 +9084,6 @@ fn handleExternLibName(
9084 .{},9084 .{},
9085 );9085 );
9086 }9086 }
9087 comp.bin_file.options.link_libc = true;
9088 break :blk;9087 break :blk;
9089 }9088 }
9090 if (target_util.is_libcpp_lib_name(target, lib_name)) {9089 if (target_util.is_libcpp_lib_name(target, lib_name)) {
...@@ -9096,7 +9095,6 @@ fn handleExternLibName(...@@ -9096,7 +9095,6 @@ fn handleExternLibName(
9096 .{},9095 .{},
9097 );9096 );
9098 }9097 }
9099 comp.bin_file.options.link_libcpp = true;
9100 break :blk;9098 break :blk;
9101 }9099 }
9102 if (mem.eql(u8, lib_name, "unwind")) {9100 if (mem.eql(u8, lib_name, "unwind")) {
src/link.zig-1
...@@ -184,7 +184,6 @@ pub const Options = struct {...@@ -184,7 +184,6 @@ pub const Options = struct {
184 dll_export_fns: bool,184 dll_export_fns: bool,
185 error_return_tracing: bool,185 error_return_tracing: bool,
186 skip_linker_dependencies: bool,186 skip_linker_dependencies: bool,
187 parent_compilation_link_libc: bool,
188 each_lib_rpath: bool,187 each_lib_rpath: bool,
189 build_id: BuildId,188 build_id: BuildId,
190 disable_lld_caching: bool,189 disable_lld_caching: bool,