2

I have a problem with gcc 4.4.7-17. I compiled a program in a server and ran this program in another server, but it crashed because of illegal instruction.

I doubt that the difference between the two servers may cause this exception.Yes, I find that the server compiling program has CPU flag bmi1 and bmi2, but the server running the program doesn't!

How can I disable bmi instructions when using gcc?

Eric Lee
  • 45
  • 5

1 Answers1

3

-mbmi and -mbmi2 are not enabled by default.

You probably enabled them by building with -march=native on a server with different hardware from the target machine. Don't do that. Use -O3 -march=ivybridge or -march=bdver2 (AMD Piledriver = Bulldozer version 2), or whatever is appropriate to make binaries that can use all the instruction-set extensions supported by your target, and tuned for your target. (-march=x implies -mtune=x).

Also, if possible use a newer version of gcc. 4.4 is pretty old by now. gcc 5.3 is the latest version in the gcc5 series, and makes better code in many cases.

gcc6 is also released, but hasn't been out as long.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847