virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

Compilation with -march=native option

Open smoretti opened this issue 6 months ago • 4 comments

Hi Do you recommend, or not, to use -march=native as compilation option?

Instead of simply -O2 -m64 on Linux

smoretti avatar Jun 05 '25 13:06 smoretti

If you are building and running Virtuoso on the same machine then the answer is ~~yes~~ NO (see my reply below)

However if you are building on a different CPU architecture and/or OS distribution, then the resulting binary may not work on the target machine.

openlink avatar Jun 06 '25 10:06 openlink

So, on the same machine you recommend it over -m64 for Linux (CFLAGS="-O2 -m64")?

smoretti avatar Jun 06 '25 11:06 smoretti

As a result of your question, i have been testing some -march and -O combinations on my Ubuntu 24.04 Noble Numbat system, using the following C compilers:

$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ clang --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Several combinations of compiler, optimiser flags, and CPU flags (including -march=native), produced a binary that did not pass the virtuoso test-suite in one way or another.

I will likely post an article on our Community Server at some point, which will describe some combinations that do work properly in our eyes.

Therefore, unless the user knows exactly what they are doing, my recommendation would be to continue using CFLAGS="-O2 -m64 , as these are tried and tested flags that we know will work on all versions of compilers and glibc versions up to and including the latest gcc 15.1 release on Debian testing.

pkleef avatar Jun 10 '25 09:06 pkleef

OK, while waiting for more tests, will keep CFLAGS="-O2 -m64"

smoretti avatar Jun 10 '25 16:06 smoretti