From 9353b8e0b88cd5237ebf274f0590766adc72cec7 Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Wed, 12 Jul 2023 10:51:24 +0200
Subject: [PATCH] [machdep] avoid warnings when generating AVR machdeps

turns out clang wants to have a specific CPU when using -target avr
---
 share/machdeps/machdep_avr_16.yaml | 5 +++++
 share/machdeps/machdep_avr_8.yaml  | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/share/machdeps/machdep_avr_16.yaml b/share/machdeps/machdep_avr_16.yaml
index f5ee3f6c848..055d78e85c3 100644
--- a/share/machdeps/machdep_avr_16.yaml
+++ b/share/machdeps/machdep_avr_16.yaml
@@ -16,6 +16,7 @@ cpp_arch_flags:
 - -target
 - avr
 - -m16
+- -mmcu=atmega16
 custom_defs: |
     #undef AVR
     #define AVR 1
@@ -33,6 +34,8 @@ custom_defs: |
     #define __ATOMIC_SEQ_CST 5
     #undef __AVR
     #define __AVR 1
+    #undef __AVR_ATmega16__
+    #define __AVR_ATmega16__ 1
     #undef __AVR__
     #define __AVR__ 1
     #undef __BIGGEST_ALIGNMENT__
@@ -645,6 +648,8 @@ custom_defs: |
     #define __clang_version__ "15.0.7 "
     #undef __clang_wide_literal_encoding__
     #define __clang_wide_literal_encoding__ "UTF-16"
+    #undef __flash
+    #define __flash __attribute__((address_space(1)))
     #undef __llvm__
     #define __llvm__ 1
 eof: (-1)
diff --git a/share/machdeps/machdep_avr_8.yaml b/share/machdeps/machdep_avr_8.yaml
index 9a9268a4d55..cbaeb67bbd3 100644
--- a/share/machdeps/machdep_avr_8.yaml
+++ b/share/machdeps/machdep_avr_8.yaml
@@ -15,6 +15,7 @@ compiler: clang
 cpp_arch_flags:
 - -target
 - avr
+- -mmcu=atmega8
 custom_defs: |
     #undef AVR
     #define AVR 1
@@ -32,6 +33,8 @@ custom_defs: |
     #define __ATOMIC_SEQ_CST 5
     #undef __AVR
     #define __AVR 1
+    #undef __AVR_ATmega8__
+    #define __AVR_ATmega8__ 1
     #undef __AVR__
     #define __AVR__ 1
     #undef __BIGGEST_ALIGNMENT__
@@ -644,6 +647,8 @@ custom_defs: |
     #define __clang_version__ "15.0.7 "
     #undef __clang_wide_literal_encoding__
     #define __clang_wide_literal_encoding__ "UTF-16"
+    #undef __flash
+    #define __flash __attribute__((address_space(1)))
     #undef __llvm__
     #define __llvm__ 1
 eof: (-1)
-- 
GitLab