diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2015-03-10 09:50:41 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2015-03-10 09:50:41 +0000 |
commit | 4a2caf6ced93a63e1703870ed67385d3f89da474 (patch) | |
tree | fa8390902e4ef79ccff88b2c2384679848448dc0 /gcc/config/avr/driver-avr.c | |
parent | 768fbdd49e8535486ea71eebc507c3b813521a1b (diff) | |
download | gcc-4a2caf6ced93a63e1703870ed67385d3f89da474.zip gcc-4a2caf6ced93a63e1703870ed67385d3f89da474.tar.gz gcc-4a2caf6ced93a63e1703870ed67385d3f89da474.tar.bz2 |
re PR target/65296 ([avr] fix various issues with specs file generation)
PR target/65296
* config.gcc (extra_options) [avr]: Remove.
(extra_gcc_objs) [avr]: Use driver-avr.o, avr-devices.o.
(tm_file) [avr]: Add avr/specs.h after avr/avr.h.
(tm_defines) [avr-*-rtems*]: Add WITH_RTEMS.
* config/avr/avr.opt (config/avr/avr-arch.h): Remove include.
(-mmcu=): Add Var and MissingArgError properties.
(-march=): Remove.
* config/avr/genmultilib.awk: Use -mmcu= instead of -march=.
* config/avr/t-multilib: Regenerate.
* config/avr/specs.h: New file.
* config/avr/driver-avr.c: New file.
* config/avr/genopt.sh: Remove file.
* config/avr/avr-tables.opt: Remove file.
* config/avr/predicates.md (avr_current_arch): Rename to avr_arch.
* config/avr/avr-c.c: Same.
* avr-arch.h: Same.
(avr_current_device): Remove proto.
* config/avr/avr.h (avr_current_arch): Rename to avr_arch.
(AVR_HAVE_8BIT_SP): Don't depend on avr_current_device.
(EXTRA_SPEC_FUNCTIONS): Define.
(avr_devicespecs_file): New specs function proto.
(DRIVER_SELF_SPECS): Use device-specs-file spec function.
* config/avr/avr.c (avr_current_arch): Rename to avr_arch.
(avr_current_device): Remove definition and usage.
(avr_set_core_architecture): New static function.
(avr_option_override): Use it.
* config/avr/avr-devices.c (diagnostic.h, avr-arch.h): Include them.
(mcu_name): New static array.
(comparator, avr_archs_str, avr_mcus_str): New static functions.
(avr_inform_devices, avr_inform_core_architectures): New functions.
* config/avr/gen-avr-mmcu-specs.c (avr-arch.h, specs.h): Include.
(avrlibc.h) [WITH_AVRLIBC]: Include.
(../rtems.h, rtems.h) [WITH_RTEMS]: Include.
(print_mcu): Rewrite from scratch.
* config/avr/avrlibc.h (LIB_SPEC, LIBGCC_SPEC, STARTFILE_SPEC):
Forward to avr-specific specs defined in device-specs file.
* config/avr/t-avr (driver-avr.o): New rule.
(avr-devices.o): Depend on avr-arch.h.
(avr-mcus): No more depend on avr-tables.opt.
(avr-tables.opt): Remove rule.
(install-device-specs): Use INSTALL_DATA, not INSTALL_PROGRAM.
From-SVN: r221316
Diffstat (limited to 'gcc/config/avr/driver-avr.c')
-rw-r--r-- | gcc/config/avr/driver-avr.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/gcc/config/avr/driver-avr.c b/gcc/config/avr/driver-avr.c new file mode 100644 index 0000000..4b39910 --- /dev/null +++ b/gcc/config/avr/driver-avr.c @@ -0,0 +1,124 @@ +/* Subroutines for the gcc driver. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + Contributed by Georg-Johann Lay <avr@gjlay.de> + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "diagnostic.h" +#include "tm.h" + +static const char dir_separator_str[] = { DIR_SEPARATOR, 0 }; + +static const char specfiles_doc_url[] = + "http://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html"; + + +static const char* +avr_diagnose_devicespecs_error (const char *mcu, const char *filename) +{ + error ("cannot access device-specs for %qs expected at %qs", + mcu, filename); + + // Inform about natively supported devices and cores. + + if (strncmp (mcu, "avr", strlen ("avr"))) + avr_inform_devices (); + + avr_inform_core_architectures (); + + inform (input_location, "you can provide your own specs files, " + "see <%s> for details", specfiles_doc_url); + + return ""; +} + + +/* Implement spec function `device-specs-fileĀ“. + + Compose -specs=<specs-file-name>. If everything went well then argv[0] + is the inflated specs directory and argv[1] is a device or core name as + supplied to -mmcu=*. */ + +const char* +avr_devicespecs_file (int argc, const char **argv) +{ + char *specfile_name; + const char *mmcu = NULL; + +#ifdef DEBUG_SPECS + if (verbose_flag) + fnotice (stderr, "Running spec function '%s' with %d args\n\n", + __FUNCTION__, argc); +#endif + + switch (argc) + { + case 0: + fatal_error (input_location, + "bad usage of spec function %qs", "device-specs-file"); + return ""; + + case 1: + mmcu = AVR_MMCU_DEFAULT; + break; + + case 2: + mmcu = argv[1]; + break; + + default: + error ("specified option %qs more than once", "-mmcu="); + return ""; + } + + specfile_name = concat (argv[0], dir_separator_str, "specs-", mmcu, NULL); + +#ifdef DEBUG_SPECS + if (verbose_flag) + fnotice (stderr, "'%s': mmcu='%s'\n'%s': specfile='%s'\n\n", + __FUNCTION__, mmcu, __FUNCTION__, specfile_name); +#endif + + // Filter out silly -mmcu= arguments like "foo bar". + + for (const char *s = mmcu; *s; s++) + if (!ISALNUM (*s) + && '-' != *s + && '_' != *s) + { + error ("strange device name %qs after %qs: bad character %qc", + mmcu, "-mmcu=", *s); + return ""; + } + + if (/* When building / configuring the compiler we might get a relative path + as supplied by "-B.". Assume that the specs file exists and MCU is + a core, not a proper device then, i.e. we have "-mmcu=avr*". */ + (0 == strncmp (mmcu, "avr", strlen ("avr")) + && specfile_name[0] == '.') + /* vanilla */ + || (IS_ABSOLUTE_PATH (specfile_name) + && !access (specfile_name, R_OK))) + { + return concat ("-specs=", specfile_name, NULL); + } + + return avr_diagnose_devicespecs_error (mmcu, specfile_name); +} |