-march bug when building kernel

Bug #947111 reported by Adrien Ferré
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
binutils
Fix Released
Medium
armel-cross-toolchain-base (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Hi,

Just tried to compile linaro kernel with linaro toolchain (up to date) and ended up with something like:

arch/arm/boot/compressed/head.S: Assembler messages:
arch/arm/boot/compressed/head.S:127: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
arch/arm/boot/compressed/head.S:134: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
arch/arm/boot/compressed/head.S:136: Error: selected processor does not support requested special purpose register -- `msr cpsr_c,r2'
make[2]: *** [arch/arm/boot/compressed/head.o] Erreur 1
make[2]: *** Attente des tâches non terminées....
make[1]: *** [arch/arm/boot/compressed/vmlinux] Erreur 2
make: *** [uImage] Erreur 2

My machine:
Description: Ubuntu 10.04.4 LTS
Release: 10.04

uname -a
Linux ferre-desktop 2.6.38-13-generic #54~lucid1-Ubuntu SMP Wed Jan 4 13:00:37 UTC 2012 x86_64 GNU/Linux

Used linux-linaro-3.1 kernel.

To fix it pm215 from the linaro irc channel told me to comment out the
asflags-y := -Wa,-march=all
part in the file arch/arm/bott/compressed/Makefile and it does the trick.

Revision history for this message
In , Arnaud Patard (arnaud-patard) wrote :

As noticed by debian bug 623964, when building an arm kernel with a snasphot made on 04/19, compiling head.S is failing with :

Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'

It's valid for current head.

To reproduce, create a head.S containing:

                mrs r2, cpsr
                msr cpsr_c, r2

And then build with ./gas/as-new -march=all -c head.S -o head.o

I believe it's due to this commit :
http://sourceware.org/git/?p=binutils.git;a=commitdiff;h=335cd49156302284cea0438fd068f0a7cc11355a

I've written this workaround:

--- binutils.orig/gas/config/tc-arm.c
+++ binutils/gas/config/tc-arm.c
@@ -5356,6 +5356,11 @@ parse_psr (char **str, bfd_boolean lhs)
   bfd_boolean is_apsr = FALSE;
   bfd_boolean m_profile = ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m);

+ /* march=all, will match the m_profile case too, so things like 'mrs r2,cpsr'
+ * will now fail. Workaround by saying it's not a m profile */
+ if (selected_cpu.core == arm_arch_any.core)
+ m_profile = FALSE;
+
   /* CPSR's and SPSR's can now be lowercase. This is just a convenience
      feature for ease of use and backwards compatibility. */
   p = *str;

It doesn't seem to create any regression but I'm not sure how good is this patch. At least, I hope it'll help fixing the bug.

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

CVSROOT: /cvs/src
Module name: src
Changes by: <email address hidden> 2011-06-03 14:42:48

Modified files:
 gas : ChangeLog
 gas/config : tc-arm.c

Log message:
 PR gas/12698
 * config/tc-arm.c (parse_psr): Set m_profile to false when
 assembling for any architecture.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4499&r2=1.4500
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-arm.c.diff?cvsroot=src&r1=1.490&r2=1.491

Revision history for this message
In , Nickc (nickc) wrote :

Hi Arnaud,

  Thanks for reporting this problem and providing a patch. Your solution works, so I have checked it in, with a slightly tweaked comment.

Cheers
  Nick

Revision history for this message
Peter Maydell (pmaydell) wrote :

NB that that asflags thing is just a work around, not an actual fix.
This bug was addressed in the toolchain:
 http://sourceware.org/bugzilla/show_bug.cgi?id=12698
and seems to be fixed in at least some of the linaro toolchain packages -- maybe it just failed to get into the lucid one somehow?

Peter Maydell (pmaydell)
affects: ubuntu → armel-cross-toolchain-base (Ubuntu)
Marcin Juszkiewicz (hrw)
Changed in armel-cross-toolchain-base (Ubuntu):
status: New → Confirmed
Changed in binutils:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
Marcin Juszkiewicz (hrw) wrote :

I just built linux-linaro 3.1-2011.11 under Lucid/amd64 (omap2plus_defconfig + make zImage).

Adrien: can you tell which versions of toolchain you used?

Revision history for this message
Adrien Ferré (ferre-adrien) wrote :

Hi Martin,

I think I used the 4.6.2

arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-gcc (Ubuntu/Linaro 4.6.2-14ubuntu2~ppa1) 4.6.2

Revision history for this message
Marcin Juszkiewicz (hrw) wrote :

Adrien: I took the same one and got kernel built. If you have your failing tree somewhere then please provide me which exactly version it is and kernel configuration you built.

If you can then please test it under Ubuntu 12.04 - it has more up-to-date cross compiler which should just work.

Revision history for this message
Adrien Ferré (ferre-adrien) wrote :

Hi Marcin,

I have lost the tree I tried to build sry.

Marcin Juszkiewicz (hrw)
Changed in armel-cross-toolchain-base (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
In , Zhenqiang Chen (zhenqiang-chen) wrote :

Created attachment 6435
failed case

Assembler fail.

Revision history for this message
In , Zhenqiang Chen (zhenqiang-chen) wrote :

The attached case is from kernel. We still get fail:

head2.s: Assembler messages:
head2.s:60: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
head2.s:67: Error: selected processor does not support requested special purpose register -- `mrs r2,cpsr'
head2.s:69: Error: selected processor does not support requested special purpose register -- `msr cpsr_c,r2'

The fault occurs in 2.22 and current trunk.

To reproduce it:
arm-linux-gnueabi-as --gdwarf2 -EL -march=armv7-a -mfloat-abi=soft -mfpu=vfpv3-d16 -meabi=5 -mimplicit-it=always -mno-warn-deprecated -mthumb -march=all -o head.o head2.s

Revision history for this message
In , Zhenqiang Chen (zhenqiang-chen) wrote :

Here is a reference patch based on your previous one.
Both function do_t_mrs and do_t_msr need update.

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 6ff64a6..7f69ffa 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -11201,8 +11201,14 @@ do_t_mrs (void)
       int flags = inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);

       if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
- constraint (flags != 0, _("selected processor does not support "
- "requested special purpose register"));
+ {
+ /* PR gas/12698: The constraint is only applied for m_profile.
+ If the user has specified -march=all, we want to ignore it as
+ we are building for any CPU type, including non-m variants. */
+ bfd_boolean m_profile = selected_cpu.core != arm_arch_any.core;
+ constraint ((flags != 0) && m_profile, _("selected processor does "
+ "not support requested special purpose register"));
+ }
       else
  /* mrs only accepts APSR/CPSR/SPSR/CPSR_all/SPSR_all (for non-M profile
     devices). */
@@ -11235,11 +11241,14 @@ do_t_msr (void)
   if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m))
     {
       int bits = inst.operands[0].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT);
-
- constraint ((ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
+ /* PR gas/12698: The constraint is only applied for m_profile.
+ If the user has specified -march=all, we want to ignore it as
+ we are building for any CPU type, including non-m variants. */
+ bfd_boolean m_profile = selected_cpu.core != arm_arch_any.core;
+ constraint (((ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
      && (bits & ~(PSR_s | PSR_f)) != 0)
     || (!ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_v6_dsp)
- && bits != PSR_f),
+ && bits != PSR_f)) && m_profile,
     _("selected processor does not support requested special "
       "purpose register"));
     }

Changed in binutils:
status: Fix Released → Confirmed
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

CVSROOT: /cvs/src
Module name: src
Changes by: <email address hidden> 2012-06-13 14:19:00

Modified files:
 gas : ChangeLog
 gas/config : tc-arm.c

Log message:
 PR gas/12698
 * config/tc-arm.c (do_t_mrs): Do not require an m-profile
 architecure when assembling for all archiectures.
 (do_t_msr): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4752&r2=1.4753
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-arm.c.diff?cvsroot=src&r1=1.519&r2=1.520

Revision history for this message
In , Nickc (nickc) wrote :

Hi Chen,

  Thanks for the patch - I have applied it to the mainline sources.

Cheers
  Nick

Changed in binutils:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.