improved handling of native system directories

* `-isystem` instead of `-I` for system include directories
   fixes a problem with native system directories interfering with zig's
   bundled libc.
 * separate Stage2Target.is_native into Stage2Target.is_native_os and
   Stage2Target.is_native_cpu.
This commit is contained in:
Andrew Kelley
2020-03-25 20:32:40 -04:00
parent dd66fbb96a
commit fae6cf0961
8 changed files with 45 additions and 21 deletions

View File

@@ -1325,7 +1325,15 @@ static int main0(int argc, char **argv) {
return print_error_usage(arg0);
}
if (target.is_native && link_libs.length != 0) {
bool any_non_c_link_libs = false;
for (size_t i = 0; i < link_libs.length; i += 1) {
if (!target_is_libc_lib_name(&target, link_libs.at(i))) {
any_non_c_link_libs = true;
break;
}
}
if (target.is_native_os && any_non_c_link_libs) {
Error err;
Stage2NativePaths paths;
if ((err = stage2_detect_native_paths(&paths))) {
@@ -1338,7 +1346,7 @@ static int main0(int argc, char **argv) {
}
for (size_t i = 0; i < paths.include_dirs_len; i += 1) {
const char *include_dir = paths.include_dirs_ptr[i];
clang_argv.append("-I");
clang_argv.append("-isystem");
clang_argv.append(include_dir);
}
for (size_t i = 0; i < paths.lib_dirs_len; i += 1) {