| author | |
| committer | |
| log | d38ed893c6ece24e52b2e0a1f8d75f6a912686d7 |
| tree | dd79b7c06c3482c47d62305e1b53278fe995cc1b |
| parent | 4a2a0f50caac5e6f7f17e5abe17dd53e9bdc1731 |
| parent | 549a7eba40aebaad2ede0fef3a574f52315c36cf |
| signature |
`std.Target`: Some miscellaneous API improvements10 files changed, 157 insertions(+), 163 deletions(-)
lib/std/Build/Module.zig+2-2| ... | @@ -492,11 +492,11 @@ pub fn linkSystemLibrary( | ... | @@ -492,11 +492,11 @@ pub fn linkSystemLibrary( |
| 492 | const b = m.owner; | 492 | const b = m.owner; |
| 493 | 493 | ||
| 494 | const target = m.requireKnownTarget(); | 494 | const target = m.requireKnownTarget(); |
| 495 | if (target.is_libc_lib_name(name)) { | 495 | if (std.zig.target.isLibCLibName(target, name)) { |
| 496 | m.link_libc = true; | 496 | m.link_libc = true; |
| 497 | return; | 497 | return; |
| 498 | } | 498 | } |
| 499 | if (target.is_libcpp_lib_name(name)) { | 499 | if (std.zig.target.isLibCxxLibName(target, name)) { |
| 500 | m.link_libcpp = true; | 500 | m.link_libcpp = true; |
| 501 | return; | 501 | return; |
| 502 | } | 502 | } |
lib/std/Build/Step/Compile.zig+4-2| ... | @@ -611,11 +611,13 @@ pub fn dependsOnSystemLibrary(compile: *const Compile, name: []const u8) bool { | ... | @@ -611,11 +611,13 @@ pub fn dependsOnSystemLibrary(compile: *const Compile, name: []const u8) bool { |
| 611 | is_linking_libcpp = is_linking_libcpp or module.link_libcpp == true; | 611 | is_linking_libcpp = is_linking_libcpp or module.link_libcpp == true; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | if (compile.rootModuleTarget().is_libc_lib_name(name)) { | 614 | const target = compile.rootModuleTarget(); |
| 615 | |||
| 616 | if (std.zig.target.isLibCLibName(target, name)) { | ||
| 615 | return is_linking_libc; | 617 | return is_linking_libc; |
| 616 | } | 618 | } |
| 617 | 619 | ||
| 618 | if (compile.rootModuleTarget().is_libcpp_lib_name(name)) { | 620 | if (std.zig.target.isLibCxxLibName(target, name)) { |
| 619 | return is_linking_libcpp; | 621 | return is_linking_libcpp; |
| 620 | } | 622 | } |
| 621 | 623 |
lib/std/Target.zig+6-147| ... | @@ -157,7 +157,7 @@ pub const Os = struct { | ... | @@ -157,7 +157,7 @@ pub const Os = struct { |
| 157 | }; | 157 | }; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { | 160 | pub inline fn versionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? { |
| 161 | return switch (tag) { | 161 | return switch (tag) { |
| 162 | .freestanding, | 162 | .freestanding, |
| 163 | .fuchsia, | 163 | .fuchsia, |
| ... | @@ -545,8 +545,8 @@ pub const Os = struct { | ... | @@ -545,8 +545,8 @@ pub const Os = struct { |
| 545 | 545 | ||
| 546 | /// Provides a tagged union. `Target` does not store the tag because it is | 546 | /// Provides a tagged union. `Target` does not store the tag because it is |
| 547 | /// redundant with the OS tag; this function abstracts that part away. | 547 | /// redundant with the OS tag; this function abstracts that part away. |
| 548 | pub inline fn getVersionRange(os: Os) TaggedVersionRange { | 548 | pub inline fn versionRange(os: Os) TaggedVersionRange { |
| 549 | return switch (os.tag.getVersionRangeTag()) { | 549 | return switch (os.tag.versionRangeTag()) { |
| 550 | .none => .{ .none = {} }, | 550 | .none => .{ .none = {} }, |
| 551 | .semver => .{ .semver = os.version_range.semver }, | 551 | .semver => .{ .semver = os.version_range.semver }, |
| 552 | .linux => .{ .linux = os.version_range.linux }, | 552 | .linux => .{ .linux = os.version_range.linux }, |
| ... | @@ -556,12 +556,12 @@ pub const Os = struct { | ... | @@ -556,12 +556,12 @@ pub const Os = struct { |
| 556 | 556 | ||
| 557 | /// Checks if system is guaranteed to be at least `version` or older than `version`. | 557 | /// Checks if system is guaranteed to be at least `version` or older than `version`. |
| 558 | /// Returns `null` if a runtime check is required. | 558 | /// Returns `null` if a runtime check is required. |
| 559 | pub inline fn isAtLeast(os: Os, comptime tag: Tag, ver: switch (tag.getVersionRangeTag()) { | 559 | pub inline fn isAtLeast(os: Os, comptime tag: Tag, ver: switch (tag.versionRangeTag()) { |
| 560 | .none => void, | 560 | .none => void, |
| 561 | .semver, .linux => std.SemanticVersion, | 561 | .semver, .linux => std.SemanticVersion, |
| 562 | .windows => WindowsVersion, | 562 | .windows => WindowsVersion, |
| 563 | }) ?bool { | 563 | }) ?bool { |
| 564 | return if (os.tag != tag) false else switch (tag.getVersionRangeTag()) { | 564 | return if (os.tag != tag) false else switch (tag.versionRangeTag()) { |
| 565 | .none => true, | 565 | .none => true, |
| 566 | inline .semver, | 566 | inline .semver, |
| 567 | .linux, | 567 | .linux, |
| ... | @@ -925,8 +925,6 @@ pub const ObjectFormat = enum { | ... | @@ -925,8 +925,6 @@ pub const ObjectFormat = enum { |
| 925 | }; | 925 | }; |
| 926 | 926 | ||
| 927 | pub fn toElfMachine(target: Target) std.elf.EM { | 927 | pub fn toElfMachine(target: Target) std.elf.EM { |
| 928 | if (target.os.tag == .elfiamcu) return .IAMCU; | ||
| 929 | |||
| 930 | return switch (target.cpu.arch) { | 928 | return switch (target.cpu.arch) { |
| 931 | .amdgcn => .AMDGPU, | 929 | .amdgcn => .AMDGPU, |
| 932 | .arc => .ARC_COMPACT, | 930 | .arc => .ARC_COMPACT, |
| ... | @@ -950,7 +948,7 @@ pub fn toElfMachine(target: Target) std.elf.EM { | ... | @@ -950,7 +948,7 @@ pub fn toElfMachine(target: Target) std.elf.EM { |
| 950 | .sparc64 => .SPARCV9, | 948 | .sparc64 => .SPARCV9, |
| 951 | .spu_2 => .SPU_2, | 949 | .spu_2 => .SPU_2, |
| 952 | .ve => .VE, | 950 | .ve => .VE, |
| 953 | .x86 => .@"386", | 951 | .x86 => if (target.os.tag == .elfiamcu) .IAMCU else .@"386", |
| 954 | .x86_64 => .X86_64, | 952 | .x86_64 => .X86_64, |
| 955 | .xcore => .XCORE, | 953 | .xcore => .XCORE, |
| 956 | .xtensa => .XTENSA, | 954 | .xtensa => .XTENSA, |
| ... | @@ -1756,10 +1754,6 @@ pub inline fn isBSD(target: Target) bool { | ... | @@ -1756,10 +1754,6 @@ pub inline fn isBSD(target: Target) bool { |
| 1756 | return target.os.tag.isBSD(); | 1754 | return target.os.tag.isBSD(); |
| 1757 | } | 1755 | } |
| 1758 | 1756 | ||
| 1759 | pub inline fn isBpfFreestanding(target: Target) bool { | ||
| 1760 | return target.cpu.arch.isBpf() and target.os.tag == .freestanding; | ||
| 1761 | } | ||
| 1762 | |||
| 1763 | pub inline fn isGnuLibC(target: Target) bool { | 1757 | pub inline fn isGnuLibC(target: Target) bool { |
| 1764 | return target.os.tag.isGnuLibC(target.abi); | 1758 | return target.os.tag.isGnuLibC(target.abi); |
| 1765 | } | 1759 | } |
| ... | @@ -2870,141 +2864,6 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { | ... | @@ -2870,141 +2864,6 @@ pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 { |
| 2870 | ); | 2864 | ); |
| 2871 | } | 2865 | } |
| 2872 | 2866 | ||
| 2873 | pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool { | ||
| 2874 | const ignore_case = target.os.tag == .macos or target.os.tag == .windows; | ||
| 2875 | |||
| 2876 | if (eqlIgnoreCase(ignore_case, name, "c")) | ||
| 2877 | return true; | ||
| 2878 | |||
| 2879 | if (target.isMinGW()) { | ||
| 2880 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 2881 | return true; | ||
| 2882 | if (eqlIgnoreCase(ignore_case, name, "mingw32")) | ||
| 2883 | return true; | ||
| 2884 | if (eqlIgnoreCase(ignore_case, name, "msvcrt-os")) | ||
| 2885 | return true; | ||
| 2886 | if (eqlIgnoreCase(ignore_case, name, "mingwex")) | ||
| 2887 | return true; | ||
| 2888 | if (eqlIgnoreCase(ignore_case, name, "uuid")) | ||
| 2889 | return true; | ||
| 2890 | if (eqlIgnoreCase(ignore_case, name, "bits")) | ||
| 2891 | return true; | ||
| 2892 | if (eqlIgnoreCase(ignore_case, name, "dmoguids")) | ||
| 2893 | return true; | ||
| 2894 | if (eqlIgnoreCase(ignore_case, name, "dxerr8")) | ||
| 2895 | return true; | ||
| 2896 | if (eqlIgnoreCase(ignore_case, name, "dxerr9")) | ||
| 2897 | return true; | ||
| 2898 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 2899 | return true; | ||
| 2900 | if (eqlIgnoreCase(ignore_case, name, "msxml2")) | ||
| 2901 | return true; | ||
| 2902 | if (eqlIgnoreCase(ignore_case, name, "msxml6")) | ||
| 2903 | return true; | ||
| 2904 | if (eqlIgnoreCase(ignore_case, name, "amstrmid")) | ||
| 2905 | return true; | ||
| 2906 | if (eqlIgnoreCase(ignore_case, name, "wbemuuid")) | ||
| 2907 | return true; | ||
| 2908 | if (eqlIgnoreCase(ignore_case, name, "wmcodecdspuuid")) | ||
| 2909 | return true; | ||
| 2910 | if (eqlIgnoreCase(ignore_case, name, "dxguid")) | ||
| 2911 | return true; | ||
| 2912 | if (eqlIgnoreCase(ignore_case, name, "ksguid")) | ||
| 2913 | return true; | ||
| 2914 | if (eqlIgnoreCase(ignore_case, name, "locationapi")) | ||
| 2915 | return true; | ||
| 2916 | if (eqlIgnoreCase(ignore_case, name, "portabledeviceguids")) | ||
| 2917 | return true; | ||
| 2918 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 2919 | return true; | ||
| 2920 | if (eqlIgnoreCase(ignore_case, name, "dloadhelper")) | ||
| 2921 | return true; | ||
| 2922 | if (eqlIgnoreCase(ignore_case, name, "strmiids")) | ||
| 2923 | return true; | ||
| 2924 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 2925 | return true; | ||
| 2926 | if (eqlIgnoreCase(ignore_case, name, "adsiid")) | ||
| 2927 | return true; | ||
| 2928 | |||
| 2929 | return false; | ||
| 2930 | } | ||
| 2931 | |||
| 2932 | if (target.abi.isGnu() or target.abi.isMusl()) { | ||
| 2933 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 2934 | return true; | ||
| 2935 | if (eqlIgnoreCase(ignore_case, name, "rt")) | ||
| 2936 | return true; | ||
| 2937 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | ||
| 2938 | return true; | ||
| 2939 | if (eqlIgnoreCase(ignore_case, name, "util")) | ||
| 2940 | return true; | ||
| 2941 | if (eqlIgnoreCase(ignore_case, name, "xnet")) | ||
| 2942 | return true; | ||
| 2943 | if (eqlIgnoreCase(ignore_case, name, "resolv")) | ||
| 2944 | return true; | ||
| 2945 | if (eqlIgnoreCase(ignore_case, name, "dl")) | ||
| 2946 | return true; | ||
| 2947 | } | ||
| 2948 | |||
| 2949 | if (target.abi.isMusl()) { | ||
| 2950 | if (eqlIgnoreCase(ignore_case, name, "crypt")) | ||
| 2951 | return true; | ||
| 2952 | } | ||
| 2953 | |||
| 2954 | if (target.os.tag.isDarwin()) { | ||
| 2955 | if (eqlIgnoreCase(ignore_case, name, "System")) | ||
| 2956 | return true; | ||
| 2957 | if (eqlIgnoreCase(ignore_case, name, "c")) | ||
| 2958 | return true; | ||
| 2959 | if (eqlIgnoreCase(ignore_case, name, "dbm")) | ||
| 2960 | return true; | ||
| 2961 | if (eqlIgnoreCase(ignore_case, name, "dl")) | ||
| 2962 | return true; | ||
| 2963 | if (eqlIgnoreCase(ignore_case, name, "info")) | ||
| 2964 | return true; | ||
| 2965 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 2966 | return true; | ||
| 2967 | if (eqlIgnoreCase(ignore_case, name, "poll")) | ||
| 2968 | return true; | ||
| 2969 | if (eqlIgnoreCase(ignore_case, name, "proc")) | ||
| 2970 | return true; | ||
| 2971 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | ||
| 2972 | return true; | ||
| 2973 | if (eqlIgnoreCase(ignore_case, name, "rpcsvc")) | ||
| 2974 | return true; | ||
| 2975 | } | ||
| 2976 | |||
| 2977 | if (target.os.isAtLeast(.macos, .{ .major = 10, .minor = 8, .patch = 0 }) orelse false) { | ||
| 2978 | if (eqlIgnoreCase(ignore_case, name, "mx")) | ||
| 2979 | return true; | ||
| 2980 | } | ||
| 2981 | |||
| 2982 | if (target.os.tag == .haiku) { | ||
| 2983 | if (eqlIgnoreCase(ignore_case, name, "root")) | ||
| 2984 | return true; | ||
| 2985 | if (eqlIgnoreCase(ignore_case, name, "network")) | ||
| 2986 | return true; | ||
| 2987 | } | ||
| 2988 | |||
| 2989 | return false; | ||
| 2990 | } | ||
| 2991 | |||
| 2992 | pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { | ||
| 2993 | const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; | ||
| 2994 | |||
| 2995 | return eqlIgnoreCase(ignore_case, name, "c++") or | ||
| 2996 | eqlIgnoreCase(ignore_case, name, "stdc++") or | ||
| 2997 | eqlIgnoreCase(ignore_case, name, "c++abi"); | ||
| 2998 | } | ||
| 2999 | |||
| 3000 | fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { | ||
| 3001 | if (ignore_case) { | ||
| 3002 | return std.ascii.eqlIgnoreCase(a, b); | ||
| 3003 | } else { | ||
| 3004 | return std.mem.eql(u8, a, b); | ||
| 3005 | } | ||
| 3006 | } | ||
| 3007 | |||
| 3008 | pub fn osArchName(target: std.Target) [:0]const u8 { | 2867 | pub fn osArchName(target: std.Target) [:0]const u8 { |
| 3009 | return target.os.tag.archName(target.cpu.arch); | 2868 | return target.os.tag.archName(target.cpu.arch); |
| 3010 | } | 2869 | } |
lib/std/Target/Query.zig+2-2| ... | @@ -124,7 +124,7 @@ pub fn fromTarget(target: Target) Query { | ... | @@ -124,7 +124,7 @@ pub fn fromTarget(target: Target) Query { |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | fn updateOsVersionRange(self: *Query, os: Target.Os) void { | 126 | fn updateOsVersionRange(self: *Query, os: Target.Os) void { |
| 127 | self.os_version_min, self.os_version_max = switch (os.tag.getVersionRangeTag()) { | 127 | self.os_version_min, self.os_version_max = switch (os.tag.versionRangeTag()) { |
| 128 | .none => .{ .{ .none = {} }, .{ .none = {} } }, | 128 | .none => .{ .{ .none = {} }, .{ .none = {} } }, |
| 129 | .semver => .{ | 129 | .semver => .{ |
| 130 | .{ .semver = os.version_range.semver.min }, | 130 | .{ .semver = os.version_range.semver.min }, |
| ... | @@ -523,7 +523,7 @@ fn parseOs(result: *Query, diags: *ParseOptions.Diagnostics, text: []const u8) ! | ... | @@ -523,7 +523,7 @@ fn parseOs(result: *Query, diags: *ParseOptions.Diagnostics, text: []const u8) ! |
| 523 | diags.os_tag = tag; | 523 | diags.os_tag = tag; |
| 524 | 524 | ||
| 525 | const version_text = it.rest(); | 525 | const version_text = it.rest(); |
| 526 | if (version_text.len > 0) switch (tag.getVersionRangeTag()) { | 526 | if (version_text.len > 0) switch (tag.versionRangeTag()) { |
| 527 | .none => return error.InvalidOperatingSystemVersion, | 527 | .none => return error.InvalidOperatingSystemVersion, |
| 528 | .semver, .linux => range: { | 528 | .semver, .linux => range: { |
| 529 | var range_it = mem.splitSequence(u8, version_text, "..."); | 529 | var range_it = mem.splitSequence(u8, version_text, "..."); |
lib/std/zig/target.zig+135| ... | @@ -124,4 +124,139 @@ pub fn muslArchName(arch: std.Target.Cpu.Arch) [:0]const u8 { | ... | @@ -124,4 +124,139 @@ pub fn muslArchName(arch: std.Target.Cpu.Arch) [:0]const u8 { |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | pub fn isLibCLibName(target: std.Target, name: []const u8) bool { | ||
| 128 | const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; | ||
| 129 | |||
| 130 | if (eqlIgnoreCase(ignore_case, name, "c")) | ||
| 131 | return true; | ||
| 132 | |||
| 133 | if (target.isMinGW()) { | ||
| 134 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 135 | return true; | ||
| 136 | if (eqlIgnoreCase(ignore_case, name, "mingw32")) | ||
| 137 | return true; | ||
| 138 | if (eqlIgnoreCase(ignore_case, name, "msvcrt-os")) | ||
| 139 | return true; | ||
| 140 | if (eqlIgnoreCase(ignore_case, name, "mingwex")) | ||
| 141 | return true; | ||
| 142 | if (eqlIgnoreCase(ignore_case, name, "uuid")) | ||
| 143 | return true; | ||
| 144 | if (eqlIgnoreCase(ignore_case, name, "bits")) | ||
| 145 | return true; | ||
| 146 | if (eqlIgnoreCase(ignore_case, name, "dmoguids")) | ||
| 147 | return true; | ||
| 148 | if (eqlIgnoreCase(ignore_case, name, "dxerr8")) | ||
| 149 | return true; | ||
| 150 | if (eqlIgnoreCase(ignore_case, name, "dxerr9")) | ||
| 151 | return true; | ||
| 152 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 153 | return true; | ||
| 154 | if (eqlIgnoreCase(ignore_case, name, "msxml2")) | ||
| 155 | return true; | ||
| 156 | if (eqlIgnoreCase(ignore_case, name, "msxml6")) | ||
| 157 | return true; | ||
| 158 | if (eqlIgnoreCase(ignore_case, name, "amstrmid")) | ||
| 159 | return true; | ||
| 160 | if (eqlIgnoreCase(ignore_case, name, "wbemuuid")) | ||
| 161 | return true; | ||
| 162 | if (eqlIgnoreCase(ignore_case, name, "wmcodecdspuuid")) | ||
| 163 | return true; | ||
| 164 | if (eqlIgnoreCase(ignore_case, name, "dxguid")) | ||
| 165 | return true; | ||
| 166 | if (eqlIgnoreCase(ignore_case, name, "ksguid")) | ||
| 167 | return true; | ||
| 168 | if (eqlIgnoreCase(ignore_case, name, "locationapi")) | ||
| 169 | return true; | ||
| 170 | if (eqlIgnoreCase(ignore_case, name, "portabledeviceguids")) | ||
| 171 | return true; | ||
| 172 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 173 | return true; | ||
| 174 | if (eqlIgnoreCase(ignore_case, name, "dloadhelper")) | ||
| 175 | return true; | ||
| 176 | if (eqlIgnoreCase(ignore_case, name, "strmiids")) | ||
| 177 | return true; | ||
| 178 | if (eqlIgnoreCase(ignore_case, name, "mfuuid")) | ||
| 179 | return true; | ||
| 180 | if (eqlIgnoreCase(ignore_case, name, "adsiid")) | ||
| 181 | return true; | ||
| 182 | |||
| 183 | return false; | ||
| 184 | } | ||
| 185 | |||
| 186 | if (target.abi.isGnu() or target.abi.isMusl()) { | ||
| 187 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 188 | return true; | ||
| 189 | if (eqlIgnoreCase(ignore_case, name, "rt")) | ||
| 190 | return true; | ||
| 191 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | ||
| 192 | return true; | ||
| 193 | if (eqlIgnoreCase(ignore_case, name, "util")) | ||
| 194 | return true; | ||
| 195 | if (eqlIgnoreCase(ignore_case, name, "resolv")) | ||
| 196 | return true; | ||
| 197 | if (eqlIgnoreCase(ignore_case, name, "dl")) | ||
| 198 | return true; | ||
| 199 | } | ||
| 200 | |||
| 201 | if (target.abi.isMusl()) { | ||
| 202 | if (eqlIgnoreCase(ignore_case, name, "crypt")) | ||
| 203 | return true; | ||
| 204 | if (eqlIgnoreCase(ignore_case, name, "xnet")) | ||
| 205 | return true; | ||
| 206 | } | ||
| 207 | |||
| 208 | if (target.os.tag.isDarwin()) { | ||
| 209 | if (eqlIgnoreCase(ignore_case, name, "System")) | ||
| 210 | return true; | ||
| 211 | if (eqlIgnoreCase(ignore_case, name, "c")) | ||
| 212 | return true; | ||
| 213 | if (eqlIgnoreCase(ignore_case, name, "dbm")) | ||
| 214 | return true; | ||
| 215 | if (eqlIgnoreCase(ignore_case, name, "dl")) | ||
| 216 | return true; | ||
| 217 | if (eqlIgnoreCase(ignore_case, name, "info")) | ||
| 218 | return true; | ||
| 219 | if (eqlIgnoreCase(ignore_case, name, "m")) | ||
| 220 | return true; | ||
| 221 | if (eqlIgnoreCase(ignore_case, name, "poll")) | ||
| 222 | return true; | ||
| 223 | if (eqlIgnoreCase(ignore_case, name, "proc")) | ||
| 224 | return true; | ||
| 225 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | ||
| 226 | return true; | ||
| 227 | if (eqlIgnoreCase(ignore_case, name, "rpcsvc")) | ||
| 228 | return true; | ||
| 229 | } | ||
| 230 | |||
| 231 | if (target.os.isAtLeast(.macos, .{ .major = 10, .minor = 8, .patch = 0 }) orelse false) { | ||
| 232 | if (eqlIgnoreCase(ignore_case, name, "mx")) | ||
| 233 | return true; | ||
| 234 | } | ||
| 235 | |||
| 236 | if (target.os.tag == .haiku) { | ||
| 237 | if (eqlIgnoreCase(ignore_case, name, "root")) | ||
| 238 | return true; | ||
| 239 | if (eqlIgnoreCase(ignore_case, name, "network")) | ||
| 240 | return true; | ||
| 241 | } | ||
| 242 | |||
| 243 | return false; | ||
| 244 | } | ||
| 245 | |||
| 246 | pub fn isLibCxxLibName(target: std.Target, name: []const u8) bool { | ||
| 247 | const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; | ||
| 248 | |||
| 249 | return eqlIgnoreCase(ignore_case, name, "c++") or | ||
| 250 | eqlIgnoreCase(ignore_case, name, "stdc++") or | ||
| 251 | eqlIgnoreCase(ignore_case, name, "c++abi"); | ||
| 252 | } | ||
| 253 | |||
| 254 | fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { | ||
| 255 | if (ignore_case) { | ||
| 256 | return std.ascii.eqlIgnoreCase(a, b); | ||
| 257 | } else { | ||
| 258 | return std.mem.eql(u8, a, b); | ||
| 259 | } | ||
| 260 | } | ||
| 261 | |||
| 127 | const std = @import("std"); | 262 | const std = @import("std"); |
src/Builtin.zig+1-1| ... | @@ -80,7 +80,7 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { | ... | @@ -80,7 +80,7 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void { |
| 80 | .{std.zig.fmtId(@tagName(target.os.tag))}, | 80 | .{std.zig.fmtId(@tagName(target.os.tag))}, |
| 81 | ); | 81 | ); |
| 82 | 82 | ||
| 83 | switch (target.os.getVersionRange()) { | 83 | switch (target.os.versionRange()) { |
| 84 | .none => try buffer.appendSlice(" .none = {} },\n"), | 84 | .none => try buffer.appendSlice(" .none = {} },\n"), |
| 85 | .semver => |semver| try buffer.writer().print( | 85 | .semver => |semver| try buffer.writer().print( |
| 86 | \\ .semver = .{{ | 86 | \\ .semver = .{{ |
src/Compilation.zig+2-2| ... | @@ -877,7 +877,7 @@ pub const cache_helpers = struct { | ... | @@ -877,7 +877,7 @@ pub const cache_helpers = struct { |
| 877 | hh.addBytes(target.cpu.model.name); | 877 | hh.addBytes(target.cpu.model.name); |
| 878 | hh.add(target.cpu.features.ints); | 878 | hh.add(target.cpu.features.ints); |
| 879 | hh.add(target.os.tag); | 879 | hh.add(target.os.tag); |
| 880 | hh.add(target.os.getVersionRange()); | 880 | hh.add(target.os.versionRange()); |
| 881 | hh.add(target.abi); | 881 | hh.add(target.abi); |
| 882 | hh.add(target.ofmt); | 882 | hh.add(target.ofmt); |
| 883 | hh.add(resolved_target.is_native_os); | 883 | hh.add(resolved_target.is_native_os); |
| ... | @@ -5412,7 +5412,7 @@ pub fn addCCArgs( | ... | @@ -5412,7 +5412,7 @@ pub fn addCCArgs( |
| 5412 | 5412 | ||
| 5413 | switch (ext) { | 5413 | switch (ext) { |
| 5414 | .c, .cpp, .m, .mm, .h, .hpp, .hm, .hmm, .cu, .rc, .assembly, .assembly_with_cpp => { | 5414 | .c, .cpp, .m, .mm, .h, .hpp, .hm, .hmm, .cu, .rc, .assembly, .assembly_with_cpp => { |
| 5415 | const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16); | 5415 | const minver: u16 = @truncate(@intFromEnum(target.os.versionRange().windows.min) >> 16); |
| 5416 | try argv.append( | 5416 | try argv.append( |
| 5417 | try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), | 5417 | try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), |
| 5418 | ); | 5418 | ); |
src/Sema.zig+2-2| ... | @@ -9606,7 +9606,7 @@ fn handleExternLibName( | ... | @@ -9606,7 +9606,7 @@ fn handleExternLibName( |
| 9606 | const comp = zcu.comp; | 9606 | const comp = zcu.comp; |
| 9607 | const target = zcu.getTarget(); | 9607 | const target = zcu.getTarget(); |
| 9608 | log.debug("extern fn symbol expected in lib '{s}'", .{lib_name}); | 9608 | log.debug("extern fn symbol expected in lib '{s}'", .{lib_name}); |
| 9609 | if (target.is_libc_lib_name(lib_name)) { | 9609 | if (std.zig.target.isLibCLibName(target, lib_name)) { |
| 9610 | if (!comp.config.link_libc) { | 9610 | if (!comp.config.link_libc) { |
| 9611 | return sema.fail( | 9611 | return sema.fail( |
| 9612 | block, | 9612 | block, |
| ... | @@ -9617,7 +9617,7 @@ fn handleExternLibName( | ... | @@ -9617,7 +9617,7 @@ fn handleExternLibName( |
| 9617 | } | 9617 | } |
| 9618 | break :blk; | 9618 | break :blk; |
| 9619 | } | 9619 | } |
| 9620 | if (target.is_libcpp_lib_name(lib_name)) { | 9620 | if (std.zig.target.isLibCxxLibName(target, lib_name)) { |
| 9621 | if (!comp.config.link_libcpp) return sema.fail( | 9621 | if (!comp.config.link_libcpp) return sema.fail( |
| 9622 | block, | 9622 | block, |
| 9623 | src_loc, | 9623 | src_loc, |
src/link/Elf.zig+1-3| ... | @@ -2045,9 +2045,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s | ... | @@ -2045,9 +2045,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s |
| 2045 | // copy when generating relocatables. Normally, we would expect `lld -r` to work. | 2045 | // copy when generating relocatables. Normally, we would expect `lld -r` to work. |
| 2046 | // However, because LLD wants to resolve BPF relocations which it shouldn't, it fails | 2046 | // However, because LLD wants to resolve BPF relocations which it shouldn't, it fails |
| 2047 | // before even generating the relocatable. | 2047 | // before even generating the relocatable. |
| 2048 | if (output_mode == .Obj and | 2048 | if (output_mode == .Obj and (comp.config.lto or target.cpu.arch.isBpf())) { |
| 2049 | (comp.config.lto or target.isBpfFreestanding())) | ||
| 2050 | { | ||
| 2051 | // In this case we must do a simple file copy | 2049 | // In this case we must do a simple file copy |
| 2052 | // here. TODO: think carefully about how we can avoid this redundant operation when doing | 2050 | // here. TODO: think carefully about how we can avoid this redundant operation when doing |
| 2053 | // build-obj. See also the corresponding TODO in linkAsArchive. | 2051 | // build-obj. See also the corresponding TODO in linkAsArchive. |
src/main.zig+2-2| ... | @@ -3765,11 +3765,11 @@ fn createModule( | ... | @@ -3765,11 +3765,11 @@ fn createModule( |
| 3765 | info: SystemLib, | 3765 | info: SystemLib, |
| 3766 | }) = .{}; | 3766 | }) = .{}; |
| 3767 | for (create_module.system_libs.keys(), create_module.system_libs.values()) |lib_name, info| { | 3767 | for (create_module.system_libs.keys(), create_module.system_libs.values()) |lib_name, info| { |
| 3768 | if (target.is_libc_lib_name(lib_name)) { | 3768 | if (std.zig.target.isLibCLibName(target, lib_name)) { |
| 3769 | create_module.opts.link_libc = true; | 3769 | create_module.opts.link_libc = true; |
| 3770 | continue; | 3770 | continue; |
| 3771 | } | 3771 | } |
| 3772 | if (target.is_libcpp_lib_name(lib_name)) { | 3772 | if (std.zig.target.isLibCxxLibName(target, lib_name)) { |
| 3773 | create_module.opts.link_libcpp = true; | 3773 | create_module.opts.link_libcpp = true; |
| 3774 | continue; | 3774 | continue; |
| 3775 | } | 3775 | } |