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"),...@@ -1725,7 +1725,7 @@ flagpsl("MT"),
1725.{1725.{
1726 .name = "no-standard-includes",1726 .name = "no-standard-includes",
1727 .syntax = .flag,1727 .syntax = .flag,
1728 .zig_equivalent = .other,1728 .zig_equivalent = .nostdlibinc,
1729 .pd1 = false,1729 .pd1 = false,
1730 .pd2 = true,1730 .pd2 = true,
1731 .psl = false,1731 .psl = false,
...@@ -3781,7 +3781,14 @@ flagpd1("nocudainc"),...@@ -3781,7 +3781,14 @@ flagpd1("nocudainc"),
3781flagpd1("nodefaultlibs"),3781flagpd1("nodefaultlibs"),
3782flagpd1("nofixprebinding"),3782flagpd1("nofixprebinding"),
3783flagpd1("nogpulib"),3783flagpd1("nogpulib"),
3784flagpd1("nolibc"),3784.{
3785 .name = "nolibc",
3786 .syntax = .flag,
3787 .zig_equivalent = .nostdlib,
3788 .pd1 = true,
3789 .pd2 = false,
3790 .psl = false,
3791},
3785flagpd1("nomultidefs"),3792flagpd1("nomultidefs"),
3786flagpd1("fnon-call-exceptions"),3793flagpd1("fnon-call-exceptions"),
3787flagpd1("fno-non-call-exceptions"),3794flagpd1("fno-non-call-exceptions"),
...@@ -3790,8 +3797,22 @@ flagpd1("noprebind"),...@@ -3790,8 +3797,22 @@ flagpd1("noprebind"),
3790flagpd1("noprofilelib"),3797flagpd1("noprofilelib"),
3791flagpd1("noseglinkedit"),3798flagpd1("noseglinkedit"),
3792flagpd1("nostartfiles"),3799flagpd1("nostartfiles"),
3793flagpd1("nostdinc"),3800.{
3794flagpd1("nostdinc++"),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},
3795.{3816.{
3796 .name = "nostdlib",3817 .name = "nostdlib",
3797 .syntax = .flag,3818 .syntax = .flag,
...@@ -3800,7 +3821,14 @@ flagpd1("nostdinc++"),...@@ -3800,7 +3821,14 @@ flagpd1("nostdinc++"),
3800 .pd2 = false,3821 .pd2 = false,
3801 .psl = false,3822 .psl = false,
3802},3823},
3803flagpd1("nostdlibinc"),3824.{
3825 .name = "nostdlibinc",
3826 .syntax = .flag,
3827 .zig_equivalent = .nostdlibinc,
3828 .pd1 = true,
3829 .pd2 = false,
3830 .psl = false,
3831},
3804.{3832.{
3805 .name = "nostdlib++",3833 .name = "nostdlib++",
3806 .syntax = .flag,3834 .syntax = .flag,
src-self-hosted/stage2.zig+1
...@@ -1293,6 +1293,7 @@ pub const ClangArgIterator = extern struct {...@@ -1293,6 +1293,7 @@ pub const ClangArgIterator = extern struct {
1293 dep_file,1293 dep_file,
1294 framework_dir,1294 framework_dir,
1295 framework,1295 framework,
1296 nostdlibinc,
1296 };1297 };
12971298
1298 const Args = struct {1299 const Args = struct {
src/main.cpp+6-1
...@@ -447,6 +447,7 @@ static int main0(int argc, char **argv) {...@@ -447,6 +447,7 @@ static int main0(int argc, char **argv) {
447 bool ensure_libc_on_non_freestanding = false;447 bool ensure_libc_on_non_freestanding = false;
448 bool ensure_libcpp_on_non_freestanding = false;448 bool ensure_libcpp_on_non_freestanding = false;
449 bool disable_c_depfile = false;449 bool disable_c_depfile = false;
450 bool want_native_include_dirs = false;
450 Buf *linker_optimization = nullptr;451 Buf *linker_optimization = nullptr;
451 OptionalBool linker_gc_sections = OptionalBoolNull;452 OptionalBool linker_gc_sections = OptionalBoolNull;
452 OptionalBool linker_allow_shlib_undefined = OptionalBoolNull;453 OptionalBool linker_allow_shlib_undefined = OptionalBoolNull;
...@@ -581,6 +582,7 @@ static int main0(int argc, char **argv) {...@@ -581,6 +582,7 @@ static int main0(int argc, char **argv) {
581 strip = true;582 strip = true;
582 ensure_libc_on_non_freestanding = true;583 ensure_libc_on_non_freestanding = true;
583 ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0);584 ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0);
585 want_native_include_dirs = true;
584586
585 bool c_arg = false;587 bool c_arg = false;
586 Stage2ClangArgIterator it;588 Stage2ClangArgIterator it;
...@@ -747,6 +749,9 @@ static int main0(int argc, char **argv) {...@@ -747,6 +749,9 @@ static int main0(int argc, char **argv) {
747 case Stage2ClangArgFramework:749 case Stage2ClangArgFramework:
748 frameworks.append(it.only_arg);750 frameworks.append(it.only_arg);
749 break;751 break;
752 case Stage2ClangArgNoStdLibInc:
753 want_native_include_dirs = false;
754 break;
750 }755 }
751 }756 }
752 // Parse linker args757 // Parse linker args
...@@ -1418,7 +1423,7 @@ static int main0(int argc, char **argv) {...@@ -1418,7 +1423,7 @@ static int main0(int argc, char **argv) {
1418 }1423 }
1419 }1424 }
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)) {
1422 Error err;1427 Error err;
1423 Stage2NativePaths paths;1428 Stage2NativePaths paths;
1424 if ((err = stage2_detect_native_paths(&paths))) {1429 if ((err = stage2_detect_native_paths(&paths))) {
src/stage2.h+1
...@@ -352,6 +352,7 @@ enum Stage2ClangArg {...@@ -352,6 +352,7 @@ enum Stage2ClangArg {
352 Stage2ClangArgDepFile,352 Stage2ClangArgDepFile,
353 Stage2ClangArgFrameworkDir,353 Stage2ClangArgFrameworkDir,
354 Stage2ClangArgFramework,354 Stage2ClangArgFramework,
355 Stage2ClangArgNoStdLibInc,
355};356};
356357
357// ABI warning358// ABI warning
tools/update_clang_options.zig+20
...@@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{...@@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{
54 .name = "fno-PIC",54 .name = "fno-PIC",
55 .ident = "no_pic",55 .ident = "no_pic",
56 },56 },
57 .{
58 .name = "nolibc",
59 .ident = "nostdlib",
60 },
57 .{61 .{
58 .name = "nostdlib",62 .name = "nostdlib",
59 .ident = "nostdlib",63 .ident = "nostdlib",
...@@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{...@@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{
66 .name = "nostdlib++",70 .name = "nostdlib++",
67 .ident = "nostdlib_cpp",71 .ident = "nostdlib_cpp",
68 },72 },
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 },
69 .{89 .{
70 .name = "shared",90 .name = "shared",
71 .ident = "shared",91 .ident = "shared",