Skip to content

[libc] implement quick exit function #93621

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

Closed
wants to merge 7 commits into from

Conversation

aaryanshukla
Copy link
Contributor

Implementing the quick exit function.

Implementing the quick exit function.
@nickdesaulniers nickdesaulniers self-requested a review May 28, 2024 23:01
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented May 28, 2024

@llvm/pr-subscribers-libc

Author: None (aaryanshukla)

Changes

Implementing the quick exit function.


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

18 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/spec/stdc.td (+2)
  • (renamed) libc/src/__support/OSUtil/baremetal/exit.cpp (+6-2)
  • (renamed) libc/src/__support/OSUtil/exit.h (+6-3)
  • (renamed) libc/src/__support/OSUtil/gpu/exit.cpp (+5-2)
  • (modified) libc/src/__support/OSUtil/linux/CMakeLists.txt (+1-1)
  • (renamed) libc/src/__support/OSUtil/linux/exit.cpp (+6-1)
  • (modified) libc/src/__support/libc_assert.h (+2-2)
  • (modified) libc/src/stdlib/CMakeLists.txt (+14-2)
  • (modified) libc/src/stdlib/_Exit.cpp (+2-2)
  • (modified) libc/src/stdlib/exit.cpp (+2-2)
  • (added) libc/src/stdlib/quick_exit.cpp (+25)
  • (added) libc/src/stdlib/quick_exit.h (+20)
  • (modified) libc/src/unistd/_exit.cpp (+2-2)
  • (modified) libc/test/IntegrationTest/test.h (+5-5)
  • (modified) libc/test/src/stdlib/CMakeLists.txt (+17)
  • (added) libc/test/src/stdlib/quick_exit_test.cpp (+17)
  • (modified) libc/utils/HdrGen/Main.cpp (+1)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5e3ddd34fb4dc..b6ead64e208c7 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -730,6 +730,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.stdlib.abort
     libc.src.stdlib.atexit
     libc.src.stdlib.exit
+    libc.src.stdlib.quick_exit
     libc.src.stdlib.getenv
 
     # signal.h entrypoints
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index eb67c9b0b009b..20a95b6aae385 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -1071,6 +1071,8 @@ def StdC : StandardSpec<"stdc"> {
           FunctionSpec<"_Exit", RetValSpec<NoReturn>, [ArgSpec<IntType>]>,
           FunctionSpec<"exit", RetValSpec<NoReturn>, [ArgSpec<IntType>]>,
           FunctionSpec<"atexit", RetValSpec<IntType>, [ArgSpec<AtexitHandlerT>]>,
+          FunctionSpec<"quick_exit", RetValSpec<NoReturn>, [ArgSpec<IntType>]>,
+
       ]
   >;
 
