| author | |
| committer | |
| log | 134e8cf76a6664ebd028fbcbfbd7a1b85ad031f5 |
| tree | deb0df7251742eb1415f3fa236780ace41304987 |
| parent | 1a3e0d6709cec285045ff95911a5b961151c8efe |
4 files changed, 94 insertions(+), 94 deletions(-)
lib/std/target.zig+90| ... | ... | @@ -2601,8 +2601,98 @@ pub const Target = struct { |
| 2601 | 2601 | }, |
| 2602 | 2602 | ); |
| 2603 | 2603 | } |
| 2604 | ||
| 2605 | pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool { | |
| 2606 | const ignore_case = target.os.tag == .macos or target.os.tag == .windows; | |
| 2607 | ||
| 2608 | if (eqlIgnoreCase(ignore_case, name, "c")) | |
| 2609 | return true; | |
| 2610 | ||
| 2611 | if (target.isMinGW()) { | |
| 2612 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 2613 | return true; | |
| 2614 | if (eqlIgnoreCase(ignore_case, name, "uuid")) | |
| 2615 | return true; | |
| 2616 | if (eqlIgnoreCase(ignore_case, name, "mingw32")) | |
| 2617 | return true; | |
| 2618 | if (eqlIgnoreCase(ignore_case, name, "msvcrt-os")) | |
| 2619 | return true; | |
| 2620 | if (eqlIgnoreCase(ignore_case, name, "mingwex")) | |
| 2621 | return true; | |
| 2622 | ||
| 2623 | return false; | |
| 2624 | } | |
| 2625 | ||
| 2626 | if (target.abi.isGnu() or target.abi.isMusl()) { | |
| 2627 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 2628 | return true; | |
| 2629 | if (eqlIgnoreCase(ignore_case, name, "rt")) | |
| 2630 | return true; | |
| 2631 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | |
| 2632 | return true; | |
| 2633 | if (eqlIgnoreCase(ignore_case, name, "util")) | |
| 2634 | return true; | |
| 2635 | if (eqlIgnoreCase(ignore_case, name, "xnet")) | |
| 2636 | return true; | |
| 2637 | if (eqlIgnoreCase(ignore_case, name, "resolv")) | |
| 2638 | return true; | |
| 2639 | if (eqlIgnoreCase(ignore_case, name, "dl")) | |
| 2640 | return true; | |
| 2641 | } | |
| 2642 | ||
| 2643 | if (target.abi.isMusl()) { | |
| 2644 | if (eqlIgnoreCase(ignore_case, name, "crypt")) | |
| 2645 | return true; | |
| 2646 | } | |
| 2647 | ||
| 2648 | if (target.os.tag.isDarwin()) { | |
| 2649 | if (eqlIgnoreCase(ignore_case, name, "System")) | |
| 2650 | return true; | |
| 2651 | if (eqlIgnoreCase(ignore_case, name, "c")) | |
| 2652 | return true; | |
| 2653 | if (eqlIgnoreCase(ignore_case, name, "dbm")) | |
| 2654 | return true; | |
| 2655 | if (eqlIgnoreCase(ignore_case, name, "dl")) | |
| 2656 | return true; | |
| 2657 | if (eqlIgnoreCase(ignore_case, name, "info")) | |
| 2658 | return true; | |
| 2659 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 2660 | return true; | |
| 2661 | if (eqlIgnoreCase(ignore_case, name, "poll")) | |
| 2662 | return true; | |
| 2663 | if (eqlIgnoreCase(ignore_case, name, "proc")) | |
| 2664 | return true; | |
| 2665 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | |
| 2666 | return true; | |
| 2667 | if (eqlIgnoreCase(ignore_case, name, "rpcsvc")) | |
| 2668 | return true; | |
| 2669 | } | |
| 2670 | ||
| 2671 | if (target.os.isAtLeast(.macos, .{ .major = 10, .minor = 8, .patch = 0 }) orelse false) { | |
| 2672 | if (eqlIgnoreCase(ignore_case, name, "mx")) | |
| 2673 | return true; | |
| 2674 | } | |
| 2675 | ||
| 2676 | return false; | |
| 2677 | } | |
| 2678 | ||
| 2679 | pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { | |
| 2680 | const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; | |
| 2681 | ||
| 2682 | return eqlIgnoreCase(ignore_case, name, "c++") or | |
| 2683 | eqlIgnoreCase(ignore_case, name, "stdc++") or | |
| 2684 | eqlIgnoreCase(ignore_case, name, "c++abi"); | |
| 2685 | } | |
| 2604 | 2686 | }; |
| 2605 | 2687 | |
| 2688 | fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { | |
| 2689 | if (ignore_case) { | |
| 2690 | return std.ascii.eqlIgnoreCase(a, b); | |
| 2691 | } else { | |
| 2692 | return std.mem.eql(u8, a, b); | |
| 2693 | } | |
| 2694 | } | |
| 2695 | ||
| 2606 | 2696 | test { |
| 2607 | 2697 | std.testing.refAllDecls(Target.Cpu.Arch); |
| 2608 | 2698 | } |
src/Sema.zig+2-2| ... | ... | @@ -9075,7 +9075,7 @@ fn handleExternLibName( |
| 9075 | 9075 | const comp = mod.comp; |
| 9076 | 9076 | const target = mod.getTarget(); |
| 9077 | 9077 | log.debug("extern fn symbol expected in lib '{s}'", .{lib_name}); |
| 9078 | if (target_util.is_libc_lib_name(target, lib_name)) { | |
| 9078 | if (target.is_libc_lib_name(lib_name)) { | |
| 9079 | 9079 | if (!comp.bin_file.options.link_libc) { |
| 9080 | 9080 | return sema.fail( |
| 9081 | 9081 | block, |
| ... | ... | @@ -9086,7 +9086,7 @@ fn handleExternLibName( |
| 9086 | 9086 | } |
| 9087 | 9087 | break :blk; |
| 9088 | 9088 | } |
| 9089 | if (target_util.is_libcpp_lib_name(target, lib_name)) { | |
| 9089 | if (target.is_libcpp_lib_name(lib_name)) { | |
| 9090 | 9090 | if (!comp.bin_file.options.link_libcpp) { |
| 9091 | 9091 | return sema.fail( |
| 9092 | 9092 | block, |
src/main.zig+2-2| ... | ... | @@ -2778,11 +2778,11 @@ fn buildOutputType( |
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | 2780 | for (system_libs.keys(), system_libs.values()) |lib_name, info| { |
| 2781 | if (target_util.is_libc_lib_name(target_info.target, lib_name)) { | |
| 2781 | if (target_info.target.is_libc_lib_name(lib_name)) { | |
| 2782 | 2782 | link_libc = true; |
| 2783 | 2783 | continue; |
| 2784 | 2784 | } |
| 2785 | if (target_util.is_libcpp_lib_name(target_info.target, lib_name)) { | |
| 2785 | if (target_info.target.is_libcpp_lib_name(lib_name)) { | |
| 2786 | 2786 | link_libcpp = true; |
| 2787 | 2787 | continue; |
| 2788 | 2788 | } |
src/target.zig-90| ... | ... | @@ -356,96 +356,6 @@ pub fn supportsReturnAddress(target: std.Target) bool { |
| 356 | 356 | }; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { | |
| 360 | if (ignore_case) { | |
| 361 | return std.ascii.eqlIgnoreCase(a, b); | |
| 362 | } else { | |
| 363 | return std.mem.eql(u8, a, b); | |
| 364 | } | |
| 365 | } | |
| 366 | ||
| 367 | pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool { | |
| 368 | const ignore_case = target.os.tag == .macos or target.os.tag == .windows; | |
| 369 | ||
| 370 | if (eqlIgnoreCase(ignore_case, name, "c")) | |
| 371 | return true; | |
| 372 | ||
| 373 | if (target.isMinGW()) { | |
| 374 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 375 | return true; | |
| 376 | if (eqlIgnoreCase(ignore_case, name, "uuid")) | |
| 377 | return true; | |
| 378 | if (eqlIgnoreCase(ignore_case, name, "mingw32")) | |
| 379 | return true; | |
| 380 | if (eqlIgnoreCase(ignore_case, name, "msvcrt-os")) | |
| 381 | return true; | |
| 382 | if (eqlIgnoreCase(ignore_case, name, "mingwex")) | |
| 383 | return true; | |
| 384 | ||
| 385 | return false; | |
| 386 | } | |
| 387 | ||
| 388 | if (target.abi.isGnu() or target.abi.isMusl()) { | |
| 389 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 390 | return true; | |
| 391 | if (eqlIgnoreCase(ignore_case, name, "rt")) | |
| 392 | return true; | |
| 393 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | |
| 394 | return true; | |
| 395 | if (eqlIgnoreCase(ignore_case, name, "util")) | |
| 396 | return true; | |
| 397 | if (eqlIgnoreCase(ignore_case, name, "xnet")) | |
| 398 | return true; | |
| 399 | if (eqlIgnoreCase(ignore_case, name, "resolv")) | |
| 400 | return true; | |
| 401 | if (eqlIgnoreCase(ignore_case, name, "dl")) | |
| 402 | return true; | |
| 403 | } | |
| 404 | ||
| 405 | if (target.abi.isMusl()) { | |
| 406 | if (eqlIgnoreCase(ignore_case, name, "crypt")) | |
| 407 | return true; | |
| 408 | } | |
| 409 | ||
| 410 | if (target.os.tag.isDarwin()) { | |
| 411 | if (eqlIgnoreCase(ignore_case, name, "System")) | |
| 412 | return true; | |
| 413 | if (eqlIgnoreCase(ignore_case, name, "c")) | |
| 414 | return true; | |
| 415 | if (eqlIgnoreCase(ignore_case, name, "dbm")) | |
| 416 | return true; | |
| 417 | if (eqlIgnoreCase(ignore_case, name, "dl")) | |
| 418 | return true; | |
| 419 | if (eqlIgnoreCase(ignore_case, name, "info")) | |
| 420 | return true; | |
| 421 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 422 | return true; | |
| 423 | if (eqlIgnoreCase(ignore_case, name, "poll")) | |
| 424 | return true; | |
| 425 | if (eqlIgnoreCase(ignore_case, name, "proc")) | |
| 426 | return true; | |
| 427 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | |
| 428 | return true; | |
| 429 | if (eqlIgnoreCase(ignore_case, name, "rpcsvc")) | |
| 430 | return true; | |
| 431 | } | |
| 432 | ||
| 433 | if (target.os.isAtLeast(.macos, .{ .major = 10, .minor = 8, .patch = 0 }) orelse false) { | |
| 434 | if (eqlIgnoreCase(ignore_case, name, "mx")) | |
| 435 | return true; | |
| 436 | } | |
| 437 | ||
| 438 | return false; | |
| 439 | } | |
| 440 | ||
| 441 | pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { | |
| 442 | const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; | |
| 443 | ||
| 444 | return eqlIgnoreCase(ignore_case, name, "c++") or | |
| 445 | eqlIgnoreCase(ignore_case, name, "stdc++") or | |
| 446 | eqlIgnoreCase(ignore_case, name, "c++abi"); | |
| 447 | } | |
| 448 | ||
| 449 | 359 | pub const CompilerRtClassification = enum { none, only_compiler_rt, only_libunwind, both }; |
| 450 | 360 | |
| 451 | 361 | pub fn classifyCompilerRtLibName(target: std.Target, name: []const u8) CompilerRtClassification { |