[llvm-branch-commits] [llvm] [libc][bazel] Use LLVM-libc startup objects in full-build tests (PR #219262)

Jackson Stogel via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 31 18:04:23 PDT 2026


https://github.com/jtstogel updated https://github.com/llvm/llvm-project/pull/219262

>From 0b0d3bb9ead00fd1a887e4f9b390a3713eba0b5b Mon Sep 17 00:00:00 2001
From: jtstogel <jtstogel at gmail.com>
Date: Tue, 18 Aug 2026 10:27:40 -0700
Subject: [PATCH] [libc][bazel] Use LLVM-libc startup objects in full-build
 tests

---
 .../libc/libc_build_rules.bzl                 |   1 +
 .../libc/test/BUILD.bazel                     |  21 +++
 .../libc/test/IntegrationTest/BUILD.bazel     |  25 +++
 .../libc/test/UnitTest/BUILD.bazel            |  39 ++++-
 .../libc/test/include/BUILD.bazel             | 150 +++++++++++-------
 .../libc/test/libc_test_rules.bzl             |  76 ++++++---
 .../libc/test/src/stdio/BUILD.bazel           |  41 ++++-
 .../libc/utils/MPCWrapper/BUILD.bazel         |   8 +-
 .../libc/utils/MPFRWrapper/BUILD.bazel        |   5 +-
 9 files changed, 276 insertions(+), 90 deletions(-)
 create mode 100644 utils/bazel/llvm-project-overlay/libc/test/IntegrationTest/BUILD.bazel

diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index 3b01e668b4aa2..7f02f8f64a68f 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -20,6 +20,7 @@ def libc_common_copts():
         "-DLIBC_NAMESPACE=" + LIBC_NAMESPACE,
     ] + select({
         Label(":full_build"): [
+            "-DLIBC_COPT_PUBLIC_PACKAGING",
             "-DLIBC_FULL_BUILD",
             "-ffreestanding",
             "-fno-asynchronous-unwind-tables",
diff --git a/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel
index c95c5711d8367..eb713d25a85b6 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel
@@ -3,6 +3,7 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 load("@bazel_skylib//rules:build_test.bzl", "build_test")
+load("@rules_cc//cc:defs.bzl", "cc_library")
 load("//libc:libc_build_rules.bzl", "libc_release_library")
 
 package(default_visibility = ["//visibility:public"])
@@ -27,3 +28,23 @@ build_test(
     name = "libc_release_build_test",
     targets = [":libc_release_test"],
 )
+
+# Dependencies that are injected into every hermetic libc_test.
+# These are grouped into their own cc_library instead of directly adding them
+# to the "deps" of each test rule to avoid hitting duplicate label errors.
+cc_library(
+    name = "hermetic_test_codegen_deps",
+    deps = select({
+        "//libc:full_build": [
+            "//libc:__stack_chk_fail",
+            "//libc:atexit",
+            "//libc:bcmp",
+            "//libc:bzero",
+            "//libc:memcmp",
+            "//libc:memcpy",
+            "//libc:memmove",
+            "//libc:memset",
+        ],
+        "//conditions:default": [],
+    }),
+)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/IntegrationTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/IntegrationTest/BUILD.bazel
new file mode 100644
index 0000000000000..06ae911555ca5
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libc/test/IntegrationTest/BUILD.bazel
@@ -0,0 +1,25 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# LLVM libc unittest library.
+
+load("//libc/test:libc_test_rules.bzl", "libc_test_library")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+libc_test_library(
+    name = "IntegrationTest",
+    srcs = ["test.cpp"],
+    hdrs = ["test.h"],
+    deps = [
+        "//libc:__support_common",
+        "//libc:__support_cpp_atomic",
+        "//libc:__support_macros_config",
+        "//libc:__support_macros_properties_architectures",
+        "//libc:__support_macros_properties_types",
+        "//libc:hdr_stdint_proxy",
+    ],
+)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
index e6223a394a776..02d8078f38b8a 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
@@ -38,7 +38,12 @@ libc_test_library(
         "LibcDeathTestExecutors.cpp",
         "LibcTest.cpp",
         "LibcTestMain.cpp",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "HermeticTestUtils.cpp",
+        ],
+        "//conditions:default": [],
+    }),
     hdrs = [
         "ErrnoCheckingTest.h",
         "ErrnoSetterMatcher.h",
@@ -49,6 +54,7 @@ libc_test_library(
     deps = [
         ":test_logger",
         "//libc:__support_c_string",
+        "//libc:__support_common",
         "//libc:__support_cpp_bit",
         "//libc:__support_cpp_bitset",
         "//libc:__support_cpp_limits",
@@ -76,8 +82,33 @@ libc_test_library(
         "//libc:func_realloc",
         "//libc:hdr_stdint_proxy",
         "//libc:llvm_libc_macros_stdfix_macros",
-        "//llvm:Support",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "//libc:access",
+            "//libc:clock",
+            "//libc:close",
+            "//libc:exit",
+            "//libc:fflush",
+            "//libc:fork",
+            "//libc:getenv",
+            "//libc:kill",
+            "//libc:llvm_libc_macros_poll_macros",
+            "//libc:llvm_libc_macros_signal_macros",
+            "//libc:llvm_libc_macros_sys_wait_macros",
+            "//libc:llvm_libc_types_pid_t",
+            "//libc:llvm_libc_types_struct_pollfd",
+            "//libc:pipe",
+            "//libc:poll",
+            "//libc:readlink",
+            "//libc:stderr",
+            "//libc:stdout",
+            "//libc:strsignal",
+            "//libc:symlink",
+            "//libc:unlink",
+            "//libc:waitpid",
+        ],
+        "//conditions:default": [],
+    }),
     # Force linking in this library's `main()` to surface
     # a duplicate symbol error if a test defines its own main.
     alwayslink = True,
@@ -89,7 +120,7 @@ libc_test_library(
     hdrs = ["LibcCTest.h"],
     deps = [
         ":LibcUnitTest",
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_common_h",
     ],
 )
 
diff --git a/utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel
index dcaf655c5b5c9..2236e85ede5eb 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/include/BUILD.bazel
@@ -13,15 +13,18 @@ licenses(["notice"])
 libc_test(
     name = "assert_test",
     srcs = ["assert_test.cpp"],
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_assert_macros",
+    ],
 )
 
 libc_test(
     name = "complex_test",
     srcs = ["complex_test.cpp"],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_complex_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -32,9 +35,9 @@ libc_test(
         "FpClassifyTest.h",
         "fpclassify_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -45,9 +48,9 @@ libc_test(
         "FpClassifyTest.h",
         "fpclassifyf_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -58,9 +61,9 @@ libc_test(
         "FpClassifyTest.h",
         "fpclassifyl_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -69,7 +72,10 @@ libc_test(
     name = "fpclassify_c_test",
     srcs = ["fpclassify_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -78,9 +84,9 @@ libc_test(
         "IsFiniteTest.h",
         "isfinite_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -91,9 +97,9 @@ libc_test(
         "IsFiniteTest.h",
         "isfinitef_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -104,9 +110,9 @@ libc_test(
         "IsFiniteTest.h",
         "isfinitel_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -115,7 +121,10 @@ libc_test(
     name = "isfinite_c_test",
     srcs = ["isfinite_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -124,9 +133,9 @@ libc_test(
         "IsInfTest.h",
         "isinf_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -137,9 +146,9 @@ libc_test(
         "IsInfTest.h",
         "isinff_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -150,9 +159,9 @@ libc_test(
         "IsInfTest.h",
         "isinfl_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -161,7 +170,10 @@ libc_test(
     name = "isinf_c_test",
     srcs = ["isinf_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -170,9 +182,9 @@ libc_test(
         "IsNanTest.h",
         "isnan_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -183,9 +195,9 @@ libc_test(
         "IsNanTest.h",
         "isnanf_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -196,9 +208,9 @@ libc_test(
         "IsNanTest.h",
         "isnanl_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -207,7 +219,10 @@ libc_test(
     name = "isnan_c_test",
     srcs = ["isnan_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -216,9 +231,9 @@ libc_test(
         "IsNormalTest.h",
         "isnormal_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -229,9 +244,9 @@ libc_test(
         "IsNormalTest.h",
         "isnormalf_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -242,9 +257,9 @@ libc_test(
         "IsNormalTest.h",
         "isnormall_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -253,14 +268,20 @@ libc_test(
     name = "isnormal_c_test",
     srcs = ["isnormal_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
     name = "issubnormal_c_test",
     srcs = ["issubnormal_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -269,9 +290,9 @@ libc_test(
         "IsZeroTest.h",
         "iszero_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -282,9 +303,9 @@ libc_test(
         "IsZeroTest.h",
         "iszerof_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -295,9 +316,9 @@ libc_test(
         "IsZeroTest.h",
         "iszerol_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -306,7 +327,10 @@ libc_test(
     name = "iszero_c_test",
     srcs = ["iszero_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
@@ -315,9 +339,9 @@ libc_test(
         "SignbitTest.h",
         "signbit_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -328,9 +352,9 @@ libc_test(
         "SignbitTest.h",
         "signbitf_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -341,9 +365,9 @@ libc_test(
         "SignbitTest.h",
         "signbitl_test.cpp",
     ],
-    full_build = True,
+    full_build_only = True,
     deps = [
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_math_function_macros",
         "//libc/test/UnitTest:fp_test_helpers",
     ],
 )
@@ -354,31 +378,39 @@ libc_test(
         "stdbit_stub.h",
         "stdbit_test.cpp",
     ],
-    full_build = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_common_h",
+        "//libc:llvm_libc_macros_stdbit_macros",
+    ],
 )
 
 libc_test(
     name = "signbit_c_test",
     srcs = ["signbit_test.c"],
     c_test = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_math_function_macros",
+    ],
 )
 
 libc_test(
     name = "stdckdint_test",
     srcs = ["stdckdint_test.cpp"],
-    full_build = True,
-    deps = ["//libc:public_headers_deps"],
+    full_build_only = True,
+    deps = [
+        "//libc:llvm_libc_macros_stdckdint_macros",
+    ],
 )
 
 libc_test(
     name = "sys_queue_test",
     srcs = ["sys/queue_test.cpp"],
-    full_build = True,
+    full_build_only = True,
     deps = [
         "//libc:__support_char_vector",
         "//libc:__support_cpp_string",
-        "//libc:public_headers_deps",
+        "//libc:llvm_libc_macros_sys_queue_macros",
     ],
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
index ab2f98d7c4e07..a135b32f7e0d2 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl
@@ -13,37 +13,39 @@ When performing tests we make sure to always use the internal version.
 """
 
 load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
-load("//libc:libc_build_rules.bzl", "libc_common_copts")
+load("//libc:libc_build_rules.bzl", "libc_common_copts", "libc_common_deps")
 load("//libc:libc_configure_options.bzl", "LIBC_CONFIGURE_OPTIONS")
 
-_FULL_BUILD_COPTS = [
-    "-nostdlib++",
-    "-nostdlib",
-    "-DLIBC_FULL_BUILD",
-    "-DLIBC_COPT_USE_C_ASSERT",
-]
-
-_TEST_DEFINES = ["LIBC_TEST_SUBPROCESS_TESTS=1"]
+_TEST_DEFINES = ["LIBC_TEST_SUBPROCESS_TESTS=1"] + select({
+    "//libc:full_build": ["TARGET_SUPPORTS_CLOCK"],
+    "//conditions:default": [],
+})
 
 def libc_test(
         name,
+        srcs = [],
         copts = [],
         deps = [],
         local_defines = [],
+        linkopts = [],
         c_test = False,
-        full_build = False,
+        full_build_only = False,
+        target_compatible_with = [],
+        tags = [],
         **kwargs):
     """Add target for a libc test.
 
     Args:
       name: Test target name
+      srcs: The list of sources for this test.
       copts: The list of options to add to the C++ compilation command.
       deps: The list of libc functions and libraries to be linked in.
       local_defines: The list of target local_defines if any.
+      linkopts: Link options for the cc_test.
       c_test: Whether this test is a C unit test (uses LibcCTest).
-      full_build: Whether to compile with LIBC_FULL_BUILD and disallow
-          use of system headers. This is useful for tests that include both
-          LLVM libc headers and proxy headers to avoid conflicting definitions.
+      full_build_only: Whether the test should only be run in full-build mode.
+      target_compatible_with: Constraints the target is compatible with.
+      tags: Tags for the cc_test.
       **kwargs: Attributes relevant for a cc_test.
     """
     deps = deps + [
@@ -55,34 +57,67 @@ def libc_test(
         "//libc:func_free",
         "//libc:func_malloc",
         "//libc:func_realloc",
-    ]
+    ] + select({
+        "//libc:full_build": [
+            # Required by crt1.o. These would usually be provided by libc.a.
+            "//libc:_r_debug",
+            "//libc:environ",
+            "//libc:program_invocation_name",
+            "//libc:program_invocation_short_name",
+
+            # Required by the hermetic test fixture or compiler codegen.
+            "//libc/test:hermetic_test_codegen_deps",
+        ],
+        "//conditions:default": [],
+    })
+
     if c_test:
         deps = deps + ["//libc/test/UnitTest:LibcCTest"]
     else:
         deps = deps + ["//libc/test/UnitTest:LibcUnitTest"]
 
-    tags = kwargs.pop("tags", [])
-    if full_build:
-        copts = copts + _FULL_BUILD_COPTS
+    linkopts = linkopts + select({
+        "//libc:full_build": [
+            "-nolibc",
+            "-nostartfiles",
+            "-nostdlib++",
+            "-static",
+            "-Wl,-z,muldefs",
+        ],
+        "//conditions:default": [],
+    })
 
-        # Temporarily disable full_build tests (currently broken) to unblock CI.
+    if full_build_only:
+        target_compatible_with = target_compatible_with + select({
+            "//libc:full_build": [],
+            "//conditions:default": ["@platforms//:incompatible"],
+        })
         tags = tags + ["manual", "nobuildkite", "notap"]
+
     cc_test(
         name = name,
+        srcs = srcs + select({
+            "//libc:full_build": [
+                "//libc/startup/linux:crt1",
+            ],
+            "//conditions:default": [],
+        }),
         local_defines = local_defines + _TEST_DEFINES + LIBC_CONFIGURE_OPTIONS,
-        deps = deps,
+        deps = deps + libc_common_deps(),
         copts = copts + libc_common_copts(),
+        linkopts = linkopts,
         linkstatic = 1,
         tags = tags,
         **kwargs
     )
 
-def libc_test_library(name, copts = [], local_defines = [], **kwargs):
+def libc_test_library(name, copts = [], deps = [], local_defines = [], **kwargs):
     """Add target for library used in libc tests.
 
     Args:
       name: Library target name.
       copts: See cc_library.copts.
+      deps: See cc_library.deps.
       local_defines: See cc_library.local_defines.
       **kwargs: Other attributes relevant to cc_library (e.g. "deps").
     """
@@ -90,6 +125,7 @@ def libc_test_library(name, copts = [], local_defines = [], **kwargs):
         name = name,
         testonly = True,
         copts = copts + libc_common_copts(),
+        deps = deps + libc_common_deps(),
         local_defines = local_defines + _TEST_DEFINES + LIBC_CONFIGURE_OPTIONS,
         linkstatic = 1,
         **kwargs
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
index 2c54fc3726591..fa58ac8da2ac4 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel
@@ -56,7 +56,15 @@ libc_test(
         "//libc:__support_cpp_limits",
         "//libc:__support_macros_properties_architectures",
         "//libc:fprintf",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "//libc:fclose",
+            "//libc:ferror",
+            "//libc:fopen",
+            "//libc:fread",
+        ],
+        "//conditions:default": [],
+    }),
 )
 
 libc_test(
@@ -97,7 +105,15 @@ libc_test(
     srcs = ["vfprintf_test.cpp"],
     deps = [
         "//libc:vfprintf",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "//libc:fclose",
+            "//libc:ferror",
+            "//libc:fopen",
+            "//libc:fread",
+        ],
+        "//conditions:default": [],
+    }),
 )
 
 libc_test(
@@ -132,7 +148,16 @@ libc_test(
         "//libc:__support_cpp_string_view",
         "//libc:fscanf",
         "//libc:hdr_stdio_macros",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "//libc:fclose",
+            "//libc:feof",
+            "//libc:ferror",
+            "//libc:fopen",
+            "//libc:fwrite",
+        ],
+        "//conditions:default": [],
+    }),
 )
 
 libc_test(
@@ -149,5 +174,13 @@ libc_test(
     deps = [
         "//libc:__support_cpp_string_view",
         "//libc:vfscanf",
-    ],
+    ] + select({
+        "//libc:full_build": [
+            "//libc:fclose",
+            "//libc:ferror",
+            "//libc:fopen",
+            "//libc:fwrite",
+        ],
+        "//conditions:default": [],
+    }),
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPCWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPCWrapper/BUILD.bazel
index dc08a96e7474f..4132d4533205c 100644
--- a/utils/bazel/llvm-project-overlay/libc/utils/MPCWrapper/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/utils/MPCWrapper/BUILD.bazel
@@ -15,8 +15,11 @@ cc_library(
     name = "mpc_impl",
     hdrs = ["mpc_inc.h"],
     target_compatible_with = select({
-        "//conditions:default": [],
         "//libc:mpc_disable": ["@platforms//:incompatible"],
+        # In full build mode, the MPFR library should be built
+        # using our own facilities, which is currently not possible.
+        "//libc:full_build": ["@platforms//:incompatible"],
+        "//conditions:default": [],
     }),
     deps = select(
         {
@@ -39,8 +42,9 @@ libc_test_library(
         },
     ),
     target_compatible_with = select({
-        "//conditions:default": [],
         "//libc:mpc_disable": ["@platforms//:incompatible"],
+        "//libc:full_build": ["@platforms//:incompatible"],
+        "//conditions:default": [],
     }),
     deps = [
         ":mpc_impl",
diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
index 2593fae4d432b..5968046d4b0e0 100644
--- a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
@@ -15,8 +15,11 @@ cc_library(
     name = "mpfr_impl",
     hdrs = ["mpfr_inc.h"],
     target_compatible_with = select({
-        "//conditions:default": [],
         "//libc:mpfr_disable": ["@platforms//:incompatible"],
+        # In full build mode, the MPFR library should be built
+        # using our own facilities, which is currently not possible.
+        "//libc:full_build": ["@platforms//:incompatible"],
+        "//conditions:default": [],
     }),
     deps = select(
         {



More information about the llvm-branch-commits mailing list