Commit 076d86f3 by Georg-Johann Lay Committed by Georg-Johann Lay

re PR target/65296 ([avr] fix various issues with specs file generation)

	PR target/65296
	* config/avr/avr.opt (-nodevicelib): New option.
	* doc/invoke.texi (AVR Options): Document it.
	* config/avr/avrlibc.h (LIB_SPEC, LIBGCC_SPEC) [avr1]: Don't link
	libgcc.a, libc.a, libm.a.
	* config/avr/specs.h: Same.
	* config/avr/gen-avr-mmcu-specs.c (print_mcu): Don't print specs
	which don't (directly) depend on the device.  Print more help.
	(*avrlibc_devicelib) [-nodevicelib]: Don't link libdev.a.
	(*cpp): Don't define __AVR_DEV_LIB_NAME__.
	* config/avr/driver-avr.c: Remove -nodevicelib from option list in
	case of an error.
	(avr_devicespecs_file): Use suffix "%s" instead of absolute path
	for specs file name.
	* config/avr/avr-arch.h (avr_mcu_t) [.library_name]: Remove.
	* config/avr/avr-mcus.def: Adjust initializers and comments.

From-SVN: r221475
parent ebd63afa
2015-03-16 Georg-Johann Lay <avr@gjlay.de>
PR target/65296
* config/avr/avr.opt (-nodevicelib): New option.
* doc/invoke.texi (AVR Options): Document it.
* config/avr/avrlibc.h (LIB_SPEC, LIBGCC_SPEC) [avr1]: Don't link
libgcc.a, libc.a, libm.a.
* config/avr/specs.h: Same.
* config/avr/gen-avr-mmcu-specs.c (print_mcu): Don't print specs
which don't (directly) depend on the device. Print more help.
(*avrlibc_devicelib) [-nodevicelib]: Don't link libdev.a.
(*cpp): Don't define __AVR_DEV_LIB_NAME__.
* config/avr/driver-avr.c: Remove -nodevicelib from option list in
case of an error.
(avr_devicespecs_file): Use suffix "%s" instead of absolute path
for specs file name.
* config/avr/avr-arch.h (avr_mcu_t) [.library_name]: Remove.
* config/avr/avr-mcus.def: Adjust initializers and comments.
2015-03-16 Jan Hubicka <hubicka@ucw.cz>
* tree-sra.c (ipa_sra_preliminary_function_checks): Use
......
......@@ -122,9 +122,6 @@ typedef struct
/* Number of 64k segments in the flash. */
int n_flash;
/* Old name of device library. */
const char *const library_name;
} avr_mcu_t;
/* AVR device specific features.
......
......@@ -111,12 +111,12 @@ avr_texinfo[] =
const avr_mcu_t
avr_mcu_types[] =
{
#define AVR_MCU(NAME, ARCH, DEV_ATTRIBUTE, MACRO, DATA_SEC, TEXT_SEC, N_FLASH, LIBNAME)\
{ NAME, ARCH, DEV_ATTRIBUTE, MACRO, DATA_SEC, TEXT_SEC, N_FLASH, LIBNAME },
#define AVR_MCU(NAME, ARCH, DEV_ATTRIBUTE, MACRO, DATA_SEC, TEXT_SEC, N_FLASH)\
{ NAME, ARCH, DEV_ATTRIBUTE, MACRO, DATA_SEC, TEXT_SEC, N_FLASH },
#include "avr-mcus.def"
#undef AVR_MCU
/* End of list. */
{ NULL, ARCH_UNKNOWN, AVR_ISA_NONE, NULL, 0, 0, 0, NULL }
{ NULL, ARCH_UNKNOWN, AVR_ISA_NONE, NULL, 0, 0, 0 }
};
......
......@@ -94,3 +94,7 @@ Warn if the address space of an address is changed.
mfract-convert-truncate
Target Report Mask(FRACT_CONV_TRUNC)
Allow to use truncation instead of rounding towards 0 for fractional int types
nodevicelib
Driver Target Report RejectNegative
Do not link against the device-specific library libdev.a
......@@ -19,21 +19,17 @@ 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/>. */
/* AVR-Libc implements functions from libgcc.a in libm.a, see PR54461.
More AVR-Libc specific specs originate from gen-avr-mmcu-specs.c:
- LIBGCC_SPEC (*libgcc)
- LIB_SPEC (*lib)
*/
#undef LIB_SPEC
#define LIB_SPEC \
" -lc %(avrlibc_devicelib) "
"%{!mmcu=avr1:-lc} %(avrlibc_devicelib)"
// AVR-Libc implements functions from libgcc.a in libm.a, see PR54461.
// For a list of functions which are provided by libm.a and are
// omitted from libgcc.a see libgcc's t-avrlibc.
#undef LIBGCC_SPEC
#define LIBGCC_SPEC \
" -lgcc -lm "
"%{!mmcu=avr1:-lgcc -lm}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
......
......@@ -24,6 +24,9 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "tm.h"
// Remove -nodevicelib from the command line if not needed
#define X_NODEVLIB "%<nodevicelib"
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
static const char specfiles_doc_url[] =
......@@ -46,7 +49,7 @@ avr_diagnose_devicespecs_error (const char *mcu, const char *filename)
inform (input_location, "you can provide your own specs files, "
"see <%s> for details", specfiles_doc_url);
return "";
return X_NODEVLIB;
}
......@@ -73,7 +76,7 @@ avr_devicespecs_file (int argc, const char **argv)
case 0:
fatal_error (input_location,
"bad usage of spec function %qs", "device-specs-file");
return "";
return X_NODEVLIB;
case 1:
mmcu = AVR_MMCU_DEFAULT;
......@@ -85,7 +88,7 @@ avr_devicespecs_file (int argc, const char **argv)
default:
error ("specified option %qs more than once", "-mmcu=");
return "";
return X_NODEVLIB;
}
specfile_name = concat (argv[0], dir_separator_str, "specs-", mmcu, NULL);
......@@ -105,7 +108,7 @@ avr_devicespecs_file (int argc, const char **argv)
{
error ("strange device name %qs after %qs: bad character %qc",
mmcu, "-mmcu=", *s);
return "";
return X_NODEVLIB;
}
if (/* When building / configuring the compiler we might get a relative path
......@@ -117,7 +120,16 @@ avr_devicespecs_file (int argc, const char **argv)
|| (IS_ABSOLUTE_PATH (specfile_name)
&& !access (specfile_name, R_OK)))
{
return concat ("-specs=", specfile_name, NULL);
return concat ("-specs=device-specs", dir_separator_str, "specs-", mmcu,
// Use '%s' instead of the expanded specfile_name. This
// is the easiest way to handle pathes containing spaces.
"%s",
#if defined (WITH_AVRLIBC)
" %{mmcu=avr*:" X_NODEVLIB "} %{!mmcu=*:" X_NODEVLIB "}",
#else
" " X_NODEVLIB,
#endif
NULL);
}
return avr_diagnose_devicespecs_error (mmcu, specfile_name);
......
......@@ -78,6 +78,40 @@ static const char header[] =
"# for a documentation of spec files.\n"
"\n";
static const char help_copy_paste[] =
"# If you intend to use an existing device specs file as a starting point\n"
"# for a new device spec file, make sure you are copying from a specs\n"
"# file for a device from the same core architecture and SP width.\n";
#if defined (WITH_AVRLIBC)
static const char help_dev_lib_name[] =
"# AVR-LibC's avr/io.h uses the device specifying macro to determine\n"
"# the name of the device header. For example, -mmcu=atmega8a triggers\n"
"# the definition of __AVR_ATmega8A__ and avr/io.h includes the device\n"
"# header 'iom8a.h' by means of:\n"
"#\n"
"# ...\n"
"# #elif defined (__AVR_ATmega8A__)\n"
"# # include <avr/iom8a.h>\n"
"# #elif ...\n"
"# \n"
"# If no device macro is defined, AVR-LibC uses __AVR_DEV_LIB_NAME__\n"
"# as fallback to determine the name of the device header as\n"
"#\n"
"# \"avr/io\" + __AVR_DEV_LIB_NAME__ + \".h\"\n"
"#\n"
"# If you provide your own specs file for a device not yet known to\n"
"# AVR-LibC, you can now define the hook macro __AVR_DEV_LIB_NAME__\n"
"# as needed so that\n"
"#\n"
"# #include <avr/io.h>\n"
"#\n"
"# will include the desired device header. For ATmega8A the supplement\n"
"# to *cpp would read\n"
"#\n"
"# -D__AVR_DEV_LIB_NAME__=m8a\n"
"\n";
#endif // WITH_AVRLIBC
static void
print_mcu (const avr_mcu_t *mcu)
......@@ -128,19 +162,25 @@ print_mcu (const avr_mcu_t *mcu)
mcu->name, arch->name, sp8 ? 8 : 16);
fprintf (f, "%s\n", header);
// avrlibc-specific specs for linking / thelinker.
fprintf (f, "*avrlibc_startfile:\n");
if (is_device)
fprintf (f, "\tdev/%s/crt1.o%%s", mcu->name);
fprintf (f, "\n\n");
fprintf (f, "%s\n", help_copy_paste);
#if defined (WITH_AVRLIBC)
// AVR-LibC specific. See avrlibc.h for the specs using them as subspecs.
fprintf (f, "*avrlibc_devicelib:\n");
if (is_device)
fprintf (f, "\tdev/%s/libdev.a%%s", mcu->name);
fprintf (f, "\n\n");
{
fprintf (f, "*avrlibc_startfile:\n");
fprintf (f, "\tdev/%s/crt1.o%%s", mcu->name);
fprintf (f, "\n\n");
fprintf (f, "*avrlibc_devicelib:\n");
fprintf (f, "\t%%{!nodevicelib:dev/%s/libdev.a%%s}", mcu->name);
fprintf (f, "\n\n");
}
#endif // WITH_AVRLIBC
// avr-specific specs for the compilation / the compiler proper.
// avr-gcc specific specs for the compilation / the compiler proper.
fprintf (f, "*cc1_n_flash:\n"
"\t%%{!mn-flash=*:-mn-flash=%d}\n\n", mcu->n_flash);
......@@ -153,19 +193,19 @@ print_mcu (const avr_mcu_t *mcu)
? "\t%{!mno-skip-bug: -mskip-bug}"
: "\t%{!mskip-bug: -mno-skip-bug}");
// avr-specific specs for assembling / the assembler.
// avr-gcc specific specs for assembling / the assembler.
fprintf (f, "*asm_arch:\n\t-mmcu=%s\n\n", arch->name);
#ifdef HAVE_AS_AVR_MLINK_RELAX_OPTION
fprintf (f, "*asm_relax:\n\t%s\n\n", ASM_RELAX_SPEC);
#endif // have as --mlink-relax
#endif // have avr-as --mlink-relax
#ifdef HAVE_AS_AVR_MRMW_OPTION
fprintf (f, "*asm_rmw:\n%s\n\n", rmw
? "\t%{!mno-rmw: -mrmw}"
: "\t%{mrmw}");
#endif // have as -mrmw
#endif // have avr-as -mrmw
fprintf (f, "*asm_errata_skip:\n%s\n\n", errata_skip
? "\t%{mno-skip-bug}"
......@@ -192,50 +232,36 @@ print_mcu (const avr_mcu_t *mcu)
fprintf (f, "*link_arch:\n\t%s\n\n", LINK_ARCH_SPEC);
fprintf (f, "*link_data_start:\n");
if (mcu->data_section_start
!= arch->default_data_section_start)
fprintf (f, "\t-Tdata 0x%lX", 0x800000UL + mcu->data_section_start);
fprintf (f, "\n\n");
fprintf (f, "*link_text_start:\n");
if (mcu->text_section_start != 0x0)
fprintf (f, "\t-Ttext 0x%lX", 0UL + mcu->text_section_start);
fprintf (f, "\n\n");
// Default specs. Rewritten to the device-specific specs file so
// they can be adjusted as needed.
bool has_libs = arch_id != ARCH_AVR1;
fprintf (f, "*self_spec:\n");
if (is_device)
fprintf (f, "\t%%{!mmcu=avr*: %%<mmcu=* -mmcu=%s} ", arch->name);
fprintf (f, "%s\n\n", sp8_spec);
fprintf (f, "*cpp:\n");
if (is_device)
fprintf (f,"\t-D__AVR_DEV_LIB_NAME__=%s"
" -D%s"
" -D__AVR_DEVICE_NAME__=%s",
mcu->library_name, mcu->macro, mcu->name);
fprintf (f, "\n\n");
fprintf (f, "*cc1:\n\t%s\n\n", CC1_SPEC);
fprintf (f, "*cc1plus:\n\t%s\n\n", CC1PLUS_SPEC);
fprintf (f, "*asm:\n\t%s\n\n", ASM_SPEC);
fprintf (f, "*link:\n\t%s\n\n", LINK_SPEC);
{
fprintf (f, "*link_data_start:\n");
if (mcu->data_section_start
!= arch->default_data_section_start)
fprintf (f, "\t-Tdata 0x%lX", 0x800000UL + mcu->data_section_start);
fprintf (f, "\n\n");
fprintf (f, "*link_text_start:\n");
if (mcu->text_section_start != 0x0)
fprintf (f, "\t-Ttext 0x%lX", 0UL + mcu->text_section_start);
fprintf (f, "\n\n");
}
fprintf (f, "*lib:\n\t%s\n\n", has_libs ? LIB_SPEC : "");
// Specs known to GCC.
fprintf (f, "*libgcc:\n\t%s\n\n", has_libs ? LIBGCC_SPEC : "");
if (is_device)
{
fprintf (f, "*self_spec:\n");
fprintf (f, "\t%%{!mmcu=avr*: %%<mmcu=* -mmcu=%s} ", arch->name);
fprintf (f, "%s\n\n", sp8_spec);
fprintf (f, "*startfile:\n\t%s\n\n", STARTFILE_SPEC);
#if defined (WITH_AVRLIBC)
fprintf (f, "%s\n", help_dev_lib_name);
#endif // WITH_AVRLIBC
fprintf (f, "*endfile:\n%s\n\n", ENDFILE_SPEC);
fprintf (f, "*cpp:\n");
fprintf (f, "\t-D%s -D__AVR_DEVICE_NAME__=%s", mcu->macro, mcu->name);
fprintf (f, "\n\n");
}
fprintf (f, "# End of file\n");
}
......
......@@ -68,10 +68,10 @@ along with GCC; see the file COPYING3. If not see
"%{shared:%eshared is not supported} "
#undef LIB_SPEC
#define LIB_SPEC " -lc "
#define LIB_SPEC " %{!mmcu=avr1:-lc} "
#undef LIBGCC_SPEC
#define LIBGCC_SPEC " -lgcc "
#define LIBGCC_SPEC " %{!mmcu=avr1:-lgcc} "
#define STARTFILE_SPEC ""
#define ENDFILE_SPEC ""
......@@ -572,7 +572,7 @@ Objective-C and Objective-C++ Dialects}.
@emph{AVR Options}
@gccoptlist{-mmcu=@var{mcu} -maccumulate-args -mbranch-cost=@var{cost} @gol
-mcall-prologues -mint8 -mn_flash=@var{size} -mno-interrupts @gol
-mrelax -mrmw -mstrict-X -mtiny-stack -Waddr-space-convert}
-mrelax -mrmw -mstrict-X -mtiny-stack -nodevicelib -Waddr-space-convert}
@emph{Blackfin Options}
@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
......@@ -13572,6 +13572,10 @@ sbiw r26, const ; X -= const
@opindex mtiny-stack
Only change the lower 8@tie{}bits of the stack pointer.
@item -nodevicelib
@opindex nodevicelib
Don't link against AVR-LibC's device specific library @code{libdev.a}.
@item -Waddr-space-convert
@opindex Waddr-space-convert
Warn about conversions between address spaces in the case where the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment