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.
from Kai Ruottu <email@example.com>
The fix given there was to add lines as follows to i386-coff.h: #undef
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
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?
Patches goto firstname.lastname@example.org with a changelog after reading <http://gcc.gnu.org/
Subject: Re: New: Alignment error building gcc with i686-coff
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
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
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.
Subject: Bug 15790
Module name: gcc
Changes by: email@example.com 2004-06-08 22:32:09
gcc : ChangeLog
* config/i386/i386-coff.h (ASM_OUTPUT_ALIGN): Define.
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.
Already fixed on mainline, will not be fixed in GCC 3.4.x.