authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-21 20:19:48-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-25 00:06:58-04:00
loge1bf74fca3de7943b8f7c15be4da3dbc8e3da17e
tree177a4093eae23bd6e1f5bb3c990dee4cccbdf033
parent535d4195907de8a7e494b0480c394634d4c6034a
signature Commit is signed but in an unrecognized format.

translate-c: put -x c back in there, it's necessary


3 files changed, 23 insertions(+), 9 deletions(-)

src/codegen.cpp+13-8
...@@ -8155,6 +8155,11 @@ static void detect_libc(CodeGen *g) {...@@ -8155,6 +8155,11 @@ static void detect_libc(CodeGen *g) {
81558155
8156// does not add the "cc" arg8156// does not add the "cc" arg
8157void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_path, bool translate_c) {8157void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_path, bool translate_c) {
8158 if (translate_c) {
8159 args.append("-x");
8160 args.append("c");
8161 }
8162
8158 if (out_dep_path != nullptr) {8163 if (out_dep_path != nullptr) {
8159 args.append("-MD");8164 args.append("-MD");
8160 args.append("-MV");8165 args.append("-MV");
...@@ -8166,13 +8171,6 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa...@@ -8166,13 +8171,6 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
8166 args.append("-fno-spell-checking");8171 args.append("-fno-spell-checking");
81678172
8168 if (translate_c) {8173 if (translate_c) {
8169 // TODO these args shouldn't be special from the non-translate-c args, probably.
8170 args.append("-nobuiltininc");
8171 args.append("-nostdinc++");
8172 if (g->libc_link_lib == nullptr) {
8173 args.append("-nolibc");
8174 }
8175
8176 // this gives us access to preprocessing entities, presumably at8174 // this gives us access to preprocessing entities, presumably at
8177 // the cost of performance8175 // the cost of performance
8178 args.append("-Xclang");8176 args.append("-Xclang");
...@@ -8293,9 +8291,16 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us...@@ -8293,9 +8291,16 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us
8293 ZigList<const char *> clang_argv = {0};8291 ZigList<const char *> clang_argv = {0};
8294 add_cc_args(g, clang_argv, nullptr, true);8292 add_cc_args(g, clang_argv, nullptr, true);
82958293
8296 clang_argv.append("-c");
8297 clang_argv.append(buf_ptr(full_path));8294 clang_argv.append(buf_ptr(full_path));
82988295
8296 if (g->verbose_cc) {
8297 fprintf(stderr, "clang");
8298 for (size_t i = 0; i < clang_argv.length; i += 1) {
8299 fprintf(stderr, " %s", clang_argv.at(i));
8300 }
8301 fprintf(stderr, "\n");
8302 }
8303
8299 clang_argv.append(nullptr); // to make the [start...end] argument work8304 clang_argv.append(nullptr); // to make the [start...end] argument work
83008305
8301 const char *resources_path = buf_ptr(g->zig_c_headers_dir);8306 const char *resources_path = buf_ptr(g->zig_c_headers_dir);
src/ir.cpp+8-1
...@@ -19098,9 +19098,16 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct...@@ -19098,9 +19098,16 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
1909819098
19099 add_cc_args(ira->codegen, clang_argv, buf_ptr(tmp_dep_file), true);19099 add_cc_args(ira->codegen, clang_argv, buf_ptr(tmp_dep_file), true);
1910019100
19101 clang_argv.append("-c");
19102 clang_argv.append(buf_ptr(&tmp_c_file_path));19101 clang_argv.append(buf_ptr(&tmp_c_file_path));
1910319102
19103 if (ira->codegen->verbose_cc) {
19104 fprintf(stderr, "clang");
19105 for (size_t i = 0; i < clang_argv.length; i += 1) {
19106 fprintf(stderr, " %s", clang_argv.at(i));
19107 }
19108 fprintf(stderr, "\n");
19109 }
19110
19104 clang_argv.append(nullptr); // to make the [start...end] argument work19111 clang_argv.append(nullptr); // to make the [start...end] argument work
1910519112
19106 AstNode *root_node;19113 AstNode *root_node;
src/translate_c.cpp+2
...@@ -5060,5 +5060,7 @@ Error parse_h_file(CodeGen *codegen, AstNode **out_root_node,...@@ -5060,5 +5060,7 @@ Error parse_h_file(CodeGen *codegen, AstNode **out_root_node,
50605060
5061 *out_root_node = c->root;5061 *out_root_node = c->root;
50625062
5063 ZigClangASTUnit_delete(ast_unit);
5064
5063 return ErrorNone;5065 return ErrorNone;
5064}5066}