public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 0/2] UnitTestFrameworkPkg: Fix Google Test components with multiple files
@ 2023-11-30 22:42 Pedro Falcato
  2023-11-30 22:42 ` [edk2-devel] [PATCH 1/2] " Pedro Falcato
  2023-11-30 22:42 ` [edk2-devel] [PATCH 2/2] UnitTestFrameworkPkg/Readme.md: Remove the mention of the gtest main() limitation Pedro Falcato
  0 siblings, 2 replies; 11+ messages in thread
From: Pedro Falcato @ 2023-11-30 22:42 UTC (permalink / raw)
  To: devel; +Cc: Pedro Falcato, Michael D Kinney, Michael Kubacki, Sean Brogan

Google Test hides test registration in global constructors on global
objects. Global constructors are traditionally implemented by placing
references to the global constructor's symbol in special sections
(traditionally named .ctors or .init_array). These sections are not
explicitly referenced by the linker, and libc only looks at special
start and end symbols (and calls them).

This works fine if you're linking a program manually using

    gcc a.o b.o c.o -o test_suite

but fails miserably when using static libraries (such as what EDK2
does), because traditional static archive symbol resolution rules don't
allow for object files to be pulled in to the link if there isn't an
undefined symbol reference to that .o elsewhere.

Fix it by passing --whole-archive (GCC) and /WHOLEARCHIVE (MSVC). These
options force the linker to pull in the entire static library, thus
including previously-unreferenced constructors and making sure
multi-file gtest EDK2 components work.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4610
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>

Pedro Falcato (2):
  UnitTestFrameworkPkg: Fix Google Test components with multiple files
  UnitTestFrameworkPkg/Readme.md: Remove the mention of the gtest main()
    limitation

 UnitTestFrameworkPkg/ReadMe.md                   | 16 ----------------
 .../UnitTestFrameworkPkgHost.dsc.inc             |  9 +++++++--
 2 files changed, 7 insertions(+), 18 deletions(-)

-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111915): https://edk2.groups.io/g/devel/message/111915
Mute This Topic: https://groups.io/mt/102904622/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-12-03 12:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-30 22:42 [edk2-devel] [PATCH 0/2] UnitTestFrameworkPkg: Fix Google Test components with multiple files Pedro Falcato
2023-11-30 22:42 ` [edk2-devel] [PATCH 1/2] " Pedro Falcato
2023-12-01 17:07   ` Michael Kubacki
2023-12-01 20:50     ` Pedro Falcato
     [not found]     ` <179CD05BE5E43398.18076@groups.io>
2023-12-01 20:52       ` Pedro Falcato
2023-12-01 21:28         ` Michael D Kinney
2023-12-03  0:34           ` Michael D Kinney
2023-12-03  2:37             ` Michael D Kinney
2023-12-03 12:11               ` Pedro Falcato
2023-11-30 22:42 ` [edk2-devel] [PATCH 2/2] UnitTestFrameworkPkg/Readme.md: Remove the mention of the gtest main() limitation Pedro Falcato
2023-12-01 17:10   ` Michael Kubacki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox