aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2024-01-15 13:25:59 +0100
committerGeorg-Johann Lay <avr@gjlay.de>2024-01-15 16:16:19 +0100
commit86fac7ee1688bdec245a43f6d2ab49fb238892e4 (patch)
tree7094e5fe2e753b36406620904de2ef421b3b5f7b
parent8414f10ad5bad6d522b72f9ae35e0bb86bb290ea (diff)
downloadgcc-86fac7ee1688bdec245a43f6d2ab49fb238892e4.zip
gcc-86fac7ee1688bdec245a43f6d2ab49fb238892e4.tar.gz
gcc-86fac7ee1688bdec245a43f6d2ab49fb238892e4.tar.bz2
AVR: target/107201: Make -nodevicelib work for all devices.
driver-avr.cc contains a spec that discriminates bwtween cores and devices by means of a mmcu=avr* spec pattern. This does not work for new devices like AVR128* which also start with mmcu=avr like all cores do. The patch uses a new spec function in order to tell apart cores from devices. gcc/ PR target/107201 * config/avr/avr.h (EXTRA_SPEC_FUNCTIONS): Add no-devlib, avr_no_devlib. * config/avr/driver-avr.cc (avr_no_devlib): New function. (avr_devicespecs_file): Use it to remove -nodevicelib from the options for cores only. * config/avr/avr-arch.h (avr_get_parch): New prototype. * config/avr/avr-devices.cc (avr_get_parch): New function.
-rw-r--r--gcc/config/avr/avr-arch.h1
-rw-r--r--gcc/config/avr/avr-devices.cc16
-rw-r--r--gcc/config/avr/avr.h2
-rw-r--r--gcc/config/avr/driver-avr.cc27
4 files changed, 43 insertions, 3 deletions
diff --git a/gcc/config/avr/avr-arch.h b/gcc/config/avr/avr-arch.h
index d0a297d..69e8db1 100644
--- a/gcc/config/avr/avr-arch.h
+++ b/gcc/config/avr/avr-arch.h
@@ -226,6 +226,7 @@ typedef struct
extern const avr_arch_t avr_arch_types[];
extern const avr_arch_t *avr_arch;
+extern const avr_arch_t *avr_get_parch (const char *mcu);
extern const avr_mcu_t avr_mcu_types[];
diff --git a/gcc/config/avr/avr-devices.cc b/gcc/config/avr/avr-devices.cc
index 90846f3..43d38eb 100644
--- a/gcc/config/avr/avr-devices.cc
+++ b/gcc/config/avr/avr-devices.cc
@@ -153,4 +153,20 @@ avr_inform_core_architectures (void)
free (archs);
}
+
+/* When MCU names a core arch like "avr5", then return a pointer to the
+ respective entry in avr_arch_types[]. Otherwise, return NULL. */
+
+const avr_arch_t *
+avr_get_parch (const char *mcu)
+{
+ for (size_t i = 0; i < ARRAY_SIZE (avr_arch_types); ++i)
+ {
+ if (strcmp (mcu, avr_arch_types[i].name) == 0)
+ return & avr_arch_types[i];
+ }
+
+ return NULL;
+}
+
#endif // IN_GEN_AVR_MMCU_TEXI
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 3ef60b9..7f7e231 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -500,9 +500,11 @@ typedef struct avr_args
extern const char *avr_devicespecs_file (int, const char**);
extern const char *avr_double_lib (int, const char**);
+extern const char *avr_no_devlib (int, const char**);
#define EXTRA_SPEC_FUNCTIONS \
{ "double-lib", avr_double_lib }, \
+ { "no-devlib", avr_no_devlib }, \
{ "device-specs-file", avr_devicespecs_file },
/* Driver self specs has lmited functionality w.r.t. '%s' for dynamic specs.
diff --git a/gcc/config/avr/driver-avr.cc b/gcc/config/avr/driver-avr.cc
index 2512c2c..727f7f0 100644
--- a/gcc/config/avr/driver-avr.cc
+++ b/gcc/config/avr/driver-avr.cc
@@ -103,9 +103,14 @@ avr_devicespecs_file (int argc, const char **argv)
}
return concat ("%{!nodevicespecs:-specs=device-specs", dir_separator_str,
- "specs-", mmcu, "%s} %<nodevicespecs"
+ "specs-", mmcu, "%s} %<nodevicespecs"
#if defined (WITH_AVRLIBC)
- " %{mmcu=avr*:" X_NODEVLIB "} %{!mmcu=*:" X_NODEVLIB "}",
+ // Return X_NODEVLIB when we are compiling for a core. As
+ // there are devices like AVR128DA32, a simple mmcu=avr* to
+ // discriminate between cores and devices ceased to work,
+ // hence use spec function no-devlib=avr_no_devlib from below.
+ // See also PR107201.
+ " %{mmcu=avr*:%:no-devlib(avr%*)} %{!mmcu=*:" X_NODEVLIB "}",
#else
" " X_NODEVLIB,
#endif
@@ -113,10 +118,26 @@ avr_devicespecs_file (int argc, const char **argv)
}
+/* Return X_NODEVLIB when ARGV[] contains a core like "avr5",
+ otherwise return "". */
+
+const char *
+avr_no_devlib (int argc, const char **argv)
+{
+ for (int i = 0; i < argc; ++i)
+ {
+ if (avr_get_parch (argv[i]))
+ return X_NODEVLIB;
+ }
+
+ return "";
+}
+
+
/* Re-build the -mdouble= and -mlong-double= options. This is needed
because these options are not independent of each other. */
-const char*
+const char *
avr_double_lib (int argc, const char **argv)
{
#if defined (WITH_DOUBLE64)