# Building GCC without AVX 2



## sickboy (Apr 20, 2017)

Hi everyone,

I’m using Poudriere to build by FreeBSD packages on a remote server. The server has an Intel Xeon D-1541 processor with support for the AVX 2 instruction set. The packages are also in use on my local machines, which have an Core i7-3520M resp. Core i5-4670K without AVX 2.

Building GCC (4.9, 5.4) on the server leads to the problem that the packages are build against AVX 2, and because of that, some compilers, like `gfortran`, won’t run on my local machines. For instance, trying to run `gfortran` on my Core i5:


```
> gfortran49 test.f08 -o test
<built-in>: internal compiler error: Illegal instruction
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
```

How can I disable AVX 2 for GCC?


----------



## talsamon (Apr 20, 2017)

Try `-mno-avx2` for the above test. Building GCC without
avx2 is hack in the configure files ..I think disabling build target avx2.


----------



## sickboy (Apr 21, 2017)

No difference:

```
> gfortran49 -mno-avx2 test.f08 -o test
<built-in>: internal compiler error: Illegal instruction
no stack trace because unwind library not available
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
```


----------



## talsamon (Apr 21, 2017)

It should also possible to build lang/gcc with `-mno-avx2`, but I am not clear if it causes problems with SSEx.


----------



## sickboy (Apr 25, 2017)

Altering the CFLAGS in the make.conf of the Poudriere Jail did not solve the problem:

```
CFLAGS="-mno-avx2"
CXXFLAGS="-mno-avx2"
```
After rebuilding `gcc49` I still can’t compile Fortran code on the local machines.


----------



## talsamon (Apr 25, 2017)

I would say the best address for your question is the
maintainer of lang/gcc.. The mail address
is in the port Makefile. Or run
`make -C /usr/ports/lang/gcc5 maintainer`.


----------

