# Custom Gcc



## hruodr (May 11, 2017)

Does this still hold:

https://docs.freebsd.org/doc/9.2-RELEASE/share/doc/freebsd/en/articles/custom-gcc/index.html

This article is not in the documentation of FreeBSD 11.

The question is also, if the new libraries are (still?) backward compatible.

And why the ports collections install gcc5 if there is gcc49. There is the danger of `gcc`-inflation.


----------



## SirDice (May 11, 2017)

The default is set to 5, see /usr/ports/Mk/bsd.default-versions.mk:

```
# Possible values: 4.7, 4.8, 4.9, 5, 6         
GCC_DEFAULT?=           5
```

Unless a port specifies it requires a specific version the system will use GCC5.

https://svnweb.freebsd.org/ports?view=revision&revision=437437


----------



## hruodr (May 11, 2017)

Well, the issue in the last line is now solved. After the update the default is 5. Would this not lead to inconsistencies?

And now I am thinking what CFLAGS I should put in /etc/make.conf as in the link above. Sure -msse4a.

Has someone experience with AMD?

From dmesg:


```
CPU: AMD E-350 Processor (1599.98-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x500f10  Family=0x14  Model=0x1  Stepping=0
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x802209<SSE3,MON,SSSE3,CX16,POPCNT>
  AMD Features=0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>
  AMD Features2=0x35ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,IBS,SKINIT,WDT>
```


----------



## SirDice (May 11, 2017)

hruodr said:


> And now I am thinking what CFLAGS I should put in /etc/make.conf as in the link above.


Nothing. Any "optimization" you try to do will negate all the optimizations that are already done. Unless you are a developer and know exactly what you're doing you should not set any of those flags.


----------



## hruodr (May 11, 2017)

The above aricle about custom gcc is from FreeBSD 9. Perhaps it is not anymore in the documentation due to the change to clang. 

The customization of /etc/libmap.conf according to the article was necessary for calculix due to the upgrade from gcc49 to gcc5 (and I hope the libs are backward compatible).

It remains also the question if the customization of /etc/make.conf is a problem (all ports compiled with gcc5).

And well, I think a computer is a programmable box for everyone, not only for professional developers.


----------



## SirDice (May 11, 2017)

hruodr said:


> It remains also the question if the customization of /etc/make.conf is a problem (all ports compiled with gcc5).
> 
> And well, I think a computer is a programmable box for everyone, not only for professional developers.


If you want to break your system that's your prerogative of course. But the first thing everybody is going to tell you when you run into problems is to clear /etc/make.conf. Why even go there when there's no real reason for it?


----------



## hruodr (May 11, 2017)

I have, from my few experience with clang, the impression that gcc compile faster, produce smaller (and I hope more efficient) code and complain less.


----------

