[llvm-branch-commits] [libc] [libc][test] Build LibcFPTestHelpers in full-build mode (PR #205237)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jun 22 19:06:40 PDT 2026


https://github.com/jofrn created https://github.com/llvm/llvm-project/pull/205237

In a full build the unit framework is built in overlay mode while the tests use LIBC_FULL_BUILD, so FEnvSafeTest's fenv_t member differs in size (16 vs 8 bytes on Darwin) -- an ODR violation that crashes math smoke tests. Add a UNIT_AS_FULL_BUILD opt-in and use it for the hermetic LibcFPTestHelpers.

>From 501cdd29bc8d458940ca970504ee6b2eec765c34 Mon Sep 17 00:00:00 2001
From: jofrn <jo7frn1 at gmail.com>
Date: Sat, 20 Jun 2026 23:56:38 -0700
Subject: [PATCH] [libc][test] Build LibcFPTestHelpers in full-build mode

In a full build the unit framework is built in overlay mode while the tests
use LIBC_FULL_BUILD, so FEnvSafeTest's fenv_t member differs in size (16 vs
8 bytes on Darwin) -- an ODR violation that crashes math smoke tests. Add a
UNIT_AS_FULL_BUILD opt-in and use it for the hermetic LibcFPTestHelpers.
---
 libc/test/UnitTest/CMakeLists.txt | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index aa245b2234793..235583198cd00 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -1,7 +1,7 @@
 function(add_unittest_framework_library name)
   cmake_parse_arguments(
     "TEST_LIB"
-    "" # No optional arguments
+    "UNIT_AS_FULL_BUILD" # Optional arguments
     "" # No single value arguments
     "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS" # Multi value arguments
     ${ARGN}
@@ -25,9 +25,13 @@ function(add_unittest_framework_library name)
     endif()
   endforeach()
 
-  if(LLVM_LIBC_FULL_BUILD)
+  if(LLVM_LIBC_FULL_BUILD AND NOT TEST_LIB_UNIT_AS_FULL_BUILD)
     # TODO: Build test framework with LIBC_FULL_BUILD in full build mode after
     # making LibcFPExceptionHelpers and LibcDeathTestExecutors hermetic.
+    # Libraries that opt in with UNIT_AS_FULL_BUILD are hermetic and are built in
+    # full-build mode so their layout matches the full-build tests that link
+    # them (e.g. the fenv_t-sized member in FEnvSafeTest, whose size differs
+    # between libc's fenv_t and the system one on some targets such as Darwin).
     set(LLVM_LIBC_FULL_BUILD "")
     _get_common_test_compile_options(compile_options "" "")
     set(LLVM_LIBC_FULL_BUILD ON)
@@ -131,6 +135,7 @@ add_header_library(
 
 add_unittest_framework_library(
   LibcFPTestHelpers
+  UNIT_AS_FULL_BUILD
   SRCS
     FEnvSafeTest.cpp
     RoundingModeUtils.cpp



More information about the llvm-branch-commits mailing list