diff --git a/libc/src/__support/OSUtil/baremetal/quick_exit.cpp b/libc/src/__support/OSUtil/baremetal/exit.cpp
similarity index 80%
rename from libc/src/__support/OSUtil/baremetal/quick_exit.cpp
rename to libc/src/__support/OSUtil/baremetal/exit.cpp
index 5b6fcf42341eb..c77e21ae6602d 100644
--- a/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
+++ b/libc/src/__support/OSUtil/baremetal/exit.cpp
@@ -6,13 +6,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 
 // This is intended to be provided by the vendor.
 extern "C" [[noreturn]] void __llvm_libc_quick_exit(int status);
 
 namespace LIBC_NAMESPACE {
+namespace internal {
 
-[[noreturn]] void quick_exit(int status) { __llvm_libc_quick_exit(status); }
+[[noreturn]] void exit(int status) { __llvm_libc_quick_exit(status); }
+
+
+}
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/OSUtil/quick_exit.h b/libc/src/__support/OSUtil/exit.h
similarity index 75%
rename from libc/src/__support/OSUtil/quick_exit.h
rename to libc/src/__support/OSUtil/exit.h
index e445917059c3e..5bd967ecf8777 100644
--- a/libc/src/__support/OSUtil/quick_exit.h
+++ b/libc/src/__support/OSUtil/exit.h
@@ -6,12 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_EXIT_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_EXIT_H
 
 namespace LIBC_NAMESPACE {
+namespace internal {
 
-[[noreturn]] void quick_exit(int status);
+[[noreturn]] void exit(int status);
+
+}
 
 }
 
diff --git a/libc/src/__support/OSUtil/gpu/quick_exit.cpp b/libc/src/__support/OSUtil/gpu/exit.cpp
similarity index 89%
rename from libc/src/__support/OSUtil/gpu/quick_exit.cpp
rename to libc/src/__support/OSUtil/gpu/exit.cpp
index af4795905e786..e9744a69650a4 100644
--- a/libc/src/__support/OSUtil/gpu/quick_exit.cpp
+++ b/libc/src/__support/OSUtil/gpu/exit.cpp
@@ -6,14 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 
 #include "src/__support/RPC/rpc_client.h"
 #include "src/__support/macros/properties/architectures.h"
 
 namespace LIBC_NAMESPACE {
+namespace internal {
 
-[[noreturn]] void quick_exit(int status) {
+[[noreturn]] void exit(int status) {
   // We want to first make sure the server is listening before we exit.
   rpc::Client::Port port = rpc::client.open<RPC_EXIT>();
   port.send_and_recv([](rpc::Buffer *) {}, [](rpc::Buffer *) {});
@@ -25,4 +26,6 @@ namespace LIBC_NAMESPACE {
   gpu::end_program();
 }
 
+
+}
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt
index 239d115704927..9a55232d532fe 100644
--- a/libc/src/__support/OSUtil/linux/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt
@@ -7,7 +7,7 @@ add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
 add_object_library(
   linux_util
   SRCS
-    quick_exit.cpp
+    exit.cpp
   HDRS
     io.h
     syscall.h
diff --git a/libc/src/__support/OSUtil/linux/quick_exit.cpp b/libc/src/__support/OSUtil/linux/exit.cpp
similarity index 95%
rename from libc/src/__support/OSUtil/linux/quick_exit.cpp
rename to libc/src/__support/OSUtil/linux/exit.cpp
index 51b3231d389f2..8dccfc22f3799 100644
--- a/libc/src/__support/OSUtil/linux/quick_exit.cpp
+++ b/libc/src/__support/OSUtil/linux/exit.cpp
@@ -11,6 +11,8 @@
 #include <sys/syscall.h> // For syscall numbers.
 
 namespace LIBC_NAMESPACE {
+namespace internal {
+
 
 // mark as no_stack_protector for x86 since TLS can be torn down before calling
 // quick_exit so that the stack protector canary cannot be loaded.
@@ -18,11 +20,14 @@ namespace LIBC_NAMESPACE {
 __attribute__((no_stack_protector))
 #endif
 __attribute__((noreturn)) void
-quick_exit(int status) {
+exit(int status) {
   for (;;) {
     LIBC_NAMESPACE::syscall_impl<long>(SYS_exit_group, status);
     LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
   }
 }
 
+
+}
+
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index 61f075435b552..ca04e7024964c 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -21,7 +21,7 @@
 #else // Not LIBC_COPT_USE_C_ASSERT
 
 #include "src/__support/OSUtil/io.h"
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 #include "src/__support/integer_to_string.h"
 #include "src/__support/macros/attributes.h" // For LIBC_INLINE
 
@@ -76,7 +76,7 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
                                                "' in function: '");            \
       LIBC_NAMESPACE::write_to_stderr(__PRETTY_FUNCTION__);                    \
       LIBC_NAMESPACE::write_to_stderr("'\n");                                  \
-      LIBC_NAMESPACE::quick_exit(0xFF);                                        \
+      LIBC_NAMESPACE::internal::exit(0xFF);                                        \
     }                                                                          \
   } while (false)
 #endif // NDEBUG
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 9b76a6a0f8575..ef74ca4fd0e70 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -2,6 +2,7 @@ add_entrypoint_object(
   atoi
   SRCS
     atoi.cpp
+    quick_exit.cpp
   HDRS
     atoi.h
   DEPENDS
@@ -13,8 +14,7 @@ add_entrypoint_object(
   atof
   SRCS
     atof.cpp
-  HDRS
-    atof.h
+      atof.h
   DEPENDS
     libc.src.errno.errno
     libc.src.__support.str_to_float
@@ -432,6 +432,18 @@ add_entrypoint_object(
     ._Exit
     .atexit
     libc.src.__support.OSUtil.osutil
+
+)
+
+add_entrypoint_object(
+  quick_exit
+  SRCS
+    quick_exit.cpp
+  HDRS
+    quick_exit.h
+  DEPENDS
+    libc.src.errno.errno
+    
 )
 
 add_entrypoint_object(
diff --git a/libc/src/stdlib/_Exit.cpp b/libc/src/stdlib/_Exit.cpp
index 233af20973924..03a766261014e 100644
--- a/libc/src/stdlib/_Exit.cpp
+++ b/libc/src/stdlib/_Exit.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 #include "src/__support/common.h"
 
 #include "src/stdlib/_Exit.h"
@@ -14,7 +14,7 @@
 namespace LIBC_NAMESPACE {
 
 [[noreturn]] LLVM_LIBC_FUNCTION(void, _Exit, (int status)) {
-  quick_exit(status);
+  internal::exit(status);
 }
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp
index ba87bffaeb541..1f7ccbb556607 100644
--- a/libc/src/stdlib/exit.cpp
+++ b/libc/src/stdlib/exit.cpp
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/stdlib/exit.h"
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 #include "src/__support/common.h"
 
 extern "C" void __cxa_finalize(void *);
@@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE {
 
 [[noreturn]] LLVM_LIBC_FUNCTION(void, exit, (int status)) {
   __cxa_finalize(nullptr);
-  quick_exit(status);
+  internal::exit(status);
 }
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/stdlib/quick_exit.cpp b/libc/src/stdlib/quick_exit.cpp
new file mode 100644
index 0000000000000..5b14683a0d956
--- /dev/null
+++ b/libc/src/stdlib/quick_exit.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of quick_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/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
+#include "src/__support/common.h"
+
+//extern "C" void __cxa_finalize(void *);
+
+namespace LIBC_NAMESPACE {
+
+[[noreturn]] LLVM_LIBC_FUNCTION(void, quick_exit, (int status)) {
+  //__cxa_finalize(nullptr);
+  exit(status);
+}
+
+
+}
+ // namespace LIBC_NAMESPACE
+
diff --git a/libc/src/stdlib/quick_exit.h b/libc/src/stdlib/quick_exit.h
new file mode 100644
index 0000000000000..1ebf689e1868e
--- /dev/null
+++ b/libc/src/stdlib/quick_exit.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for quick_exit -------------------*- C++ -*-===//
+//
+// 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_SRC_STDLIB_QUICK_EXIT_H
+#define LLVM_LIBC_SRC_STDLIB_QUICK_EXIT_H
+
+#include <stdlib.h>
+
+namespace LIBC_NAMESPACE {
+
+[[noreturn]] void quick_exit(int status);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_STDLIB_QUICK_EXIT_H
diff --git a/libc/src/unistd/_exit.cpp b/libc/src/unistd/_exit.cpp
index 6fbf3a51d42f4..4b652a2c13fd1 100644
--- a/libc/src/unistd/_exit.cpp
+++ b/libc/src/unistd/_exit.cpp
@@ -7,13 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/unistd/_exit.h"
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 #include "src/__support/common.h"
 
 namespace LIBC_NAMESPACE {
 
 [[noreturn]] LLVM_LIBC_FUNCTION(void, _exit, (int status)) {
-  quick_exit(status);
+  internal::exit(status);
 }
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 64906ef179391..14e6f22f0ee67 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_UTILS_INTEGRATION_TEST_TEST_H
 
 #include "src/__support/OSUtil/io.h"
-#include "src/__support/OSUtil/quick_exit.h"
+#include "src/__support/OSUtil/exit.h"
 
 #define __AS_STRING(val) #val
 #define __CHECK_TRUE(file, line, val, should_exit)                             \
@@ -18,7 +18,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val "' to be true, but is false\n");             \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::quick_exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                         \
   }
 
 #define __CHECK_FALSE(file, line, val, should_exit)                            \
@@ -26,7 +26,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val "' to be false, but is true\n");             \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::quick_exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                         \
   }
 
 #define __CHECK_EQ(file, line, val1, val2, should_exit)                        \
@@ -34,7 +34,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val1 "' to be equal to '" #val2 "'\n");          \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::quick_exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                         \
   }
 
 #define __CHECK_NE(file, line, val1, val2, should_exit)                        \
@@ -42,7 +42,7 @@
     LIBC_NAMESPACE::write_to_stderr(file ":" __AS_STRING(                      \
         line) ": Expected '" #val1 "' to not be equal to '" #val2 "'\n");      \
     if (should_exit)                                                           \
-      LIBC_NAMESPACE::quick_exit(127);                                         \
+      LIBC_NAMESPACE::internal::exit(127);                                         \
   }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 28c5b566cc477..e07e8b651322e 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -324,6 +324,23 @@ add_libc_test(
     libc.src.stdlib.srand
 )
 
+add_libc_test(
+    quick_exit_test
+    # The EXPECT_EXITS test is only availible for unit tests.
+    UNIT_TEST_ONLY
+    SUITE
+      libc-stdlib-tests
+    SRCS
+      quick_exit_test.cpp
+    DEPENDS
+      libc.include.stdlib
+      libc.src.stdlib._Exit
+      libc.src.stdlib.quick_exit
+      libc.src.stdlib.atexit
+      libc.src.__support.CPP.array
+      libc.src.__support.CPP.utility
+  )
+
 if(LLVM_LIBC_FULL_BUILD)
 
   add_libc_test(
diff --git a/libc/test/src/stdlib/quick_exit_test.cpp b/libc/test/src/stdlib/quick_exit_test.cpp
new file mode 100644
index 0000000000000..8ed878a11575b
--- /dev/null
+++ b/libc/test/src/stdlib/quick_exit_test.cpp
@@ -0,0 +1,17 @@
+//===-- Unittests for quick_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/quick_exit.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdlib.h>
+
+TEST(LlvmLibcStdlib, quick_exit) {
+  EXPECT_EXITS([] { LIBC_NAMESPACE::quick_exit(1); }, 1);
+  EXPECT_EXITS([] { LIBC_NAMESPACE::quick_exit(65); }, 65);
+}
diff --git a/libc/utils/HdrGen/Main.cpp b/libc/utils/HdrGen/Main.cpp
index d3418f206b10e..92269dd70ae19 100644
--- a/libc/utils/HdrGen/Main.cpp
+++ b/libc/utils/HdrGen/Main.cpp
@@ -65,3 +65,4 @@ int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv);
   return TableGenMain(argv[0], &llvm_libc::HeaderGeneratorMain);
 }
+

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Balance the backslash at line 79

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did LIBC_NAMESPACE::internal, and on the last line I made the comment // namespace LIBC_NAMESPACE::internal, but I think either works

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I found in review:

@@ -11,18 +11,23 @@
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use LIBC_NAMESPACE::internal instead of two namespace declarations

Copy link

github-actions bot commented May 29, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

fixed line spacing, max text per line, and unnecesary code that was
moved/deleted.
- some files had lines go over 80 pieces of text
- added missing dependencies on quick exit
- reverted some unnecesary changes made to the make files
- fixed the order of include files to met clang formatting rules.
RoseZhang03

This comment was marked as outdated.

@aaryanshukla aaryanshukla marked this pull request as ready for review May 29, 2024 22:52
Comment on lines 20 to 22
if (should_exit)

LIBC_NAMESPACE::internal::exit(127);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting looks wrong here.

@@ -10,19 +10,18 @@
#include "syscall.h" // For internal syscall function.
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE {
namespace LIBC_NAMESPACE::internal {

// mark as no_stack_protector for x86 since TLS can be torn down before calling
// quick_exit so that the stack protector canary cannot be loaded.
#ifdef LIBC_TARGET_ARCH_IS_X86
__attribute__((no_stack_protector))
#endif
__attribute__((noreturn)) void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one probably should be changed to [[noreturn]] to match others.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was an issue with [[]] notation for multiple attributes, IIRC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping ((noreturn)) the same for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://godbolt.org/z/rhYeP3vjM which part doesn't work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, then perhaps I misremember. Sorry for not just checking it myself!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using [[gnu:: instead should work for gcc: https://godbolt.org/z/6dbrc6cY6

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang doesn't recognize [[gnu::

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, interesting, turns out it is supported since clang 18: https://godbolt.org/z/G1srfsWen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have put a comment there. 🤣

This is the third time ppl get confused.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, interesting, turns out it is supported since clang 18: https://godbolt.org/z/G1srfsWen

Because we filed a issue just for this place.

added no_stack_proctector and noreturn brackets.
removed unnecesary stdlib.h files.
fixed line formatting for test.h files.
put internal in front of the calling for exit.
changed all areas from quick_exit to exit in build.BAZEL.
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label May 30, 2024
modified quick_exit to exit in cmakefiles.
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -1,18 +1,21 @@
//===----- Baremetal implementation of a quick exit function ----*- C++ -*-===//
//===----- Baremetal implementation of an exit function ----*- C++ -*-===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: align the length of this line.

@michaelrj-google
Copy link
Contributor

Superseded by #93620

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel libc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants