| author | |
| committer | |
| log | 152db27146e8b219af118abae8d235831aad2153 |
| tree | 91f94e66e9757620cc21a06afbff78720509fec3 |
| parent | 3ca861c7dd048a8bc15b6776a3b56fdc790750f7 |
| signature |
closes #16983 files changed, 19 insertions(+), 0 deletions(-)
src/all_types.hpp+1| ... | ... | @@ -1808,6 +1808,7 @@ struct CodeGen { |
| 1808 | 1808 | bool enable_cache; |
| 1809 | 1809 | bool enable_time_report; |
| 1810 | 1810 | bool system_linker_hack; |
| 1811 | bool reported_bad_link_libc_error; | |
| 1811 | 1812 | |
| 1812 | 1813 | //////////////////////////// Participates in Input Parameter Cache Hash |
| 1813 | 1814 | /////// Note: there is a separate cache hash for builtin.zig, when adding fields, |
src/ir.cpp+8| ... | ... | @@ -15520,6 +15520,14 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 15520 | 15520 | } |
| 15521 | 15521 | |
| 15522 | 15522 | static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, AstNode *source_node) { |
| 15523 | if (buf_eql_str(lib_name, "c") && ira->codegen->libc_link_lib == nullptr && | |
| 15524 | !ira->codegen->reported_bad_link_libc_error) | |
| 15525 | { | |
| 15526 | ir_add_error_node(ira, source_node, | |
| 15527 | buf_sprintf("dependency on library c must be explicitly specified in the build command")); | |
| 15528 | ira->codegen->reported_bad_link_libc_error = true; | |
| 15529 | } | |
| 15530 | ||
| 15523 | 15531 | LinkLib *link_lib = add_link_lib(ira->codegen, lib_name); |
| 15524 | 15532 | for (size_t i = 0; i < link_lib->symbols.length; i += 1) { |
| 15525 | 15533 | Buf *existing_symbol_name = link_lib->symbols.at(i); |
test/compile_errors.zig+10| ... | ... | @@ -1,6 +1,16 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.addTest( | |
| 5 | "implicit dependency on libc", | |
| 6 | \\extern "c" fn exit(u8) void; | |
| 7 | \\export fn entry() void { | |
| 8 | \\ exit(0); | |
| 9 | \\} | |
| 10 | , | |
| 11 | ".tmp_source.zig:3:5: error: dependency on library c must be explicitly specified in the build command", | |
| 12 | ); | |
| 13 | ||
| 4 | 14 | cases.addTest( |
| 5 | 15 | "libc headers note", |
| 6 | 16 | \\const c = @cImport(@cInclude("stdio.h")); |