User account creation filtered due to spam.

Bug 15790 - [3.4 only] Alignment error building gcc with i686-coff target
Summary: [3.4 only] Alignment error building gcc with i686-coff target
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.3
Assignee: Jim Wilson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-06-02 23:15 UTC by Richard Parratt
Modified: 2004-10-31 01:59 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-coff
Build:
Known to work: 4.0.0
Known to fail: 3.4.0
Last reconfirmed: 2004-06-08 22:35:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Parratt 2004-06-02 23:15:14 UTC
I was trying to build a GCC cross compiler with a target of "i686-coff". 
It failed with "Error: Alignment not a power of 2"

I found various references to this, e.g. 
http://sources.redhat.com/ml/crossgcc/2001-03/msg00176.html
 from Kai Ruottu <kai.ruottu@luukku.com>

The fix given there was to add lines as follows to i386-coff.h: #undef 
ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG)    \
    if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))

This worked.

As this seems to be an old chestnut (it was already one in 2001) could the fix 
be added to the reference source, so that everyone making a cross-compiler 
doesn't have to patch?
Comment 1 Andrew Pinski 2004-06-02 23:47:24 UTC
Patches goto gcc-patches@gcc.gnu.org with a changelog after reading <http://gcc.gnu.org/
contribute.html> fully.
Comment 2 Jim Wilson 2004-06-08 22:29:37 UTC
Subject: Re:  New: Alignment error building gcc with i686-coff
 target

richard dot parratt at netiq dot com wrote:
> I was trying to build a GCC cross compiler with a target of "i686-coff". 
> It failed with "Error: Alignment not a power of 2"

The problem here is that there is some historical confusion over whether 
the argument to the .align directive is the number of bytes or the log 
of the number of bytes.  Gas changed a few times long ago, and 
eventually settled on using number of bytes for all x86 targets except 
aout and go32.  The gcc i386-coff port defaults to using the log of the 
number of bytes, and hence conflicts with gas.

Hoewver, if gcc is configured right, this shouldn't be a problem.  gcc 
will find the cross assembler, gas, and do a test to determine how to 
emit assembler align directives.  I know of at least 3 ways to get this 
right.
1) Configure gcc and gas in a combined source tree.
2) Configure, build, and install gas using the same prefix as is used 
for gcc, before configuring gcc.
3) Use the --with-as= option when configuring gcc to point at the cross 
assembler.

If you don't do one of these things, then gcc won't build correctly 
anyways, so you actually have to do something wrong to end up with this 
problem.  I noticed that if I configured gcc wrong, and then configured 
it correctly, I ended up with this problem because bad data was read 
from the config.cache file produced by the first configure run.

Anyways, this is easy enough to fix, so I will check in a patch for it.
Comment 3 CVS Commits 2004-06-08 22:32:13 UTC
Subject: Bug 15790

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	wilson@gcc.gnu.org	2004-06-08 22:32:09

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: i386-coff.h 

Log message:
	PR target/15790
	* config/i386/i386-coff.h (ASM_OUTPUT_ALIGN): Define.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3881&r2=2.3882
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386-coff.h.diff?cvsroot=gcc&r1=1.14&r2=1.15

Comment 4 Jim Wilson 2004-06-08 22:35:18 UTC
Fixed in mainline.  Technically, this isn't a regression, so I don't think we
need it fixed in gcc-3.3 or gcc-3.4.  Also, I supplied info on how to work
around the problem.
Comment 5 Mark Mitchell 2004-10-31 01:59:08 UTC
Already fixed on mainline, will not be fixed in GCC 3.4.x.