# Compiler machine compatibility

**URL:** <https://www.ruby-forum.com/t/compiler-machine-compatibility/205562>\
**Category:** GNU Radio\
**Created:** [April 8, 2011, 6:33pm UTC](https://www.ruby-forum.com/t/compiler-machine-compatibility/205562 "2011-04-08T18:33:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 8, 2011, 6:33pm UTC](https://www.ruby-forum.com/t/compiler-machine-compatibility/205562/1 "2011-04-08T18:33:37Z")

</div>

I have some code that lives on top of Gnu Radio, and I think I’m having  
a code-generation issue with GCC. The binaries work on all  
my machines, but on a customers machine, it raises an Illegal  
Instruction exception. I generated the code on a 32-bit Intel Core  
machine, on Fedora 12. The code is executing on a Pentium-IV class  
machine, on a Fedora 12 installation. I gather than by default  
GCC will generate code that’s optimized for the machine on which the  
compile is happening. How do distributors of binaries assure  
that the code will execute correctly on older-generation hardware?

---

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [April 8, 2011, 7:08pm UTC](https://www.ruby-forum.com/t/compiler-machine-compatibility/205562/2 "2011-04-08T19:08:09Z")

</div>

On Fri, 2011-04-08 at 12:29 -0400, Marcus D. Leech wrote:

> I have some code that lives on top of Gnu Radio, and I think I’m having  
> a code-generation issue with GCC. The binaries work on all  
> my machines, but on a customers machine, it raises an Illegal  
> Instruction exception. I generated the code on a 32-bit Intel Core  
> machine, on Fedora 12. The code is executing on a Pentium-IV class  
> machine, on a Fedora 12 installation. I gather than by default  
> GCC will generate code that’s optimized for the machine on which the  
> compile is happening. How do distributors of binaries assure  
> that the code will execute correctly on older-generation hardware?

Make sure you’re compiling with optimization flags appropriate for the  
hardware you’re planning to run on. For instance, if you spec -msse3 or  
newer on a pre-Prescott P4, you’ll generate instructions the CPU can’t  
execute. I’m pretty sure GCC won’t generate these instructions unless  
you specify it using these flags so make sure your automake/cmake setup  
isn’t doing so.

Another issue is if you compile on a 32-bit compiler it’ll barf on a  
64-bit system, and this might generate an illegal instruction error.  
This is the reason package maintainers keep a 32-bit and 64-bit version  
of their packages. If you want to make code that runs on a 64-bit system  
from your 32-bit system, you’ll have to use a 64-bit GCC installation (I  
think GCC is the same for either, but you need 64-bit libc) and use -m64  
as a compile flag.

–n

---

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [April 8, 2011, 7:32pm UTC](https://www.ruby-forum.com/t/compiler-machine-compatibility/205562/3 "2011-04-08T19:32:13Z")

</div>

On 08/04/2011 1:06 PM, Nick F. wrote:

> This is the reason package maintainers keep a 32-bit and 64-bit version  
> of their packages. If you want to make code that runs on a 64-bit system  
> from your 32-bit system, you’ll have to use a 64-bit GCC installation (I  
> think GCC is the same for either, but you need 64-bit libc) and use -m64  
> as a compile flag.

Hmm, my “make” use using the “naked” compiler without any extra flags.  
The target system is  
a Pentium-IV, and my build system is a 32-bit Intel Core (T2400).

---

<div class="post-metadata">

**Author:** ![Marcus\_DSLeech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/74df32/32.png) [@Marcus\_DSLeech](https://www.ruby-forum.com/u/Marcus_DSLeech)\
**Post date:** [April 9, 2011, 1:19am UTC](https://www.ruby-forum.com/t/compiler-machine-compatibility/205562/4 "2011-04-09T01:19:01Z")

</div>

On 04/08/2011 01:06 PM, Nick F. wrote:

> This is the reason package maintainers keep a 32-bit and 64-bit version  
> of their packages. If you want to make code that runs on a 64-bit system  
> from your 32-bit system, you’ll have to use a 64-bit GCC installation (I  
> think GCC is the same for either, but you need 64-bit libc) and use -m64  
> as a compile flag.
> 
> –n  
> OK, so it turns out that I lied, viciously and nastily. Brazenly, even  
> 🙂

I had -msse3 turned on, which won’t work on an early Pentium 4, but will  
work on late-model Pentium 4.

So, I cranked-back the optimization flags to -msse2, which was available  
for Pentium 4.

–  
Marcus L.  
Principal Investigator  
Shirleys Bay Radio Astronomy Consortium

> **[Live Draw HK Tercepat | Result HK | HK Pools | Live HK | HK Prize Hari Ini](https://www.sbrac.org)**
>
> Temukan live draw hk tercepat melalui halaman hk pools yang resmi dan dapatkan result hk prize melalui live hk secara langsung di situs kami.
