| ... | ... | @@ -3798,53 +3798,88 @@ fn detectLibCIncludeDirs( |
| 3798 | 3798 | // If not linking system libraries, build and provide our own libc by |
| 3799 | 3799 | // default if possible. |
| 3800 | 3800 | if (target_util.canBuildLibC(target)) { |
| 3801 | | const generic_name = target_util.libCGenericName(target); |
| 3802 | | // Some architectures are handled by the same set of headers. |
| 3803 | | const arch_name = if (target.abi.isMusl()) |
| 3804 | | musl.archName(target.cpu.arch) |
| 3805 | | else if (target.cpu.arch.isThumb()) |
| 3806 | | // ARM headers are valid for Thumb too. |
| 3807 | | switch (target.cpu.arch) { |
| 3808 | | .thumb => "arm", |
| 3809 | | .thumbeb => "armeb", |
| 3810 | | else => unreachable, |
| 3811 | | } |
| 3812 | | else |
| 3813 | | @tagName(target.cpu.arch); |
| 3814 | | const os_name = @tagName(target.os.tag); |
| 3815 | | // Musl's headers are ABI-agnostic and so they all have the "musl" ABI name. |
| 3816 | | const abi_name = if (target.abi.isMusl()) "musl" else @tagName(target.abi); |
| 3817 | | const s = std.fs.path.sep_str; |
| 3818 | | const arch_include_dir = try std.fmt.allocPrint( |
| 3819 | | arena, |
| 3820 | | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", |
| 3821 | | .{ zig_lib_dir, arch_name, os_name, abi_name }, |
| 3822 | | ); |
| 3823 | | const generic_include_dir = try std.fmt.allocPrint( |
| 3824 | | arena, |
| 3825 | | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}", |
| 3826 | | .{ zig_lib_dir, generic_name }, |
| 3827 | | ); |
| 3828 | | const arch_os_include_dir = try std.fmt.allocPrint( |
| 3829 | | arena, |
| 3830 | | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any", |
| 3831 | | .{ zig_lib_dir, @tagName(target.cpu.arch), os_name }, |
| 3832 | | ); |
| 3833 | | const generic_os_include_dir = try std.fmt.allocPrint( |
| 3834 | | arena, |
| 3835 | | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any", |
| 3836 | | .{ zig_lib_dir, os_name }, |
| 3837 | | ); |
| 3801 | switch (target.os.tag) { |
| 3802 | .macos => { |
| 3803 | const arch_name = @tagName(target.cpu.arch); |
| 3804 | const os_name = try std.fmt.allocPrint(arena, "{s}.{d}", .{ |
| 3805 | @tagName(target.os.tag), |
| 3806 | target.os.version_range.semver.min.major, |
| 3807 | }); |
| 3808 | const s = std.fs.path.sep_str; |
| 3809 | const list = try arena.alloc([]const u8, 3); |
| 3838 | 3810 | |
| 3839 | | const list = try arena.alloc([]const u8, 4); |
| 3840 | | list[0] = arch_include_dir; |
| 3841 | | list[1] = generic_include_dir; |
| 3842 | | list[2] = arch_os_include_dir; |
| 3843 | | list[3] = generic_os_include_dir; |
| 3844 | | return LibCDirs{ |
| 3845 | | .libc_include_dir_list = list, |
| 3846 | | .libc_installation = null, |
| 3847 | | }; |
| 3811 | list[0] = try std.fmt.allocPrint( |
| 3812 | arena, |
| 3813 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-gnu", |
| 3814 | .{ zig_lib_dir, arch_name, os_name }, |
| 3815 | ); |
| 3816 | list[1] = try std.fmt.allocPrint( |
| 3817 | arena, |
| 3818 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any", |
| 3819 | .{ zig_lib_dir, os_name }, |
| 3820 | ); |
| 3821 | list[2] = try std.fmt.allocPrint( |
| 3822 | arena, |
| 3823 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-macos-any", |
| 3824 | .{zig_lib_dir}, |
| 3825 | ); |
| 3826 | |
| 3827 | return LibCDirs{ |
| 3828 | .libc_include_dir_list = list, |
| 3829 | .libc_installation = null, |
| 3830 | }; |
| 3831 | }, |
| 3832 | else => { |
| 3833 | const generic_name = target_util.libCGenericName(target); |
| 3834 | // Some architectures are handled by the same set of headers. |
| 3835 | const arch_name = if (target.abi.isMusl()) |
| 3836 | musl.archName(target.cpu.arch) |
| 3837 | else if (target.cpu.arch.isThumb()) |
| 3838 | // ARM headers are valid for Thumb too. |
| 3839 | switch (target.cpu.arch) { |
| 3840 | .thumb => "arm", |
| 3841 | .thumbeb => "armeb", |
| 3842 | else => unreachable, |
| 3843 | } |
| 3844 | else |
| 3845 | @tagName(target.cpu.arch); |
| 3846 | const os_name = @tagName(target.os.tag); |
| 3847 | // Musl's headers are ABI-agnostic and so they all have the "musl" ABI name. |
| 3848 | const abi_name = if (target.abi.isMusl()) "musl" else @tagName(target.abi); |
| 3849 | const s = std.fs.path.sep_str; |
| 3850 | const arch_include_dir = try std.fmt.allocPrint( |
| 3851 | arena, |
| 3852 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", |
| 3853 | .{ zig_lib_dir, arch_name, os_name, abi_name }, |
| 3854 | ); |
| 3855 | const generic_include_dir = try std.fmt.allocPrint( |
| 3856 | arena, |
| 3857 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "generic-{s}", |
| 3858 | .{ zig_lib_dir, generic_name }, |
| 3859 | ); |
| 3860 | const arch_os_include_dir = try std.fmt.allocPrint( |
| 3861 | arena, |
| 3862 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-any", |
| 3863 | .{ zig_lib_dir, @tagName(target.cpu.arch), os_name }, |
| 3864 | ); |
| 3865 | const generic_os_include_dir = try std.fmt.allocPrint( |
| 3866 | arena, |
| 3867 | "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "any-{s}-any", |
| 3868 | .{ zig_lib_dir, os_name }, |
| 3869 | ); |
| 3870 | |
| 3871 | const list = try arena.alloc([]const u8, 4); |
| 3872 | list[0] = arch_include_dir; |
| 3873 | list[1] = generic_include_dir; |
| 3874 | list[2] = arch_os_include_dir; |
| 3875 | list[3] = generic_os_include_dir; |
| 3876 | |
| 3877 | return LibCDirs{ |
| 3878 | .libc_include_dir_list = list, |
| 3879 | .libc_installation = null, |
| 3880 | }; |
| 3881 | }, |
| 3882 | } |
| 3848 | 3883 | } |
| 3849 | 3884 | |
| 3850 | 3885 | // If zig can't build the libc for the target and we are targeting the |