[AVR] Define __ELF__
authorAyke van Laethem <aykevanlaethem@gmail.com>
Tue, 14 Apr 2020 15:30:24 +0000 (17:30 +0200)
committerAyke van Laethem <aykevanlaethem@gmail.com>
Tue, 14 Apr 2020 22:22:53 +0000 (00:22 +0200)
This symbol is defined in avr-gcc. Because AVR normally uses the ELF
format, define the symbol unconditionally.

This patch is needed to get Clang to compile compiler-rt.

Differential Revision: https://reviews.llvm.org/D78117

clang/lib/Basic/Targets/AVR.cpp
clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c
clang/test/CodeGen/avr/target-cpu-defines/attiny104.c
clang/test/CodeGen/avr/target-cpu-defines/common.c

index d865676..bb215b4 100644 (file)
@@ -300,6 +300,7 @@ void AVRTargetInfo::getTargetDefines(const LangOptions &Opts,
   Builder.defineMacro("AVR");
   Builder.defineMacro("__AVR");
   Builder.defineMacro("__AVR__");
+  Builder.defineMacro("__ELF__");
 
   if (!this->CPU.empty()) {
     auto It = llvm::find_if(
index 83b0acc..29f8fa6 100644 (file)
@@ -5,3 +5,4 @@
 // CHECK: #define __AVR 1
 // CHECK: #define __AVR_ATmega328P__ 1
 // CHECK: #define __AVR__ 1
+// CHECK: #define __ELF__ 1
index 7de65bf..3f3d871 100644 (file)
@@ -5,3 +5,4 @@
 // CHECK: #define __AVR 1
 // CHECK: #define __AVR_ATtiny104__ 1
 // CHECK: #define __AVR__ 1
+// CHECK: #define __ELF__ 1
index 0b11f5d..3f93852 100644 (file)
@@ -4,3 +4,4 @@
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
 // CHECK: #define __AVR__ 1
+// CHECK: #define __ELF__ 1