[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GCC/G++ will not compile i686 binaries when asked.



On Wed, Aug 25, 2004 at 05:48:45PM -0700, dking@pimpsoft.com wrote:
> For the past few weeks I have been co-working on a private project. I
> have done allot of work on it and I would hate to have to start over.
> 
> The makefile I created for this project explicitly tells the compiler
> (g++) to compile the binary using i686 (-march=pentiumpro) assembly
> instructions and internal timeings. Yet for some [explitive]
> [explitive] reason it refuses to do so and both ?file? amd ?readelf?
> tell me it always compiles for a bare i386 despite my explicit
> commands otherwise.
> 
> Two questions:
> Why the [explitive] does this [explitive] thing not compile the end
> result into a i686 only binary as I asked it to?
> How the [explitive] do I fix it?
> 
> I have read the gcc/g++ manual pages. I have googled. I have spent
> the past hour dedicating myself to this problem, and nothing seems to
> work.
> 
> This is [b]really[/b] getting to me. Please help.

C file:

int main(int argc) {
	int sam = 0;
	if (argc > 1) sam = argc;
	return sam;
}

Compile:

~ %% gcc -o testC test.c -mcpu=pentiumpro -march=pentiumpro -O3

Dissassembly Excerpt:

08048320 <main>:
 8048320:       55                      push   %ebp
 8048321:       31 c0                   xor    %eax,%eax
 8048323:       89 e5                   mov    %esp,%ebp
 8048325:       83 ec 08                sub    $0x8,%esp
 8048328:       8b 4d 08                mov    0x8(%ebp),%ecx
 804832b:       83 e4 f0                and    $0xfffffff0,%esp
 804832e:       83 f9 02                cmp    $0x2,%ecx
 8048331:       0f 4d c1                cmovge %ecx,%eax
 8048334:       89 ec                   mov    %ebp,%esp
 8048336:       5d                      pop    %ebp
 8048337:       c3                      ret    

See that cmovge - that's a Pentium ONLY insn.

And readelf says:
  Machine:                           Intel 80386

Is that ^^^ why you thing gcc won't make 686 programs?


1. A PPro exec is the same as a 386 exec except for the insns. ReadELF
   will tell you it's a 386 exec even if you have a PPro exec.

Please comment. If it doesn't have 686 asm and could benefit from it, we
(atleast I) need more info.

P.S. I use woody with a GCC-3.3 from unstable and the ness. libs.



Reply to: