diff options
author | Pedro Falcato <pedro.falcato@gmail.com> | 2023-11-30 14:42:13 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-12-03 02:37:26 +0000 |
commit | c3769e392b9293d8fdd124665f12b08c704e5952 (patch) | |
tree | 7f56ca711b7f49157d6b33026282d8d354873ab4 /.gitignore | |
parent | 70b174e24db4a6de1590fda65846074dcb9fd7d3 (diff) | |
download | edk2-c3769e392b9293d8fdd124665f12b08c704e5952.zip edk2-c3769e392b9293d8fdd124665f12b08c704e5952.tar.gz edk2-c3769e392b9293d8fdd124665f12b08c704e5952.tar.bz2 |
UnitTestFrameworkPkg: Fix Google Test components with multiple files
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4610
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.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Reviewed-by: Cc: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions