Merge "Revert "Also build the compile-time tests with _FORTIFY_SOURCE=3."" into main
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index ba68401..bb4916a 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -122,7 +122,11 @@
  * [malloc_usable_size(3)](https://man7.org/linux/man-pages/man3/malloc_usable_size.3.html)
  * returns the actual size of the given heap block.
  */
-__nodiscard size_t malloc_usable_size(const void* _Nullable __ptr);
+__nodiscard size_t malloc_usable_size(const void* _Nullable __ptr)
+#if defined(_FORTIFY_SOURCE)
+    __clang_error_if(_FORTIFY_SOURCE == 3, "malloc_usable_size() and _FORTIFY_SOURCE=3 are incompatible")
+#endif
+;
 
 #define __MALLINFO_BODY \
   /** Total number of non-mmapped bytes currently allocated from OS. */ \
diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp
index c0aa176..4defc5d 100644
--- a/tests/heap_tagging_level_test.cpp
+++ b/tests/heap_tagging_level_test.cpp
@@ -105,7 +105,7 @@
 
 TEST(heap_tagging_level, sync_async_bad_accesses_die) {
 #if defined(__BIONIC__) && defined(__aarch64__)
-  if (!mte_supported() || !running_with_mte()) {
+  if (!mte_supported() || !mte_enabled()) {
     GTEST_SKIP() << "requires MTE to be enabled";
   }
 
@@ -177,7 +177,7 @@
     EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
     EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_SYNC));
     EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_NONE));
-  } else if (mte_supported() && running_with_mte()) {
+  } else if (mte_supported() && mte_enabled()) {
     // ASYNC -> ...
     EXPECT_FALSE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_TBI));
     EXPECT_TRUE(SetHeapTaggingLevel(M_HEAP_TAGGING_LEVEL_ASYNC));
@@ -211,7 +211,7 @@
 #if defined(__BIONIC__) && defined(__aarch64__)
   // We can't test SYNC -> NONE in tagging_level_transitions because we can only make one transition
   // to NONE (which we use to test ASYNC -> NONE), so we test it here separately.
-  if (!mte_supported() || !running_with_mte()) {
+  if (!mte_supported() || !mte_enabled()) {
     GTEST_SKIP() << "requires MTE to be enabled";
   }
 
diff --git a/tests/memtag_stack_dlopen_test.cpp b/tests/memtag_stack_dlopen_test.cpp
index 68ddb81..eb69a62 100644
--- a/tests/memtag_stack_dlopen_test.cpp
+++ b/tests/memtag_stack_dlopen_test.cpp
@@ -38,9 +38,13 @@
 #include "mte_utils.h"
 #include "utils.h"
 
+#if defined(__BIONIC__)
+#include <bionic/mte.h>
+#endif
+
 TEST(MemtagStackDlopenTest, DependentBinaryGetsMemtagStack) {
 #if defined(__BIONIC__) && defined(__aarch64__)
-  if (!running_with_mte()) GTEST_SKIP() << "Test requires MTE.";
+  if (!mte_enabled()) GTEST_SKIP() << "Test requires MTE.";
   if (is_stack_mte_on())
     GTEST_SKIP() << "Stack MTE needs to be off for this test. Are you running fullmte?";
 
@@ -58,7 +62,7 @@
 
 TEST(MemtagStackDlopenTest, DependentBinaryGetsMemtagStack2) {
 #if defined(__BIONIC__) && defined(__aarch64__)
-  if (!running_with_mte()) GTEST_SKIP() << "Test requires MTE.";
+  if (!mte_enabled()) GTEST_SKIP() << "Test requires MTE.";
   if (is_stack_mte_on())
     GTEST_SKIP() << "Stack MTE needs to be off for this test. Are you running fullmte?";
 
@@ -77,7 +81,7 @@
 TEST(MemtagStackDlopenTest, DlopenRemapsStack) {
 #if defined(__BIONIC__) && defined(__aarch64__)
   // If this test is failing, look at crash logcat for why the test binary died.
-  if (!running_with_mte()) GTEST_SKIP() << "Test requires MTE.";
+  if (!mte_enabled()) GTEST_SKIP() << "Test requires MTE.";
   if (is_stack_mte_on())
     GTEST_SKIP() << "Stack MTE needs to be off for this test. Are you running fullmte?";
 
@@ -98,7 +102,7 @@
 TEST(MemtagStackDlopenTest, DlopenRemapsStack2) {
 #if defined(__BIONIC__) && defined(__aarch64__)
   // If this test is failing, look at crash logcat for why the test binary died.
-  if (!running_with_mte()) GTEST_SKIP() << "Test requires MTE.";
+  if (!mte_enabled()) GTEST_SKIP() << "Test requires MTE.";
   if (is_stack_mte_on())
     GTEST_SKIP() << "Stack MTE needs to be off for this test. Are you running fullmte?";
 
diff --git a/tests/mte_test.cpp b/tests/mte_test.cpp
index 5eb804f..67db820 100644
--- a/tests/mte_test.cpp
+++ b/tests/mte_test.cpp
@@ -39,7 +39,7 @@
 #endif
   }
 #if defined(__aarch64__)
-  if (mte_supported() && running_with_mte()) {
+  if (mte_supported() && mte_enabled()) {
     EXPECT_DEATH(
         {
           volatile int load ATTRIBUTE_UNUSED = *mistagged_p;