[PATCH] D136712: Define _GNU_SOURCE for arm baremetal in C++ mode.

Manoj Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 13:56:06 PDT 2022


manojgupta updated this revision to Diff 470611.
manojgupta added a comment.

Removed c++ limitation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136712/new/

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-baremetal-defines.cpp


Index: clang/test/Driver/arm-baremetal-defines.cpp
===================================================================
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===================================================================
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -692,8 +692,10 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
       (getTriple().getEnvironment() == llvm::Triple::EABI ||
-       getTriple().getEnvironment() == llvm::Triple::EABIHF))
+       getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
     Builder.defineMacro("__ELF__");
+    Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136712.470611.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221025/1aa4802c/attachment.bin>


More information about the cfe-commits mailing list