Commit 7d8ee52
committed
fix(link): per-consumer archive-vs-inline for kind=lib deps (Windows LNK1561)
A pure-archive approach broke Windows: mcpp links via MSVC lld-link there, which
does NOT pull an archive member just to satisfy the entry point — so tests with
no own main (relying on gtest_main) failed with LNK1561 'entry point must be
defined'. (--start-lib isn't an option: Mach-O lld doesn't support it.)
Decide per consumer by scanning its entry source for a main definition:
- defines main → link the dep as an archive (member with main not pulled → no
duplicate main; entry comes from the test, fine on every linker)
- no main → inline the dep's objects directly, so the dep's gtest_main
-style entry object provides main on every linker incl. MSVC
Generic (only inspects the consumer, not which dep object holds main) and covers
all {own/framework main} × {uses/doesn't use gtest} combinations on Linux,
macOS and Windows. Also: dep archive now uses platform-aware naming.
Verified locally: e2e 78 green; nomain test inlines gtest_main.o, ownmain test
links libcompat_gtest.a.1 parent 95e43a3 commit 7d8ee52
2 files changed
Lines changed: 70 additions & 26 deletions
Lines changed: 35 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
88 | 99 | | |
89 | 100 | | |
90 | 101 | | |
91 | 102 | | |
92 | 103 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
98 | 113 | | |
99 | 114 | | |
100 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
546 | 553 | | |
547 | 554 | | |
548 | 555 | | |
| |||
580 | 587 | | |
581 | 588 | | |
582 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
583 | 602 | | |
584 | 603 | | |
585 | 604 | | |
| |||
619 | 638 | | |
620 | 639 | | |
621 | 640 | | |
622 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
623 | 648 | | |
624 | 649 | | |
625 | 650 | | |
| |||
629 | 654 | | |
630 | 655 | | |
631 | 656 | | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
637 | 666 | | |
638 | 667 | | |
639 | 668 | | |
| |||
0 commit comments