authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-04 14:58:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-04 14:58:24-04:00
log52db13738b3fca0ad5d83476e584be1d61a1428f
treeec09a5850e5917f2846ef457c4539e036832d348
parentd02838b71a0b0fd3495c1b714ab3c6da05441980
signaturelock-open Commit is signed but in an unrecognized format.

zig cc looks for native include directories unless -nostdinc

closes #4938

5 files changed, 61 insertions(+), 6 deletions(-)

src-self-hosted/clang_options_data.zig+33-5
......@@ -1725,7 +1725,7 @@ flagpsl("MT"),
17251725.{
17261726 .name = "no-standard-includes",
17271727 .syntax = .flag,
1728 .zig_equivalent = .other,
1728 .zig_equivalent = .nostdlibinc,
17291729 .pd1 = false,
17301730 .pd2 = true,
17311731 .psl = false,
......@@ -3781,7 +3781,14 @@ flagpd1("nocudainc"),
37813781flagpd1("nodefaultlibs"),
37823782flagpd1("nofixprebinding"),
37833783flagpd1("nogpulib"),
3784flagpd1("nolibc"),
3784.{
3785 .name = "nolibc",
3786 .syntax = .flag,
3787 .zig_equivalent = .nostdlib,
3788 .pd1 = true,
3789 .pd2 = false,
3790 .psl = false,
3791},
37853792flagpd1("nomultidefs"),
37863793flagpd1("fnon-call-exceptions"),
37873794flagpd1("fno-non-call-exceptions"),
......@@ -3790,8 +3797,22 @@ flagpd1("noprebind"),
37903797flagpd1("noprofilelib"),
37913798flagpd1("noseglinkedit"),
37923799flagpd1("nostartfiles"),
3793flagpd1("nostdinc"),
3794flagpd1("nostdinc++"),
3800.{
3801 .name = "nostdinc",
3802 .syntax = .flag,
3803 .zig_equivalent = .nostdlibinc,
3804 .pd1 = true,
3805 .pd2 = false,
3806 .psl = false,
3807},
3808.{
3809 .name = "nostdinc++",
3810 .syntax = .flag,
3811 .zig_equivalent = .nostdlib_cpp,
3812 .pd1 = true,
3813 .pd2 = false,
3814 .psl = false,
3815},
37953816.{
37963817 .name = "nostdlib",
37973818 .syntax = .flag,
......@@ -3800,7 +3821,14 @@ flagpd1("nostdinc++"),
38003821 .pd2 = false,
38013822 .psl = false,
38023823},
3803flagpd1("nostdlibinc"),
3824.{
3825 .name = "nostdlibinc",
3826 .syntax = .flag,
3827 .zig_equivalent = .nostdlibinc,
3828 .pd1 = true,
3829 .pd2 = false,
3830 .psl = false,
3831},
38043832.{
38053833 .name = "nostdlib++",
38063834 .syntax = .flag,
src-self-hosted/stage2.zig+1
......@@ -1293,6 +1293,7 @@ pub const ClangArgIterator = extern struct {
12931293 dep_file,
12941294 framework_dir,
12951295 framework,
1296 nostdlibinc,
12961297 };
12971298
12981299 const Args = struct {
src/main.cpp+6-1
......@@ -447,6 +447,7 @@ static int main0(int argc, char **argv) {
447447 bool ensure_libc_on_non_freestanding = false;
448448 bool ensure_libcpp_on_non_freestanding = false;
449449 bool disable_c_depfile = false;
450 bool want_native_include_dirs = false;
450451 Buf *linker_optimization = nullptr;
451452 OptionalBool linker_gc_sections = OptionalBoolNull;
452453 OptionalBool linker_allow_shlib_undefined = OptionalBoolNull;
......@@ -581,6 +582,7 @@ static int main0(int argc, char **argv) {
581582 strip = true;
582583 ensure_libc_on_non_freestanding = true;
583584 ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0);
585 want_native_include_dirs = true;
584586
585587 bool c_arg = false;
586588 Stage2ClangArgIterator it;
......@@ -747,6 +749,9 @@ static int main0(int argc, char **argv) {
747749 case Stage2ClangArgFramework:
748750 frameworks.append(it.only_arg);
749751 break;
752 case Stage2ClangArgNoStdLibInc:
753 want_native_include_dirs = false;
754 break;
750755 }
751756 }
752757 // Parse linker args
......@@ -1418,7 +1423,7 @@ static int main0(int argc, char **argv) {
14181423 }
14191424 }
14201425
1421 if (target.is_native_os && any_system_lib_dependencies) {
1426 if (target.is_native_os && (any_system_lib_dependencies || want_native_include_dirs)) {
14221427 Error err;
14231428 Stage2NativePaths paths;
14241429 if ((err = stage2_detect_native_paths(&paths))) {
src/stage2.h+1
......@@ -352,6 +352,7 @@ enum Stage2ClangArg {
352352 Stage2ClangArgDepFile,
353353 Stage2ClangArgFrameworkDir,
354354 Stage2ClangArgFramework,
355 Stage2ClangArgNoStdLibInc,
355356};
356357
357358// ABI warning
tools/update_clang_options.zig+20
......@@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{
5454 .name = "fno-PIC",
5555 .ident = "no_pic",
5656 },
57 .{
58 .name = "nolibc",
59 .ident = "nostdlib",
60 },
5761 .{
5862 .name = "nostdlib",
5963 .ident = "nostdlib",
......@@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{
6670 .name = "nostdlib++",
6771 .ident = "nostdlib_cpp",
6872 },
73 .{
74 .name = "nostdinc++",
75 .ident = "nostdlib_cpp",
76 },
77 .{
78 .name = "nostdlibinc",
79 .ident = "nostdlibinc",
80 },
81 .{
82 .name = "nostdinc",
83 .ident = "nostdlibinc",
84 },
85 .{
86 .name = "no-standard-includes",
87 .ident = "nostdlibinc",
88 },
6989 .{
7090 .name = "shared",
7191 .ident = "shared",