[libc-commits] [PATCH] D158193: [libc][NFC] Put definitions of stdout and friends into their own object files.

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Aug 17 09:31:32 PDT 2023


jhuber6 added a comment.

Here's a list of changes I had to make to get all tests passing with a local build, I use `glibc` version 2.37

  diff --git a/libc/test/src/__support/File/CMakeLists.txt b/libc/test/src/__support/File/CMakeLists.txt
  index 5ef8de1d6f7a..8b00427ae1ae 100644
  --- a/libc/test/src/__support/File/CMakeLists.txt
  +++ b/libc/test/src/__support/File/CMakeLists.txt
  @@ -34,6 +34,7 @@ foreach(target IN LISTS platform_file_targets)
           libc.src.__support.File.file
           libc.src.__support.File.${target}
           libc.include.stdio
  +      HERMETIC_TEST_ONLY
       )
     endif()
   endforeach()
  diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt
  index f29c21079959..ccdf778475ec 100644
  --- a/libc/test/src/stdio/CMakeLists.txt
  +++ b/libc/test/src/stdio/CMakeLists.txt
  @@ -151,75 +151,6 @@ else()
    set(fprintf_test_copts "-DLIBC_COPT_PRINTF_USE_SYSTEM_FILE")
   endif()
   
  -add_libc_unittest(
  -  fprintf_test
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    fprintf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.fprintf
  -    ${fprintf_test_deps}
  -  COMPILE_OPTIONS
  -    ${fprintf_test_copts}
  -)
  -
  -add_libc_unittest(
  -  printf_test
  -  ${hermetic_test_only}
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    printf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.printf
  -)
  -
  -add_fp_unittest(
  -  vsprintf_test
  -  UNIT_TEST_ONLY
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    vsprintf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.vsprintf
  -)
  -
  -add_libc_unittest(
  -  vsnprintf_test
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    vsnprintf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.vsnprintf
  -)
  -
  -add_libc_unittest(
  -  vfprintf_test
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    vfprintf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.vfprintf
  -    ${fprintf_test_deps}
  -  COMPILE_OPTIONS
  -    ${fprintf_test_copts}
  -)
  -
  -add_libc_unittest(
  -  vprintf_test
  -  ${hermetic_test_only}
  -  SUITE
  -    libc_stdio_unittests
  -  SRCS
  -    vprintf_test.cpp
  -  DEPENDS
  -    libc.src.stdio.vprintf
  -)
  -
   add_libc_unittest(
     fscanf_test
     SUITE
  diff --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt
  index ceee888669b7..ca2b1b05ba18 100644
  --- a/libc/test/src/unistd/CMakeLists.txt
  +++ b/libc/test/src/unistd/CMakeLists.txt
  @@ -429,16 +429,3 @@ add_libc_unittest(
       libc.include.unistd
       libc.src.unistd.sysconf
   )
  -
  -add_libc_unittest(
  -  getopt_test
  -  SUITE
  -    libc_unistd_unittests
  -  SRCS
  -    getopt_test.cpp
  -  DEPENDS
  -    libc.src.unistd.getopt
  -    libc.src.__support.CPP.array
  -    libc.src.stdio.fopencookie
  -    libc.src.stdio.fflush
  -)

The platform file tests need to be made hermetic as they link in the libc file handle which overrides it. The other tests that fail are all the `printf` variants and `getopt` weirdly enough. I think the common factor here is `fflush`? Since when I ran the debugger it seemed to crash somewhere in that call to the system libc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158193/new/

https://reviews.llvm.org/D158193



More information about the libc-commits mailing list