What is the proper way to use CFLAGS? Also some questions about Sagemath

I was looking for an excuse to compile something (I like watching my computer compile stuff) and decided to compile sagemath (I figured it would start up faster if I compiled it). Of course, I wanted to use -march=native and O3 (yes I know, -O3 is not recommended). So I followed this thread and did this:

export CHOST="x86_64-pc-linux-gnu"
export CFLAGS="-march=native -O3 -pipe -fno-plt"
export CXXFLAGS="-march=native -O3 -pipe -fno-plt"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
export MAKEFLAGS="-j6"
export DEBUG_CFLAGS="-g -fvar-tracking-assignments"
export DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

So, did it work? Because now I would say Sage is slightly slower than the binary version (maybe it’s because I used -O3).
Also before compiling sage I didn’t delete my existing .sage directory. Should I have done that or is that irrelevant compilation-wise?
Also anyone have any tips on how to make sage start up faster? That is my main gripe with the programme right now


You could try something like go-preload. Look at the Arch Wiki.

So results are here

Could the slowness of the compiled version be due to a missing package, library etc.? It lives in an isolated directory, could that be the cause?
Next time I’ll compile with -O2

Thanks a lot. I guess this is just what I needed.

If you missed a library/package then it would not run.

1 Like

This topic:

Is very different to this topic:

Might be worth thinking about keeping separate topics separate.