aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-09-21 11:18:49 -0400
committerAndrew Kelley <superjoe30@gmail.com>2016-09-21 11:18:49 -0400
commit3f8f0b9bba5407ed5f7279bfdb7d22afaa126674 (patch)
treef63d6c21e29f2b5cad0c1723a2531f071061c225 /src
parentb97bfc3ecba9655cdd989add13a7582272659268 (diff)
downloadzig-3f8f0b9bba5407ed5f7279bfdb7d22afaa126674.tar.gz
zig-3f8f0b9bba5407ed5f7279bfdb7d22afaa126674.zip
exporting an object creates an h file
Diffstat (limited to 'src')
-rw-r--r--src/all_types.hpp1
-rw-r--r--src/codegen.cpp1
-rw-r--r--src/link.cpp10
3 files changed, 8 insertions, 4 deletions
diff --git a/src/all_types.hpp b/src/all_types.hpp
index 8bf842d359..d778145d37 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1256,6 +1256,7 @@ struct CodeGen {
bool is_big_endian;
bool is_static;
bool strip_debug_symbols;
+ bool want_h_file;
bool have_exported_main;
bool link_libc;
Buf *libc_lib_dir;
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 7b732e4255..6ad0854158 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -63,6 +63,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
g->generic_table.init(16);
g->is_release_build = false;
g->is_test_build = false;
+ g->want_h_file = true;
// the error.Ok value
g->error_decls.append(nullptr);
diff --git a/src/link.cpp b/src/link.cpp
index 9698ac46dc..b36140d551 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -38,6 +38,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {
ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
CodeGen *child_gen = codegen_create(std_dir_path, child_target);
child_gen->link_libc = parent_gen->link_libc;
+ child_gen->want_h_file = false;
codegen_set_is_release(child_gen, parent_gen->is_release_build);
@@ -793,10 +794,8 @@ void codegen_link(CodeGen *g, const char *out_file) {
buf_init_from_buf(&lj.out_file_o, &lj.out_file);
- if (g->out_type != OutTypeObj) {
- const char *o_ext = get_o_file_extension(g);
- buf_append_str(&lj.out_file_o, o_ext);
- }
+ const char *o_ext = get_o_file_extension(g);
+ buf_append_str(&lj.out_file_o, o_ext);
char *err_msg = nullptr;
if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o),
@@ -806,6 +805,9 @@ void codegen_link(CodeGen *g, const char *out_file) {
}
if (g->out_type == OutTypeObj) {
+ if (g->want_h_file) {
+ codegen_generate_h_file(g);
+ }
if (g->verbose) {
fprintf(stderr, "OK\n");
}