[PATCH] D136712: Define _GNU_SOURCE for arm baremetal in C++ mode.
Manoj Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 3 12:32:23 PDT 2022
manojgupta updated this revision to Diff 473004.
manojgupta added a comment.
Updated test.
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/Preprocessor/init-arm.c
Index: clang/test/Preprocessor/init-arm.c
===================================================================
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
// THUMB-MINGW:#define __ARM_DWARF_EH__ 1
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1
Index: clang/lib/Basic/Targets/ARM.cpp
===================================================================
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
// 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__");
+ if (Opts.CPlusPlus)
+ Builder.defineMacro("_GNU_SOURCE");
+ }
// Target properties.
Builder.defineMacro("__REGISTER_PREFIX__", "");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136712.473004.patch
Type: text/x-patch
Size: 1307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221103/72685828/attachment.bin>
More information about the cfe-commits
mailing list