mirror of
https://github.com/ziglang/zig.git
synced 2026-02-09 19:10:48 +00:00
translate-c: put -x c back in there, it's necessary
This commit is contained in:
parent
535d419590
commit
e1bf74fca3
@ -8155,6 +8155,11 @@ static void detect_libc(CodeGen *g) {
|
||||
|
||||
// does not add the "cc" arg
|
||||
void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_path, bool translate_c) {
|
||||
if (translate_c) {
|
||||
args.append("-x");
|
||||
args.append("c");
|
||||
}
|
||||
|
||||
if (out_dep_path != nullptr) {
|
||||
args.append("-MD");
|
||||
args.append("-MV");
|
||||
@ -8166,13 +8171,6 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
|
||||
args.append("-fno-spell-checking");
|
||||
|
||||
if (translate_c) {
|
||||
// TODO these args shouldn't be special from the non-translate-c args, probably.
|
||||
args.append("-nobuiltininc");
|
||||
args.append("-nostdinc++");
|
||||
if (g->libc_link_lib == nullptr) {
|
||||
args.append("-nolibc");
|
||||
}
|
||||
|
||||
// this gives us access to preprocessing entities, presumably at
|
||||
// the cost of performance
|
||||
args.append("-Xclang");
|
||||
@ -8293,9 +8291,16 @@ void codegen_translate_c(CodeGen *g, Buf *full_path, FILE *out_file, bool use_us
|
||||
ZigList<const char *> clang_argv = {0};
|
||||
add_cc_args(g, clang_argv, nullptr, true);
|
||||
|
||||
clang_argv.append("-c");
|
||||
clang_argv.append(buf_ptr(full_path));
|
||||
|
||||
if (g->verbose_cc) {
|
||||
fprintf(stderr, "clang");
|
||||
for (size_t i = 0; i < clang_argv.length; i += 1) {
|
||||
fprintf(stderr, " %s", clang_argv.at(i));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
clang_argv.append(nullptr); // to make the [start...end] argument work
|
||||
|
||||
const char *resources_path = buf_ptr(g->zig_c_headers_dir);
|
||||
|
||||
@ -19098,9 +19098,16 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
|
||||
|
||||
add_cc_args(ira->codegen, clang_argv, buf_ptr(tmp_dep_file), true);
|
||||
|
||||
clang_argv.append("-c");
|
||||
clang_argv.append(buf_ptr(&tmp_c_file_path));
|
||||
|
||||
if (ira->codegen->verbose_cc) {
|
||||
fprintf(stderr, "clang");
|
||||
for (size_t i = 0; i < clang_argv.length; i += 1) {
|
||||
fprintf(stderr, " %s", clang_argv.at(i));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
clang_argv.append(nullptr); // to make the [start...end] argument work
|
||||
|
||||
AstNode *root_node;
|
||||
|
||||
@ -5060,5 +5060,7 @@ Error parse_h_file(CodeGen *codegen, AstNode **out_root_node,
|
||||
|
||||
*out_root_node = c->root;
|
||||
|
||||
ZigClangASTUnit_delete(ast_unit);
|
||||
|
||||
return ErrorNone;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user