Skip to content

Conversation

@SchrodingerZhu
Copy link
Contributor

Reverts #166355

@llvmbot llvmbot added the libc label Nov 14, 2025
@SchrodingerZhu
Copy link
Contributor Author

Direct merge since this is to restore a broken PR stacking

@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2025

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

Reverts llvm/llvm-project#166355


Full diff: https://github.com/llvm/llvm-project/pull/168102.diff

6 Files Affected:

  • (modified) libc/cmake/modules/LLVMLibCArchitectures.cmake (-31)
  • (modified) libc/include/sys/syscall.h.def (+1-2)
  • (modified) libc/test/UnitTest/ExecuteFunctionUnix.cpp (+3-1)
  • (modified) libc/test/src/stdlib/CMakeLists.txt (-13)
  • (modified) libc/test/src/stdlib/_Exit_test.cpp (+4)
  • (removed) libc/test/src/stdlib/exit_test.cpp (-15)
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 939fc1226a4e9..6c730f807de6d 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -215,37 +215,6 @@ else()
           "Unsupported libc target operating system ${LIBC_TARGET_OS}")
 endif()
 
-# If the compiler target triple is not the same as the triple specified by
-# LIBC_TARGET_TRIPLE or LLVM_RUNTIMES_TARGET, we will add a --target option
-# if the compiler is clang. If the compiler is GCC we just error out as there
-# is no equivalent of an option like --target.
-if(explicit_target_triple AND
-   (NOT (libc_compiler_triple STREQUAL explicit_target_triple)))
-  set(LIBC_CROSSBUILD TRUE)
-  if(CMAKE_COMPILER_IS_GNUCXX)
-    message(FATAL_ERROR
-            "GCC target triple (${libc_compiler_triple}) and the explicity "
-            "specified target triple (${explicit_target_triple}) do not match.")
-  else()
-    list(APPEND
-         LIBC_COMPILE_OPTIONS_DEFAULT "--target=${explicit_target_triple}")
-  endif()
-endif()
-
-if(LIBC_TARGET_OS_IS_DARWIN)
-  execute_process(
-    COMMAND xcrun --sdk macosx --show-sdk-path
-    OUTPUT_VARIABLE MACOSX_SDK_PATH
-    RESULT_VARIABLE MACOSX_SDK_PATH_RESULT
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-  )
-  if(MACOSX_SDK_PATH_RESULT EQUAL 0)
-    list(APPEND LIBC_COMPILE_OPTIONS_DEFAULT "-I" "${MACOSX_SDK_PATH}/usr/include")
-  else()
-    message(WARNING "Could not find macOS SDK path. `xcrun --sdk macosx --show-sdk-path` failed.")
-  endif()
-endif()
-
 # Windows does not support full mode build.
 if (LIBC_TARGET_OS_IS_WINDOWS AND LLVM_LIBC_FULL_BUILD)
   message(FATAL_ERROR "Windows does not support full mode build.")
diff --git a/libc/include/sys/syscall.h.def b/libc/include/sys/syscall.h.def
index f7e53cc4942d5..60e5024e500e3 100644
--- a/libc/include/sys/syscall.h.def
+++ b/libc/include/sys/syscall.h.def
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SYS_SYSCALL_H
 #define LLVM_LIBC_SYS_SYSCALL_H
 
-#if defined(__linux__)
+//TODO: Handle non-linux syscalls
 
 #include <asm/unistd.h>
 
@@ -2361,6 +2361,5 @@
 #define SYS_writev __NR_writev
 #endif
 
-#endif // __linux__
 
 #endif // LLVM_LIBC_SYS_SYSCALL_H
diff --git a/libc/test/UnitTest/ExecuteFunctionUnix.cpp b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
index ab18f7a2ebf52..c0e85c2144005 100644
--- a/libc/test/UnitTest/ExecuteFunctionUnix.cpp
+++ b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
@@ -57,7 +57,9 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, int timeout_ms) {
   }
   ::close(pipe_fds[1]);
 
-  pollfd poll_fd{pipe_fds[0], POLLIN, 0};
+  struct pollfd poll_fd {
+    pipe_fds[0], 0, 0
+  };
   // No events requested so this call will only return after the timeout or if
   // the pipes peer was closed, signaling the process exited.
   if (::poll(&poll_fd, 1, timeout_ms) == -1) {
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 80aab080e36d4..42e8faa3fd69f 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -398,19 +398,6 @@ if(LLVM_LIBC_FULL_BUILD)
       libc-stdlib-tests
     SRCS
       _Exit_test.cpp
-    DEPENDS
-      libc.src.__support.OSUtil.osutil
-      libc.src.stdlib._Exit
-  )
-
-  add_libc_test(
-    exit_test
-    # The EXPECT_EXITS test is only availible for unit tests.
-    UNIT_TEST_ONLY
-    SUITE
-      libc-stdlib-tests
-    SRCS
-      exit_test.cpp
     DEPENDS
       libc.src.stdlib._Exit
       libc.src.stdlib.exit
diff --git a/libc/test/src/stdlib/_Exit_test.cpp b/libc/test/src/stdlib/_Exit_test.cpp
index 57c432828c2f3..333277dc01dca 100644
--- a/libc/test/src/stdlib/_Exit_test.cpp
+++ b/libc/test/src/stdlib/_Exit_test.cpp
@@ -7,9 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/stdlib/_Exit.h"
+#include "src/stdlib/exit.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcStdlib, _Exit) {
   EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(1); }, 1);
   EXPECT_EXITS([] { LIBC_NAMESPACE::_Exit(65); }, 65);
+
+  EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
+  EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
 }
diff --git a/libc/test/src/stdlib/exit_test.cpp b/libc/test/src/stdlib/exit_test.cpp
deleted file mode 100644
index 5c82d8303036a..0000000000000
--- a/libc/test/src/stdlib/exit_test.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- Unittests for exit -----------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "src/stdlib/exit.h"
-#include "test/UnitTest/Test.h"
-
-TEST(LlvmLibcStdlib, exit) {
-  EXPECT_EXITS([] { LIBC_NAMESPACE::exit(1); }, 1);
-  EXPECT_EXITS([] { LIBC_NAMESPACE::exit(65); }, 65);
-}

@SchrodingerZhu SchrodingerZhu merged commit 5b798df into main Nov 14, 2025
16 of 21 checks passed
@SchrodingerZhu SchrodingerZhu deleted the revert-166355-exit_split branch November 14, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants