aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-04-28 23:47:39 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-04-28 23:47:39 -0400
commit998e25a01e8b3ada235aee4a9f785a7454de4b3f (patch)
tree1b79bfe9853f513f921f396724be9c7787dc6463 /src
parenta344cb03bc3c48f3c7fec32dc19c1bcad0910941 (diff)
downloadzig-998e25a01e8b3ada235aee4a9f785a7454de4b3f.tar.gz
zig-998e25a01e8b3ada235aee4a9f785a7454de4b3f.zip
pthread support working
Diffstat (limited to 'src')
-rw-r--r--src/all_types.hpp1
-rw-r--r--src/analyze.cpp8
-rw-r--r--src/codegen.cpp2
3 files changed, 11 insertions, 0 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp
index d1b2ad61d2..f08b870b37 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1486,6 +1486,7 @@ struct CodeGen {
ZigList<LinkLib *> link_libs_list;
LinkLib *libc_link_lib;
+ LinkLib *pthread_link_lib;
// add -framework [name] args to linker
ZigList<Buf *> darwin_frameworks;
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 1ecfe32f4c..8a9d236790 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -6049,10 +6049,15 @@ LinkLib *create_link_lib(Buf *name) {
LinkLib *add_link_lib(CodeGen *g, Buf *name) {
bool is_libc = buf_eql_str(name, "c");
+ bool is_pthread = buf_eql_str(name, "pthread");
if (is_libc && g->libc_link_lib != nullptr)
return g->libc_link_lib;
+ if (is_pthread && g->pthread_link_lib != nullptr) {
+ return g->pthread_link_lib;
+ }
+
for (size_t i = 0; i < g->link_libs_list.length; i += 1) {
LinkLib *existing_lib = g->link_libs_list.at(i);
if (buf_eql_buf(existing_lib->name, name)) {
@@ -6066,6 +6071,9 @@ LinkLib *add_link_lib(CodeGen *g, Buf *name) {
if (is_libc)
g->libc_link_lib = link_lib;
+ if (is_pthread)
+ g->pthread_link_lib = link_lib;
+
return link_lib;
}
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 2d8c385f44..9f064d5f19 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -145,6 +145,7 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
{
g->libc_link_lib = create_link_lib(buf_create_from_str("c"));
g->link_libs_list.append(g->libc_link_lib);
+ g->pthread_link_lib = create_link_lib(buf_create_from_str("pthread"));
}
return g;
@@ -6373,6 +6374,7 @@ static void define_builtin_compile_vars(CodeGen *g) {
buf_appendf(contents, "pub const object_format = ObjectFormat.%s;\n", cur_obj_fmt);
buf_appendf(contents, "pub const mode = %s;\n", build_mode_to_str(g->build_mode));
buf_appendf(contents, "pub const link_libc = %s;\n", bool_to_str(g->libc_link_lib != nullptr));
+ buf_appendf(contents, "pub const link_pthread = %s;\n", bool_to_str(g->pthread_link_lib != nullptr));
buf_appendf(contents, "pub const have_error_return_tracing = %s;\n", bool_to_str(g->have_err_ret_tracing));
buf_appendf(contents, "pub const __zig_test_fn_slice = {}; // overwritten later\n");