use -nostdinc and sometimes -nolibc when compiling C code

master
Andrew Kelley 2019-02-26 14:50:20 -05:00
parent 0eed72d687
commit 1ec1097bd3
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 14 additions and 1 deletions

View File

@ -8151,8 +8151,15 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
} }
args.append("-nobuiltininc"); args.append("-nobuiltininc");
args.append("-nostdinc");
args.append("-nostdinc++"); args.append("-nostdinc++");
if (g->libc_link_lib == nullptr) {
args.append("-nolibc");
}
args.append("-fno-spell-checking");
args.append("-isystem"); args.append("-isystem");
args.append(buf_ptr(g->zig_c_headers_dir)); args.append(buf_ptr(g->zig_c_headers_dir));

View File

@ -4805,7 +4805,11 @@ Error parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const
} }
clang_argv.append("-nobuiltininc"); clang_argv.append("-nobuiltininc");
clang_argv.append("-nostdinc");
clang_argv.append("-nostdinc++"); clang_argv.append("-nostdinc++");
if (codegen->libc_link_lib == nullptr) {
clang_argv.append("-nolibc");
}
clang_argv.append("-isystem"); clang_argv.append("-isystem");
clang_argv.append(buf_ptr(codegen->zig_c_headers_dir)); clang_argv.append(buf_ptr(codegen->zig_c_headers_dir));
@ -4832,7 +4836,9 @@ Error parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const
clang_argv.append("-Xclang"); clang_argv.append("-Xclang");
clang_argv.append("-detailed-preprocessing-record"); clang_argv.append("-detailed-preprocessing-record");
if (!c->codegen->zig_target->is_native) { if (c->codegen->zig_target->is_native) {
clang_argv.append("-march=native");
} else {
clang_argv.append("-target"); clang_argv.append("-target");
clang_argv.append(buf_ptr(&c->codegen->triple_str)); clang_argv.append(buf_ptr(&c->codegen->triple_str));
} }