Skip to content
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

[libc][OSUtil] refactor quick_exit to be an object library everywhere #85955

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

nickdesaulniers
Copy link
Member

The usage of __builtin_unreachable after calls to quick_exit were distressing.
If a function is properly marked [[noreturn]] then __builtin_unreachable is not
necessary.

Looking into this further, we seem to have header only implementations for CPU
targets. The inline nature of these functions is curious; we're going to exit,
it doesn't matter if we need to pay the call of a function or not. If we just
make these functions have distinct TUs rather than be header only, we can clean
up the cmake rules for quick_exit which were different between CPU and GPU.

Remove darwin support for quick_exit. This isn't being tested, and we can bring
it back when necessary.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 20, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

The usage of __builtin_unreachable after calls to quick_exit were distressing.
If a function is properly marked [[noreturn]] then __builtin_unreachable is not
necessary.

Looking into this further, we seem to have header only implementations for CPU
targets. The inline nature of these functions is curious; we're going to exit,
it doesn't matter if we need to pay the call of a function or not. If we just
make these functions have distinct TUs rather than be header only, we can clean
up the cmake rules for quick_exit which were different between CPU and GPU.

Remove darwin support for quick_exit. This isn't being tested, and we can bring
it back when necessary.


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

14 Files Affected:

  • (modified) libc/src/__support/OSUtil/CMakeLists.txt (+7-20)
  • (modified) libc/src/__support/OSUtil/baremetal/CMakeLists.txt (+3-2)
  • (renamed) libc/src/__support/OSUtil/baremetal/quick_exit.cpp (+5-8)
  • (modified) libc/src/__support/OSUtil/darwin/CMakeLists.txt (-1)
  • (removed) libc/src/__support/OSUtil/darwin/quick_exit.h (-26)
  • (modified) libc/src/__support/OSUtil/gpu/CMakeLists.txt (-1)
  • (modified) libc/src/__support/OSUtil/gpu/quick_exit.cpp (+2-7)
  • (removed) libc/src/__support/OSUtil/gpu/quick_exit.h (-18)
  • (modified) libc/src/__support/OSUtil/linux/CMakeLists.txt (+3-2)
  • (removed) libc/src/__support/OSUtil/linux/quick_exit.h (-35)
  • (modified) libc/src/__support/OSUtil/quick_exit.h (+4-11)
  • (modified) libc/src/stdlib/CMakeLists.txt (+3-2)
  • (modified) libc/src/stdlib/_Exit.cpp (+1-2)
  • (modified) libc/src/stdlib/exit.cpp (+1-2)
diff --git a/libc/src/__support/OSUtil/CMakeLists.txt b/libc/src/__support/OSUtil/CMakeLists.txt
index ca3b3bf1263e0a..94d1042ccbb4a0 100644
--- a/libc/src/__support/OSUtil/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/CMakeLists.txt
@@ -8,23 +8,10 @@ if(NOT TARGET ${target_os_util})
   return()
 endif()
 
