# Skylake CFLAGS

## Holysword

Hey there,

What CFLAGS have you guys been using for Skylake? I just got mine and I couldn't find info about it anywhere. Is march=core2 fine or will I be missing out a lot?

This is what I got previously (though I have no idea where I got it from...)

```
ABI_X86="32 64"

CHOST="x86_64-pc-linux-gnu"

CFLAGS="-march=core2"

CFLAGS="${CFLAGS} -msse4"

CFLAGS="${CFLAGS} -mcx16"

CFLAGS="${CFLAGS} -msahf"

CFLAGS="${CFLAGS} -O2"

CFLAGS="${CFLAGS} -pipe"

CXXFLAGS="${CFLAGS}"

CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" 
```

----------

## Tony0945

See my thread here: https://forums.gentoo.org/viewtopic.php?p=7867046#7867046

I would emerge the source with the experimental flag and choose the "Native optimizations autodetected by GCC  " option.

In my case I took the specific Phenom II choice, but my CPU is five years old.  I've been thinking of updating to a Skylake and would definitely do as I said.

Please let us know how it works.  You might also try the "Core i7" option that is also uncovered by the experimental use flag.

----------

## Mr_Maniac

```
-march=native -O2 -pipe
```

Should suffice. GCC will automatically use options suitable for your CPU. You can, of course, also use -O3 if you want.[/code]

----------

## Holysword

 *Tony0945 wrote:*   

> See my thread here: https://forums.gentoo.org/viewtopic.php?p=7867046#7867046
> 
> I would emerge the source with the experimental flag and choose the "Native optimizations autodetected by GCC  " option.
> 
> In my case I took the specific Phenom II choice, but my CPU is five years old.  I've been thinking of updating to a Skylake and would definitely do as I said.
> ...

 

 *Mr_Maniac wrote:*   

> 
> 
> ```
> -march=native -O2 -pipe
> ```
> ...

 

Thanks, I will check the experimental sources later. Right now I am having trouble with a kernel panic, so I want to fix that first. Also, I loved this comment:

 *NeddySeagoon wrote:*   

> As usual, if it breaks, you can keep all the pieces.

 

----------

## NeddySeagoon

Holysword,

Thats not original, it was inspired by

```
COPYRIGHT

       The  chat  program  is  in  public  domain.  This is not the GNU public

       license. If it breaks then you get to keep both pieces.
```

Using -O3 system wide is a very bad idea.  It enables options that can produce incorrect results in some circumstances.

It also enables options that make the binary bigger in an attempt to get faster execution.  The bigger binaries are faster can be true ... up to  point.  When the bigger binary no longer fits into the CPU cache, it suddenly gets much slower, due to "cache thrashing".

"Cache thrashing" also occurs between concurrent tasks, when one pushes the other out of the CPU cache.

In short, use -O3 only on a package by package basis, where its known to produce correct results and you really need the speed.

----------

## Holysword

 *NeddySeagoon wrote:*   

> Holysword,
> 
> Thats not original, it was inspired by
> 
> ```
> ...

 

Living and learning, thanks for sharing!   :Razz: 

----------

## ryszardzonk

 *NeddySeagoon wrote:*   

> In short, use -O3 only on a package by package basis, where its known to produce correct results and you really need the speed.

 

I have been using -O3 or -Ofast for several packages like multimedia libraries or app-arch, but I have read in few pleases that -O3 might be usefull for others speeding up python or sqlite, but I never found any benchmarks to confirm it. Have You found that true or perhaps know other packages that might have use of that higher CFLAGS?

----------

