I have moved from gcc version 4.0.3 to 4.3.3 and realized that -mfpmath was set to sse by default in gcc 4.3.3. This actually caused errors in my application.
In 4.0.3 the -mfpmath was 387.
I want to know how I can get all the default options enabled by gcc for a given version.
How can I dump set of all options used by gcc while compiling.
This enables me to compare version 4.0.3 vs 4.3.3.
In general it will be great if I can know a comprehensive list of things need to be checked before going for a version change in gcc .(As this has effect on performance and functionality.)
gcc -Q -v
With just a basic tiny c or cpp file as an input file. Should give you a big list of all the options passed to gcc by default, one of those might be causing sse fp math to be enabled.
In addition to compiling a specific file -Q -v, which outputs the list of passed and enabled options, as well as a lots of other version, configuration, and timing information, you can also use gcc -Q --help=target to just list default target-specific compiler options:
$ gcc --version | head -1
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
$ gcc -Q --help=target
The following options are target specific:
-m128bit-long-double [disabled]
-m32 [disabled]
-m3dnow [disabled]
-m3dnowa [disabled]
-m64 [enabled]
-m80387 [enabled]
-m8bit-idiv [disabled]
-m96bit-long-double [enabled]
-mabi=
-mabm [disabled]
-maccumulate-outgoing-args [disabled]
-maes [disabled]
-malign-double [disabled]
-malign-functions=
-malign-jumps=
-malign-loops=
-malign-stringops [enabled]
-mandroid [disabled]
-march= x86-64
...
To also include a list of target-specific assembler and linker options (but not currently their default settings), use --target-help instead of --help=target.
In addition to -Q --help=target for target-specific options, you can use -Q -O<n> --help=optimize to display which optimizer passes are on or off at a given optimization level. -Q also appears to work by itself with other --help=<blah> arguments as well.
The version I've here of gcc 4.3.3 hasn't the behavior you are complaining about. I compiled it myself so I'm pretty sure that there must be another reason for the change you are seeing than just the gcc version (like compiling for 64 bit which has always used sse AFAIR).
gcc has release notes which notifies of behavior changes. They are packaged with gcc source distribution and are available on the web. For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html.
Related
I'd like to ensure that a large set projects are build with the -fno-omit-frame-pointer flag for easier debugging with tools like ebpf.
One way of course would be to modify the build scripts of each of these projects, but that is a lot of work.
I've come across the possibility to configure gcc with --enable-frame-pointer which restores the old default from the early gcc4.x days of using -fno-omit-frame-pointer.
I've built gcc from source like that and confirmed:
❯ ./bin/gcc -m32 -O3 -Q --help=optimizers | grep omit
-fomit-frame-pointer [disabled]
❯ ./bin/gcc -m64 -O3 -Q --help=optimizers | grep omit
-fomit-frame-pointer [enabled]
Is anyone aware of a possibility to extend the effect of --enable-frame-pointer to the 64bit targets?
I believe you are using an older version of GCC because support of this flag on x64 has been enabled some time ago (see e.g. this commit).
I'm trying to compile C code on a Jetson Nano and I get this error during compiling. I tried removing any occurrence of 'm -64' but it seems like its added automatically. This is the cmd where it fails: /usr/bin/gcc-7 -Wall -Wextra -Wconversion -pedantic -Wshadow -m64 -Wfatal-errors -O0 -g -o CMakeFiles/dir/testCCompiler.c.o -c /home/user/dir/CMakeFiles/CMakeTmp/testCCompiler.c
uname -a: Linux jetson-nano 4.9.140-tegra aarch64 aarch64 aarch64 GNU/Linux
gcc-7 -v: Using built-in specs.
COLLECT_GCC=gcc-7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/7/lto-wrapper
Target: aarch64-linux-gnu
gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)
CMAKE_C_COMPILER = gcc-7
CMAKE_CXX_COMPILER = g++-7
CXX_COMPILE_FLAGS = "-Wall -Werror -Wextra -Wnon-virtual-dtor -Wconversion -Wold-style-cast -pedantic -Wshadow"
C_COMPILE_FLAGS = "-Wall -Wextra -Wconversion -pedantic -Wshadow"
gcc-7: error: unrecognized command line option ‘-m64’
error: unrecognized command line option ‘-m64’
I believe you are looking for -march=armv8-a (and friends), and not -m64. The GCC arm64 options are available at 3.18.1 AArch64 Options in the manual.
Aarch64 includes ASIMD in the base specification, so there are no extra gyrations needed for it. ASIMD is "Advanced SIMD instructions", and it is what ARM calls NEON on the Aarch32 and Aarch64 architectures.
If you want to enable extensions, like CRC or Crypto, then the option would look like -march=armv8.1-a+crc or -march=armv8.1-a+crypto or -march=armv8.1-a+crc+crypto.
The equivalent x86 options would be the following. Obviously, the ARM port of GCC does not use the same model as x86. It is confusing for new users (or it was confusing for me).
-march=armv8-a → -msse2
-march=armv8.1-a+crc → -msse2 -msse4.1
-march=armv8.1-a+crypto → -msse2 -mpclmul -maes
-march=armv8.1-a+crc+crypto → -msse2 -msse4.1 -mpclmul -maes
ARM instruction set includes SHA in crypto, so the x86 options should probably include -msha. The problem is, x86 SHA did not arrive until about 8 years after carryless multiplies and AES.
Also, GCC ARM compilers usually don't understand -march=native. On older GCC compilers, the compiler will just crash. On mid-ranged GCC it is simply ignored. I believe the latest GCC compilers honor it.
This error often happens when cross-compiling with Rust/Cargo, because Cargo isn't smart enough to find cross-build tools by itself.
You need to set appropriate env vars. In the example replace x86_64_unknown_linux_gnu with your target, and paths to your cross-build paths (the example is for Debian). Watch out the env vars are case-sensitive and inconsistently named!
# for the cc crate
export HOST_CC=gcc
export CC_x86_64_unknown_linux_gnu=/usr/bin/x86_64-linux-gnu-gcc
# for Cargo
export CARGO_TARGET_X86_64-UNKNOWN-LINUX-GNU_LINKER=/usr/bin/x86_64-linux-gnu-gcc
I was trying some vectorisation after upgrading g++ from version 4.8.5 to 5.4.1. With this flags:
g++ particles-v3.cpp -o v3 -O3 -msse4.2 -mfpmath=sse -ftree-vectorizer-verbose=5 -ffast-math -m32 -march=native -std=c++11
While the same command gives over 4000 lines of detailed information about the vectorization with g++-4.8, with g++-5.4 it does not say anything.
Is there some major change in g++-5 that makes the -ftree-vectorizer-verbose=X unusable, or is there simply somethin wrong in the line? How to change it so that it works?
EDIT:
found out that using -fopt-info-vec-all gives exacty the info I wanted. Thus question solved.
I experienced crashes running an old code of mine on a system which doesn't support SSE4.1, I debugged a bit and found SSE instructions in the glibc, is that possible? Why isn't this reported in gcc 4.8.1 release notes?
You can see what optimizations are used by GCC with the following command:
$ gcc -Q --help=target
For instance, on my machine, GCC does not enable sse4.1 by default:
$ gcc -Q --help=target | grep msse4.1
-msse4.1 [disabled]
However, it is supported because it appears in /proc/cpuinfo. And indeed, if I ask GCC to optimize the generated code for my machine, it enables sse4.1:
$ gcc -Q --help=target -march=native | grep msse4.1
-msse4.1 [enabled]
What's the meaning of the -O4 optimization flag in gcc (3.2.3)? What's the difference to O3? When would you use one vs. the other?
The man pages only mention O, O0-3, Os, no word of the mysterious O4. Thanks!
There is no -O4 in 3.2.3.
Everything above -O3 results in -O3 being chosen.
You can check what optimization are enabled for each level
gcc -c -Q -O3 --help=optimizers | grep enabled
It works at least for gcc 4.4.