-# The OSUtil is an object library in GPU mode.
-if(NOT LIBC_TARGET_OS_IS_GPU)
-  add_header_library(
-    osutil
-    HDRS
-      io.h
-      quick_exit.h
-      syscall.h
-    DEPENDS
-      ${target_os_util}
-  )
-else()
-  add_object_library(
-    osutil
-    ALIAS
-      ${target_os_util}
-    DEPENDS
-      ${target_os_util}
-  )
-endif()
+add_object_library(
+  osutil
+  ALIAS
+    ${target_os_util}
+  DEPENDS
+    ${target_os_util}
+)
diff --git a/libc/src/__support/OSUtil/baremetal/CMakeLists.txt b/libc/src/__support/OSUtil/baremetal/CMakeLists.txt
index 280ff87cf1470d..23da40326bbb72 100644
--- a/libc/src/__support/OSUtil/baremetal/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/baremetal/CMakeLists.txt
@@ -1,8 +1,9 @@
-add_header_library(
+add_object_library(
   baremetal_util
+  SRCS
+    quick_exit.cpp
   HDRS
     io.h
-    quick_exit.h
   DEPENDS
     libc.src.__support.common
     libc.src.__support.CPP.string_view
diff --git a/libc/src/__support/OSUtil/baremetal/quick_exit.h b/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
similarity index 61%
rename from libc/src/__support/OSUtil/baremetal/quick_exit.h
rename to libc/src/__support/OSUtil/baremetal/quick_exit.cpp
index 74f9142e21b81e..f0971d4db352e0 100644
--- a/libc/src/__support/OSUtil/baremetal/quick_exit.h
+++ b/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
@@ -6,16 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_BAREMETAL_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_BAREMETAL_QUICK_EXIT_H
-
-namespace LIBC_NAMESPACE {
+#include "src/__support/OSUtil/quick_exit.h"
 
 // This is intended to be provided by the vendor.
-extern "C" void __llvm_libc_quick_exit(int status);
+[[noreturn]] extern "C" void __llvm_libc_quick_exit(int status);
 
-void quick_exit(int status) { __llvm_libc_quick_exit(status); }
+namespace LIBC_NAMESPACE {
 
-} // namespace LIBC_NAMESPACE
+[[noreturn]] void quick_exit(int status) { __llvm_libc_quick_exit(status); }
 
-#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_BAREMETAL_QUICK_EXIT_H
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/OSUtil/darwin/CMakeLists.txt b/libc/src/__support/OSUtil/darwin/CMakeLists.txt
index a3e6b93c8e9925..4241bb37684f7c 100644
--- a/libc/src/__support/OSUtil/darwin/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/darwin/CMakeLists.txt
@@ -8,7 +8,6 @@ add_header_library(
   darwin_util
   HDRS
     io.h
-    quick_exit.h
     syscall.h
   DEPENDS
     .${LIBC_TARGET_ARCHITECTURE}.darwin_util
diff --git a/libc/src/__support/OSUtil/darwin/quick_exit.h b/libc/src/__support/OSUtil/darwin/quick_exit.h
deleted file mode 100644
index 71647f50def5e2..00000000000000
--- a/libc/src/__support/OSUtil/darwin/quick_exit.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===--------- Darwin implementation of a quick exit function ---*- 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___SUPPORT_OSUTIL_DARWIN_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_DARWIN_QUICK_EXIT_H
-
-#include "syscall.h" // For internal syscall function.
-
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE {
-
-LIBC_INLINE void quick_exit(int status) {
-  for (;;) {
-    LIBC_NAMESPACE::syscall_impl<long>(1 /* SYS_exit */, status);
-  }
-}
-
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_DARWIN_QUICK_EXIT_H
diff --git a/libc/src/__support/OSUtil/gpu/CMakeLists.txt b/libc/src/__support/OSUtil/gpu/CMakeLists.txt
index 8e892a7000c9b3..0c89f9223678b1 100644
--- a/libc/src/__support/OSUtil/gpu/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/gpu/CMakeLists.txt
@@ -4,7 +4,6 @@ add_object_library(
     quick_exit.cpp
     io.cpp
   HDRS
-    quick_exit.h
     io.h
   DEPENDS
     libc.src.__support.common
diff --git a/libc/src/__support/OSUtil/gpu/quick_exit.cpp b/libc/src/__support/OSUtil/gpu/quick_exit.cpp
index 1a03be0ace6728..af4795905e7868 100644
--- a/libc/src/__support/OSUtil/gpu/quick_exit.cpp
+++ b/libc/src/__support/OSUtil/gpu/quick_exit.cpp
@@ -6,17 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
-
-#include "quick_exit.h"
+#include "src/__support/OSUtil/quick_exit.h"
 
 #include "src/__support/RPC/rpc_client.h"
 #include "src/__support/macros/properties/architectures.h"
 
 namespace LIBC_NAMESPACE {
 
-void quick_exit(int status) {
+[[noreturn]] void quick_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 *) {});
@@ -29,5 +26,3 @@ void quick_exit(int status) {
 }
 
 } // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
diff --git a/libc/src/__support/OSUtil/gpu/quick_exit.h b/libc/src/__support/OSUtil/gpu/quick_exit.h
deleted file mode 100644
index b51385defbc0de..00000000000000
--- a/libc/src/__support/OSUtil/gpu/quick_exit.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//===---------- GPU implementation of a quick exit function -----*- 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___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
-
-namespace LIBC_NAMESPACE {
-
-void quick_exit(int status);
-
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
diff --git a/libc/src/__support/OSUtil/linux/CMakeLists.txt b/libc/src/__support/OSUtil/linux/CMakeLists.txt
index c27f9be7464894..239d115704927b 100644
--- a/libc/src/__support/OSUtil/linux/CMakeLists.txt
+++ b/libc/src/__support/OSUtil/linux/CMakeLists.txt
@@ -4,11 +4,12 @@ endif()
 
 add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
 
-add_header_library(
+add_object_library(
   linux_util
+  SRCS
+    quick_exit.cpp
   HDRS
     io.h
-    quick_exit.h
     syscall.h
   DEPENDS
     .${LIBC_TARGET_ARCHITECTURE}.linux_${LIBC_TARGET_ARCHITECTURE}_util
diff --git a/libc/src/__support/OSUtil/linux/quick_exit.h b/libc/src/__support/OSUtil/linux/quick_exit.h
deleted file mode 100644
index 432395584d8467..00000000000000
--- a/libc/src/__support/OSUtil/linux/quick_exit.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===---------- Linux implementation of a quick exit function ---*- 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___SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
-#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
-
-#include "syscall.h" // For internal syscall function.
-
-#include "src/__support/common.h"
-
-#include <sys/syscall.h> // For syscall numbers.
-
-namespace LIBC_NAMESPACE {
-
-// 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
-LIBC_INLINE void
-quick_exit(int status) {
-  for (;;) {
-    LIBC_NAMESPACE::syscall_impl<long>(SYS_exit_group, status);
-    LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
-  }
-}
-
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_QUICK_EXIT_H
diff --git a/libc/src/__support/OSUtil/quick_exit.h b/libc/src/__support/OSUtil/quick_exit.h
index 6c59c1afcda254..e445917059c3e1 100644
--- a/libc/src/__support/OSUtil/quick_exit.h
+++ b/libc/src/__support/OSUtil/quick_exit.h
@@ -9,17 +9,10 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
 
-#include "src/__support/macros/properties/architectures.h"
+namespace LIBC_NAMESPACE {
 
-#if defined(LIBC_TARGET_ARCH_IS_GPU)
-#include "gpu/quick_exit.h"
-#elif defined(__APPLE__)
-#include "darwin/quick_exit.h"
-#elif defined(__linux__)
-#include "linux/quick_exit.h"
-#elif defined(__ELF__)
-// TODO: Ideally we would have LIBC_TARGET_OS_IS_BAREMETAL.
-#include "baremetal/quick_exit.h"
-#endif
+[[noreturn]] void quick_exit(int status);
+
+}
 
 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_QUICK_EXIT_H
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index bd0bcffe0045d1..71449f9bfc9d5f 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -372,10 +372,11 @@ add_entrypoint_object(
   CXX_STANDARD
     20 # For constinit of the atexit callback list.
   DEPENDS
-    libc.src.__support.fixedvector
+    libc.src.__support.CPP.new
+    libc.src.__support.OSUtil.osutil
     libc.src.__support.blockstore
+    libc.src.__support.fixedvector
     libc.src.__support.threads.mutex
-    libc.src.__support.CPP.new
 )
 
 add_entrypoint_object(
diff --git a/libc/src/stdlib/_Exit.cpp b/libc/src/stdlib/_Exit.cpp
index 85684d1e90879e..233af209739244 100644
--- a/libc/src/stdlib/_Exit.cpp
+++ b/libc/src/stdlib/_Exit.cpp
@@ -13,9 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LLVM_LIBC_FUNCTION(void, _Exit, (int status)) {
+[[noreturn]] LLVM_LIBC_FUNCTION(void, _Exit, (int status)) {
   quick_exit(status);
-  __builtin_unreachable();
 }
 
 } // namespace LIBC_NAMESPACE
diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp
index cc5ae6648d11f2..94cf2ae055fc30 100644
--- a/libc/src/stdlib/exit.cpp
+++ b/libc/src/stdlib/exit.cpp
@@ -16,10 +16,9 @@ namespace internal {
 void call_exit_callbacks();
 }
 
-LLVM_LIBC_FUNCTION(void, exit, (int status)) {
+[[noreturn]] LLVM_LIBC_FUNCTION(void, exit, (int status)) {
   internal::call_exit_callbacks();
   quick_exit(status);
-  __builtin_unreachable();
 }
 
 } // namespace LIBC_NAMESPACE

@nickdesaulniers nickdesaulniers marked this pull request as draft March 20, 2024 16:09
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

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

I think this is reasonable. Ideally the targets all depend on osutil correctly so we'll pull this in where needed.

Comment on lines -9 to -10
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder how these got here, probably some victim of copy paste.

Copy link
Member Author

Choose a reason for hiding this comment

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

it happens

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

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

I second the changes here.

Copy link

github-actions bot commented Mar 20, 2024

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

Comment on lines 18 to 21
__attribute__((no_stack_protector))
#endif
LIBC_INLINE void
quick_exit(int status) {
__attribute__((noreturn))
void quick_exit(int status) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any way we could use C++ [[]] syntax for these?

Copy link
Contributor

@jhuber6 jhuber6 Mar 20, 2024

Choose a reason for hiding this comment

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

I think [[clang::no_stack_protector]] or [[gnu::no_stack_protector]] should work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, [[gnu::no_stack_protector]] was added to clang on our request for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, adding attributes is fairly trivial, but unlike the GPU build we can't rely on an up-to-date compiler so I guess we'll just need to keep it as-is.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I hit an issue with having these be repeated as separate attribute expressions, but I think I know how to fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

done in 9ceeba4 PTAL

Copy link
Member Author

Choose a reason for hiding this comment

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

the issue was, clang errors if you mix GNU C __attribute__s with C23/C++20 [[]] attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

presubmit failure

-- The C compiler identification is Clang 16.0.6
llvm-project/github-pull-requests/libc/src/__support/OSUtil/linux/quick_exit.cpp:18:3: error: unknown attribute 'no_stack_protector' ignored [-Werror,-Wunknown-attributes]
[[gnu::no_stack_protector]]
^~~~~~~~~~~~~~~~~~~~~~~

So ironically, no_stack_protector was a function attribute in clang first, then GCC added support, then clang had to match the gnu:: prefix later. GCC does not recognize the clang:: attribute prefix. All the issues with compiler version compatibility are avoided by just using the GNU C extension syntax for attributes.

So I'm going to revert 9ceeba4.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, probably should've been more clear. This will work fine if you require runtimes builds of clang since it has the change, but not with the minimum clang version we support.

@nickdesaulniers
Copy link
Member Author

TODO: breaks bazel!

@nickdesaulniers nickdesaulniers marked this pull request as draft March 21, 2024 21:03
@nickdesaulniers nickdesaulniers marked this pull request as ready for review March 21, 2024 21:37
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Mar 21, 2024
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 once bazel is fixed.

The usage of __builtin_unreachable after calls to quick_exit were distressing.
If a function is properly marked [[noreturn]] then __builtin_unreachable is not
necessary.

Looking into this further, we seem to have header only implementations for CPU
targets. The inline nature of these functions is curious; we're going to exit,
it doesn't matter if we need to pay the call of a function or not. If we just
make these functions have distinct TUs rather than be header only, we can clean
up the cmake rules for quick_exit which were different between CPU and GPU.

Remove darwin support for quick_exit. This isn't being tested, and we can bring
it back when necessary.
Copy link

✅ With the latest revision this PR passed the Python code formatter.

@nickdesaulniers nickdesaulniers merged commit ecfffbf into llvm:main Mar 26, 2024
4 checks passed
@nickdesaulniers nickdesaulniers deleted the quick_exit branch March 26, 2024 15:27
@zeroomega
Copy link
Contributor

Hi this patch breaks runtimes-armv6m-unknown-eabi build with error message:

[58/398](61) Building CXX object libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj
FAILED: libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj 
/b/s/w/ir/x/w/llvm_build/./bin/clang++ --target=armv6m-unknown-eabi -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -I/b/s/w/ir/x/w/llvm-llvm-project/libc -isystem /b/s/w/ir/x/w/llvm_build/include/armv6m-unknown-eabi --target=armv6m-unknown-eabi -mcpu=cortex-m0plus -mthumb -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-armv6m-unknown-eabi-bins=../../../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O2 -g -DNDEBUG -std=gnu++17 -UNDEBUG --target=armv6m-unknown-eabi -fpie -ffreestanding -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -MD -MT libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj -MF libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj.d -o libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj -c /b/s/w/ir/x/w/llvm-llvm-project/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
/b/s/w/ir/x/w/llvm-llvm-project/libc/src/__support/OSUtil/baremetal/quick_exit.cpp:12:1: error: an attribute list cannot appear here
   12 | [[noreturn]] extern "C" void __llvm_libc_quick_exit(int status);
      | ^~~~~~~~~~~~
1 error generated.

Failed build: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8752376881927918433/overview
Full stdout: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8752376881927918433/+/u/clang/build/stdout
Could you revert the change, fix it and reland it please?

@jhuber6
Copy link
Contributor

jhuber6 commented Mar 26, 2024

[[noreturn]] extern "C" void __llvm_libc_quick_exit(int status);

This should be trivial to fix-forward instead of revert, see https://godbolt.org/z/zv9oqnrd9.

@jhuber6
Copy link
Contributor

jhuber6 commented Mar 26, 2024

Hi this patch breaks runtimes-armv6m-unknown-eabi build with error message:

[58/398](61) Building CXX object libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj
FAILED: libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj 
/b/s/w/ir/x/w/llvm_build/./bin/clang++ --target=armv6m-unknown-eabi -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -I/b/s/w/ir/x/w/llvm-llvm-project/libc -isystem /b/s/w/ir/x/w/llvm_build/include/armv6m-unknown-eabi --target=armv6m-unknown-eabi -mcpu=cortex-m0plus -mthumb -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build/runtimes/runtimes-armv6m-unknown-eabi-bins=../../../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O2 -g -DNDEBUG -std=gnu++17 -UNDEBUG --target=armv6m-unknown-eabi -fpie -ffreestanding -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -MD -MT libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj -MF libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj.d -o libc/src/__support/OSUtil/baremetal/CMakeFiles/libc.src.__support.OSUtil.baremetal.baremetal_util.dir/quick_exit.cpp.obj -c /b/s/w/ir/x/w/llvm-llvm-project/libc/src/__support/OSUtil/baremetal/quick_exit.cpp
/b/s/w/ir/x/w/llvm-llvm-project/libc/src/__support/OSUtil/baremetal/quick_exit.cpp:12:1: error: an attribute list cannot appear here
   12 | [[noreturn]] extern "C" void __llvm_libc_quick_exit(int status);
      | ^~~~~~~~~~~~
1 error generated.

Failed build: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8752376881927918433/overview Full stdout: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8752376881927918433/+/u/clang/build/stdout Could you revert the change, fix it and reland it please?

Let me know if 630283c fixes it.

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.

None yet

7 participants