aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-25 20:09:18 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-25 20:09:18 -0500
commit152db27146e8b219af118abae8d235831aad2153 (patch)
tree91f94e66e9757620cc21a06afbff78720509fec3 /src/ir.cpp
parent3ca861c7dd048a8bc15b6776a3b56fdc790750f7 (diff)
downloadzig-152db27146e8b219af118abae8d235831aad2153.tar.gz
zig-152db27146e8b219af118abae8d235831aad2153.zip
better error message when forgetting to link against libc
closes #1698
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index d6e40384f8..73ad54a32d 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -15520,6 +15520,14 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
}
static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, AstNode *source_node) {
+ if (buf_eql_str(lib_name, "c") && ira->codegen->libc_link_lib == nullptr &&
+ !ira->codegen->reported_bad_link_libc_error)
+ {
+ ir_add_error_node(ira, source_node,
+ buf_sprintf("dependency on library c must be explicitly specified in the build command"));
+ ira->codegen->reported_bad_link_libc_error = true;
+ }
+
LinkLib *link_lib = add_link_lib(ira->codegen, lib_name);
for (size_t i = 0; i < link_lib->symbols.length; i += 1) {
Buf *existing_symbol_name = link_lib->symbols.at(i);