Skip to content

[libc++][hardening] Don't use fputs on Fuchsia. #150558

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

Conversation

var-const
Copy link
Member

This is a quick fix for a build error on Fuchsia where many C standard
library filesystem-related functions are not available; it effectively
makes the hardening log function a no-op on Fuchsia.

Links:

This is a quick fix for a build error on Fuchsia where many C standard
library filesystem-related functions are not available; it effectively
makes the hardening log function a no-op on Fuchsia.

Links:
* llvm#149452 (comment)
* https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8708441153070837249/overview
@var-const var-const requested a review from a team as a code owner July 25, 2025 00:35
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 25, 2025
@var-const var-const requested a review from ldionne July 25, 2025 00:35
@var-const var-const added the hardening Issues related to the hardening effort label Jul 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2025

@llvm/pr-subscribers-libcxx

Author: Konstantin Varlamov (var-const)

Changes

This is a quick fix for a build error on Fuchsia where many C standard
library filesystem-related functions are not available; it effectively
makes the hardening log function a no-op on Fuchsia.

Links:


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

1 Files Affected:

  • (modified) libcxx/src/experimental/log_hardening_failure.cpp (+2)
diff --git a/libcxx/src/experimental/log_hardening_failure.cpp b/libcxx/src/experimental/log_hardening_failure.cpp
index f836c15452249..d385c706c8257 100644
--- a/libcxx/src/experimental/log_hardening_failure.cpp
+++ b/libcxx/src/experimental/log_hardening_failure.cpp
@@ -18,7 +18,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 void __log_hardening_failure(const char* message) noexcept {
   // Always log the message to `stderr` in case the platform-specific system calls fail.
+#ifndef __Fuchsia__ // `fputs` is not available on Fuchsia.
   std::fputs(message, stderr);
+#endif
 
 #if defined(__BIONIC__)
   // Show error in logcat. The latter two arguments are ignored on Android.

@var-const var-const closed this Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardening Issues related to the hardening effort libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants