aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-03-22 11:55:41 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-03-22 11:55:41 -0400
commit01b2bf4a44c586f2fa51e8824be608b92d82fed4 (patch)
tree487e4484a35984c7177f4481c25a18d31c9ebfe9 /src/codegen.cpp
parent87bc97daefc8b5d8b665ea2fb2b6c232b80344bc (diff)
downloadzig-01b2bf4a44c586f2fa51e8824be608b92d82fed4.tar.gz
zig-01b2bf4a44c586f2fa51e8824be608b92d82fed4.zip
on Darwin/MacOS/iOS, add c to link libs implicitly
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index f67cdf2ab2..3babaac0e4 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -115,6 +115,15 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
}
+ // On Darwin/MacOS/iOS, we always link libSystem which contains libc.
+ if (g->zig_target.os == ZigLLVM_Darwin ||
+ g->zig_target.os == ZigLLVM_MacOSX ||
+ g->zig_target.os == ZigLLVM_IOS)
+ {
+ g->link_libc = true;
+ g->link_libs.append(buf_create_from_str("c"));
+ }
+
return g;
}
@@ -191,6 +200,8 @@ void codegen_add_rpath(CodeGen *g, const char *name) {
void codegen_add_link_lib(CodeGen *g, const char *lib) {
if (strcmp(lib, "c") == 0) {
+ if (g->link_libc)
+ return;
g->link_libc = true;
}
g->link_libs.append(buf_create_from_str(lib));