diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig index 2afe7f568..889737bda 100644 --- a/src-self-hosted/clang_options_data.zig +++ b/src-self-hosted/clang_options_data.zig @@ -1725,7 +1725,7 @@ flagpsl("MT"), .{ .name = "no-standard-includes", .syntax = .flag, - .zig_equivalent = .other, + .zig_equivalent = .nostdlibinc, .pd1 = false, .pd2 = true, .psl = false, @@ -3781,7 +3781,14 @@ flagpd1("nocudainc"), flagpd1("nodefaultlibs"), flagpd1("nofixprebinding"), flagpd1("nogpulib"), -flagpd1("nolibc"), +.{ + .name = "nolibc", + .syntax = .flag, + .zig_equivalent = .nostdlib, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("nomultidefs"), flagpd1("fnon-call-exceptions"), flagpd1("fno-non-call-exceptions"), @@ -3790,8 +3797,22 @@ flagpd1("noprebind"), flagpd1("noprofilelib"), flagpd1("noseglinkedit"), flagpd1("nostartfiles"), -flagpd1("nostdinc"), -flagpd1("nostdinc++"), +.{ + .name = "nostdinc", + .syntax = .flag, + .zig_equivalent = .nostdlibinc, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "nostdinc++", + .syntax = .flag, + .zig_equivalent = .nostdlib_cpp, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "nostdlib", .syntax = .flag, @@ -3800,7 +3821,14 @@ flagpd1("nostdinc++"), .pd2 = false, .psl = false, }, -flagpd1("nostdlibinc"), +.{ + .name = "nostdlibinc", + .syntax = .flag, + .zig_equivalent = .nostdlibinc, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "nostdlib++", .syntax = .flag, diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index b63b6e8ca..bfc49a876 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -1293,6 +1293,7 @@ pub const ClangArgIterator = extern struct { dep_file, framework_dir, framework, + nostdlibinc, }; const Args = struct { diff --git a/src/main.cpp b/src/main.cpp index 17a1c2bc5..a2d7577a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -447,6 +447,7 @@ static int main0(int argc, char **argv) { bool ensure_libc_on_non_freestanding = false; bool ensure_libcpp_on_non_freestanding = false; bool disable_c_depfile = false; + bool want_native_include_dirs = false; Buf *linker_optimization = nullptr; OptionalBool linker_gc_sections = OptionalBoolNull; OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; @@ -581,6 +582,7 @@ static int main0(int argc, char **argv) { strip = true; ensure_libc_on_non_freestanding = true; ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0); + want_native_include_dirs = true; bool c_arg = false; Stage2ClangArgIterator it; @@ -747,6 +749,9 @@ static int main0(int argc, char **argv) { case Stage2ClangArgFramework: frameworks.append(it.only_arg); break; + case Stage2ClangArgNoStdLibInc: + want_native_include_dirs = false; + break; } } // Parse linker args @@ -1418,7 +1423,7 @@ static int main0(int argc, char **argv) { } } - if (target.is_native_os && any_system_lib_dependencies) { + if (target.is_native_os && (any_system_lib_dependencies || want_native_include_dirs)) { Error err; Stage2NativePaths paths; if ((err = stage2_detect_native_paths(&paths))) { diff --git a/src/stage2.h b/src/stage2.h index 02b33419f..e397291f5 100644 --- a/src/stage2.h +++ b/src/stage2.h @@ -352,6 +352,7 @@ enum Stage2ClangArg { Stage2ClangArgDepFile, Stage2ClangArgFrameworkDir, Stage2ClangArgFramework, + Stage2ClangArgNoStdLibInc, }; // ABI warning diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index fd6edbdf2..f1029cb06 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{ .name = "fno-PIC", .ident = "no_pic", }, + .{ + .name = "nolibc", + .ident = "nostdlib", + }, .{ .name = "nostdlib", .ident = "nostdlib", @@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{ .name = "nostdlib++", .ident = "nostdlib_cpp", }, + .{ + .name = "nostdinc++", + .ident = "nostdlib_cpp", + }, + .{ + .name = "nostdlibinc", + .ident = "nostdlibinc", + }, + .{ + .name = "nostdinc", + .ident = "nostdlibinc", + }, + .{ + .name = "no-standard-includes", + .ident = "nostdlibinc", + }, .{ .name = "shared", .ident = "shared",