diff mbox

[AVR] Fix PR51345: split multilibs for SPH / no-SPH devices, Take #2

Message ID 4F01A993.4040203@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay Jan. 2, 2012, 12:56 p.m. UTC
Denis Chertykov wrote:
> 2011/12/19 Georg-Johann Lay <avr@>:
>> Joseph S. Myers wrote:
>>> On Sun, 18 Dec 2011, Georg-Johann Lay wrote:
>>>
>>>>> This new file needs to have the standard copyright and license notices.
>>>>> It's desirable to generate such notices in the output files as well.
>>>> What is the right copyright for the generated files?
>>> See other examples.
>> There is more than one flavour if the license... From what you wrote it's okay
>> to use GPL in all cases even if included libgcc, so I used that text.
>>
>> Besides printing license, there are two minor changes compared to the original
>> patch:
>>
>> * lib1funcs.S defines macro SPEED_DIV that trades speed against code size.
>>  It uses __AVR_HAVE_8BIT_SP__ now to get better estimation of flash size.
>>
>> * avr-c.c use AVR_HAVE_8BIT_SP instead of avr_current_device->short_sp to
>>  define respective built-in macros __AVR_HAVE_8/16BIT_SP__.
>>
>> Ok?
>>
>> Johann
>>
>> contrib/
>>        PR target/51345
>>        * gcc_update (files_and_dependencies): Add
>>        gcc/config/avr/t-multilib, gcc/config/avr/multilib.h.
>>
>> libgcc/
>>        PR target/51345
>>        * config/avr/lib1funcs.S: Remove FIXME comments.
>>        (SPEED_DIV): Depend on __AVR_HAVE_8BIT_SP__.
>> gcc/
>>        PR target/51345
>>        * config.gcc (tm_file target=avr]): Add avr/avr-multilib.h
>>        (tmake_file target=avr): Add avr/t-multilib.
>>
>>        * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use AVR_HAVE_8BIT_SP
>>        to built-in define __AVR_HAVE_8BIT_SP__, __AVR_HAVE_16BIT_SP__.
>>        * config/avr/genmultilib.awk: New file.
>>        * config/avr/t-multilib: New auto-generated file.
>>        * config/avr/multilib.h: New auto-generated file.
>>        * config/avr/t-avr (AVR_MCUS): New variable.
>>        (genopt.sh): Use it.
>>        (s-mlib): Depend on t-multilib.
>>        (t-multilib, multilib.h): New dependencies.
>>        (s-avr-mlib): New rule to build t-multilib, multilib.h from AVR_MCUS.
>>        (MULTILIB_OPTIONS): Remove.
>>        (MULTILIB_MATCHES): Remove.
>>        (MULTILIB_DIRNAMES): Remove.
>>        (MULTILIB_EXCEPTIONS): Remove:
>>        * config/avr/genopt.sh: Don't use hard coded file name;
>>        pass AVR_MCUS from t-avr instead.
>>
> 
> Approved.
> 
> Denis.

Applied with the following change. This is needed if older version of [g]awk is
installed that does not accept length() on arrays.  The generated files are the
same.

Johann
diff mbox

Patch

diff --git a/gcc/config/avr/genmultilib.awk b/gcc/config/avr/genmultilib.awk
index bbff61c..7bc3b4a 100644
--- a/gcc/config/avr/genmultilib.awk
+++ b/gcc/config/avr/genmultilib.awk
@@ -36,6 +36,8 @@  BEGIN {
     option[""] = ""
     tiny_stack[""] = 1
     comment = 1
+    n_mcu = 0
+    n_cores = 0
 
     mtiny[0] = ""
     mtiny[1] = "tiny-stack"
@@ -110,7 +112,8 @@  BEGIN {
 	if (core == "avr1")
 	    next
 
-	cores[length (cores)] = core
+	cores[n_cores] = core
+	n_cores++
 	tiny_stack[core] = 0
 	option[core] = "mmcu=" core
 
@@ -122,7 +125,8 @@  BEGIN {
 	next
 
     tiny_stack[name]  = $5
-    mcu[length (mcu)] = name
+    mcu[n_mcu] = name
+    n_mcu++
     option[name]      = "mmcu=" name
     toCore[name]      = core
 
@@ -157,7 +161,7 @@  END {
     #    (avr2, avr25, ...) x mtiny-stack
 
     sep = ""
-    for (c = 0; c < length (cores); c++)
+    for (c = 0; c < n_cores; c++)
     {
 	m_options = m_options sep option[cores[c]]
 	sep = "/"
@@ -175,7 +179,7 @@  END {
     dot_excludes = ""
     m_raw_sp8 = ""
 
-    for (t = 0; t < length (mcu); t++)
+    for (t = 0; t < n_mcu; t++)
     {
 	core = toCore[mcu[t]]
 	
@@ -212,8 +216,9 @@  END {
     ####################################################################
     # Compose MULTILIB_DIRNAMES, MULTILIB_EXEPTIONS and avr_multilib_raw
 
-    for (t = 0; t < length (mtiny); t++)
-	for (c = -1; c < length (cores); c++)
+    n_mtiny = 2
+    for (t = 0; t < n_mtiny; t++)
+	for (c = -1; c < n_cores; c++)
 	{
 	    if (c == -1)
 		core = ""
@@ -255,7 +260,7 @@  END {
 
 	    line = mdir
 
-	    for (s = 0; s < length (cores); s++)
+	    for (s = 0; s < n_cores; s++)
 	    {
 		if (cores[s] == core)
 		    line = line " " option[cores[s]]