Skip to content

[libc][NFC] Add stdint.h proxy header to fix dependency issue with <stdint.h> includes. #150303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libc/benchmarks/gpu/BenchmarkLogger.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "benchmarks/gpu/BenchmarkLogger.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/OSUtil/io.h" // write_to_stderr
Expand All @@ -7,8 +8,6 @@
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
#include "src/__support/uint128.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace benchmarks {

Expand Down
1 change: 1 addition & 0 deletions libc/benchmarks/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_unittest_framework_library(
LibcGpuBenchmark.h
BenchmarkLogger.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.big_int
libc.src.__support.c_string
libc.src.__support.CPP.string
Expand Down
3 changes: 1 addition & 2 deletions libc/benchmarks/gpu/LibcGpuBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "benchmarks/gpu/BenchmarkLogger.h"
#include "benchmarks/gpu/timing/timing.h"
#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/functional.h"
#include "src/__support/CPP/limits.h"
Expand All @@ -13,8 +14,6 @@
#include "src/stdlib/rand.h"
#include "src/time/clock.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

namespace benchmarks {
Expand Down
2 changes: 2 additions & 0 deletions libc/benchmarks/gpu/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_benchmark(
SRCS
sin_benchmark.cpp
DEPENDS
libc.hdr.stdint_proxy
libc.src.math.sin
libc.src.math.sinf
libc.src.stdlib.srand
Expand All @@ -51,6 +52,7 @@ add_benchmark(
SRCS
atan2_benchmark.cpp
DEPENDS
libc.hdr.stdint_proxy
libc.src.math.atan2
libc.src.stdlib.srand
libc.src.stdlib.rand
Expand Down
3 changes: 2 additions & 1 deletion libc/benchmarks/gpu/src/math/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H
#define LLVM_LIBC_SRC_MATH_AMDGPU_PLATFORM_H

#include "hdr/stdint_proxy.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

Expand Down
1 change: 1 addition & 0 deletions libc/benchmarks/gpu/timing/amdgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_header_library(
HDRS
timing.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.common
libc.src.__support.macros.config
libc.src.__support.macros.attributes
Expand Down
3 changes: 1 addition & 2 deletions libc/benchmarks/gpu/timing/amdgpu/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_UTILS_GPU_TIMING_AMDGPU
#define LLVM_LIBC_UTILS_GPU_TIMING_AMDGPU

#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/atomic.h"
#include "src/__support/CPP/type_traits.h"
Expand All @@ -17,8 +18,6 @@
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

// Returns the overhead associated with calling the profiling region. This
Expand Down
1 change: 1 addition & 0 deletions libc/benchmarks/gpu/timing/nvptx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_header_library(
HDRS
timing.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.common
libc.src.__support.macros.config
libc.src.__support.macros.attributes
Expand Down
3 changes: 1 addition & 2 deletions libc/benchmarks/gpu/timing/nvptx/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_UTILS_GPU_TIMING_NVPTX
#define LLVM_LIBC_UTILS_GPU_TIMING_NVPTX

#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/array.h"
#include "src/__support/CPP/atomic.h"
#include "src/__support/CPP/type_traits.h"
Expand All @@ -17,8 +18,6 @@
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

// Returns the overhead associated with calling the profiling region. This
Expand Down
1 change: 1 addition & 0 deletions libc/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ add_header_library(
HDRS
app.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.common
)
3 changes: 1 addition & 2 deletions libc/config/gpu/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#ifndef LLVM_LIBC_CONFIG_GPU_APP_H
#define LLVM_LIBC_CONFIG_GPU_APP_H

#include "hdr/stdint_proxy.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

// TODO: Move other global values here and export them to the host.
Expand Down
3 changes: 1 addition & 2 deletions libc/config/linux/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#ifndef LLVM_LIBC_CONFIG_LINUX_APP_H
#define LLVM_LIBC_CONFIG_LINUX_APP_H

#include "hdr/stdint_proxy.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

// Data structure to capture properties of the linux/ELF TLS image.
Expand Down
3 changes: 1 addition & 2 deletions libc/config/uefi/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#ifndef LLVM_LIBC_CONFIG_UEFI_APP_H
#define LLVM_LIBC_CONFIG_UEFI_APP_H

#include "hdr/stdint_proxy.h"
#include "include/llvm-libc-types/EFI_HANDLE.h"
#include "include/llvm-libc-types/EFI_SYSTEM_TABLE.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {

// Data structure which captures properties of a UEFI application.
Expand Down
9 changes: 9 additions & 0 deletions libc/hdr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,14 @@ add_proxy_header_library(
libc.include.llvm-libc-macros.offsetof_macro
)

# stdint.h header.
add_proxy_header_library(
stdint_proxy
HDRS
stdint_proxy.h
FULL_BUILD_DEPENDS
libc.include.stdint
)

add_subdirectory(types)
add_subdirectory(func)
18 changes: 18 additions & 0 deletions libc/hdr/stdint_proxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- stdint.h ----------------------------------------------------------===//
//
// Part of the LLVM Project, 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_HDR_STDINT_PROXY_H
#define LLVM_LIBC_HDR_STDINT_PROXY_H

// This target is to make sure we have correct build order in full build mode,
// that is `libc.include.stdint` is added to the dependency of all targets
// that use <stdint.h> header.

#include <stdint.h>

#endif // LLVM_LIBC_HDR_STDINT_PROXY_H
2 changes: 2 additions & 0 deletions libc/hdr/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ add_proxy_header_library(
DEPENDS
libc.hdr.fcntl_overlay
FULL_BUILD_DEPENDS
libc.hdr.stdint_proxy
libc.include.llvm-libc-types.struct_flock
)

Expand All @@ -104,6 +105,7 @@ add_proxy_header_library(
DEPENDS
libc.hdr.fcntl_overlay
FULL_BUILD_DEPENDS
libc.hdr.stdint_proxy
libc.include.llvm-libc-types.struct_flock64
)

Expand Down
17 changes: 9 additions & 8 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ add_header_macro(
.llvm-libc-types.fexcept_t
)

add_header_macro(
stdint
../libc/include/stdint.yaml
stdint.h
DEPENDS
.llvm-libc-macros.stdint_macros
)

add_header_macro(
inttypes
../libc/include/inttypes.yaml
Expand All @@ -109,6 +117,7 @@ add_header_macro(
.llvm_libc_common_h
.llvm-libc-types.imaxdiv_t
.llvm-libc-macros.inttypes_macros
.stdint
)

add_header_macro(
Expand All @@ -119,14 +128,6 @@ add_header_macro(
.llvm-libc-macros.float_macros
)

add_header_macro(
stdint
../libc/include/stdint.yaml
stdint.h
DEPENDS
.llvm-libc-macros.stdint_macros
)

add_header_macro(
limits
../libc/include/limits.yaml
Expand Down
12 changes: 12 additions & 0 deletions libc/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_header_library(
HDRS
block.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.CPP.algorithm
libc.src.__support.CPP.limits
libc.src.__support.CPP.new
Expand Down Expand Up @@ -86,6 +87,7 @@ add_header_library(
blockstore.h
DEPENDS
.libc_assert
libc.hdr.stdint_proxy
libc.src.__support.CPP.new
)

Expand All @@ -97,6 +99,8 @@ add_header_library(
macros/properties/architectures.h
macros/attributes.h
macros/config.h
DEPENDS
libc.hdr.stdint_proxy
)

add_header_library(
Expand Down Expand Up @@ -199,6 +203,7 @@ add_header_library(
integer_to_string.h
DEPENDS
.big_int
libc.hdr.stdint_proxy
libc.src.__support.common
libc.src.__support.CPP.algorithm
libc.src.__support.CPP.limits
Expand All @@ -215,6 +220,7 @@ add_header_library(
ryu_long_double_constants.h
DEPENDS
.libc_assert
libc.hdr.stdint_proxy
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fp_bits
libc.src.__support.common
Expand All @@ -226,6 +232,7 @@ add_header_library(
high_precision_decimal.h
DEPENDS
.str_to_integer
libc.hdr.stdint_proxy
)

add_header_library(
Expand All @@ -240,6 +247,7 @@ add_header_library(
.str_to_num_result
.uint128
libc.hdr.errno_macros
libc.hdr.stdint_proxy
libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.limits
Expand All @@ -257,6 +265,7 @@ add_header_library(
integer_literals.h
DEPENDS
.uint128
libc.hdr.stdint_proxy
libc.src.__support.CPP.limits
)

Expand Down Expand Up @@ -290,6 +299,7 @@ add_header_library(
HDRS
arg_list.h
DEPENDS
libc.hdr.stdint_proxy
libc.src.__support.common
)

Expand Down Expand Up @@ -329,6 +339,7 @@ add_header_library(
DEPENDS
.math_extras
.number_pair
libc.hdr.stdint_proxy
libc.src.__support.CPP.array
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
Expand Down Expand Up @@ -361,6 +372,7 @@ add_header_library(
hash.h
DEPENDS
.uint128
libc.hdr.stdint_proxy
libc.src.__support.CPP.bit
libc.src.__support.CPP.limits
libc.src.__support.macros.attributes
Expand Down
3 changes: 3 additions & 0 deletions libc/src/__support/CPP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_header_library(
DEPENDS
.limits
.type_traits
libc.hdr.stdint_proxy
libc.src.__support.macros.attributes
libc.src.__support.macros.sanitizer
)
Expand All @@ -39,6 +40,8 @@ add_header_library(
functional
HDRS
functional.h
DEPENDS
libc.hdr.stdint_proxy
)

add_header_library(
Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/CPP/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
#define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H

#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/limits.h" // numeric_limits
#include "src/__support/CPP/type_traits.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/sanitizer.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace cpp {

Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/CPP/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_FUNCTIONAL_H
#define LLVM_LIBC_SRC___SUPPORT_CPP_FUNCTIONAL_H

#include "hdr/stdint_proxy.h"
#include "src/__support/CPP/type_traits/enable_if.h"
#include "src/__support/CPP/type_traits/is_convertible.h"
#include "src/__support/CPP/type_traits/is_same.h"
Expand All @@ -19,8 +20,6 @@
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"

#include <stdint.h>

namespace LIBC_NAMESPACE_DECL {
namespace cpp {

Expand Down
Loading
Loading