501 questions
3
votes
1
answer
133
views
Can I avoid explicitly specifying compiler flags to get a well-optimized build?
Suppose I have a CMake project which produces a CPU-intensive application.
When I build binaries for execution on a given machine, or for performance benchmarking, I would like them to be maximally, ...
2
votes
1
answer
76
views
gcc compilation error on simple short int function call with flag -Werror=traditional-conversion
Compiling this C program with gcc 11.4.0 and -Werror=traditional-conversion raises an error:
short int f(short int x);
short int f(short int x) {
return x;
}
int main(void)
{
short int a = 0;...
0
votes
1
answer
28
views
Can't set -fbracket-depth parameter for PYMC model compilation
I'm trying to train a pymc model (version 4.4.0) on a Mac. My model is fairly complex and it seems like the current level of complexity is causing the compiler some issues because I'm getting this ...
-1
votes
1
answer
107
views
CMAKE_CXX_FLAGS is not passed to compiler: why and how to fix?
I pass compiler flags by setting CMAKE_CXX_FLAGS via command line as:
$ CC=my_llvm/clang CC=my_llvm/clang++ \
cmake -DCMAKE_AR=my_llvm/llvm-ar -DCMAKE_LD=my_llvm/lld \
-DCMAKE_CXX_FLAGS=--target=...
0
votes
0
answers
46
views
Use of MLA instruction at Optimization Level -Og in ARM GCC compiler
For the sample code below, I am using ARM GCC 10.2.1.
int myfunc(int num) {
int x,i;
for(i=0; i<10; i++)
{
x= (num*num)+i;
}
return x;}
}
When I use optimization level -O1 the following assembly ...
-1
votes
1
answer
108
views
Instantiate different classes according to different compilation flag of same header file in c++
I have a class that varies according to a compilation flag.
I would like to instantiate both the versions of the class in the same scope.
my_class.h
#ifndef MY_CLASS_H
#define MY_CLASS_H
#ifdef ...
2
votes
2
answers
153
views
Why does my C++ code with a type mismatch compile without warnings using the GCC "-Wall" flag?
I have the following code:
#include <iostream>
char add(char a, int b)
{
return a + b;
}
int main(void)
{
long long a = 100000000;
long long b = 20;
int x = add(a, b);
...
1
vote
1
answer
181
views
GCC instruction scheduling: how do the algorithms differ?
GCC offers a number of options related to instruction scheduling in the compiler flags. An overview of what this means is on the GCC Wiki for "Instruction Scheduling", but this is well out ...
0
votes
2
answers
295
views
nvcc - add flags to a specific file using cmake
I am writing a CXX+CUDA project, and I'm compiling using nvcc, with CXX compiler of icpc.
I want to add different compilation flags for icpc for different files. In CXX standalone this is possible ...
3
votes
1
answer
134
views
How can I specify flags for CMAKE_<LANG>_HOST_COMPILER?
CMake has a set of variables named CMAKE_<LANG>_FLAGS (CMAKE_CXX_FLAGS, CMAKE_Fortran_FLAGS etc.) which are used when building command-lines for compiling targets with the compilers for those ...
1
vote
1
answer
286
views
Improve g++ compiler flags for debug and release
I am making a game in c++ with sdl2, and I am currently compiling the program with g++ using the following flags:
DEBUG_FLAGS = -g -Og -DDEBUG
RELEASE_FLAGS = -O3 -DNDEBUG -mwindows -s
I want the ...
1
vote
0
answers
133
views
Puncover: Stack column is empty after analysis
I'm trying to show some stack analysis with puncover, but it doesn't work -
the column "Stack" is empty, while "Code" and "Static" are visible.
I'm using an arm-gcc ...
6
votes
2
answers
4k
views
AddressSanitizer:DEADLYSIGNAL from -fsanitize=address flag
Whenever I run any c++ code, regardless of its contents, I sometimes randomly get the following error:
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer:DEADLYSIGNAL
...
1
vote
1
answer
1k
views
How to set a CMake flag cache variable in presets without overwriting it?
Trying to follow best practice as suggested in this post, I'd like to set optional flags in the preset file and required flags in the toolchain/CMakelist. To be specific CMAKE_x_FLAGS, but I think ...
0
votes
1
answer
126
views
How to change variables in the yml to install an environment in Windows
My knowledge in linux is very limited and I have tried my best but couldn't figure this problem.
There is a python package that I have managed to install on a linux computer by following the ...
2
votes
1
answer
227
views
How should I conditionally set -isystem and -L flags in CMake?
I have a project that is to be compiled for Linux and Windows. Compilation for the former is done in a Linux environment, and compilation for the latter is done in w64devkit, i.e. I don't need to ...
0
votes
1
answer
94
views
Which specific optimization flag causes libm functions to be treated as pure?
I see that passing -ffast-math causes cmath functions like log, cos etc to be treated as pure functions as the compiler is able to perform loop-invariant code motion. As a simple example.
double ...
3
votes
0
answers
147
views
Clang ignores -mstack-alignment=XX flag
This is related to an issue described in this question -- a reproducible example can be found there, as well as a description of the environment (briefly: Apple Silicon with macOS Sonoma and clang 15)....
0
votes
1
answer
161
views
Cast variable to nibble in struct
I face the following. I have a struct like this:
typedef struct
{
uint8 nibble_1 : 4;
uint8 nibble_2 : 4;
uint8 data_1;
uint8 data_2;
uint8 data_3;
} NibbleStruct;
Background ...
1
vote
0
answers
59
views
For uint64 type flag variable, unable to give it run time value in kubernetes deployment
So I have a Go binary with the flag
commitAfter = engine.Uint64("commitAfter", 1000, "Commit After Transactions")
And I am able to set it's value while executing the binary:
./...
1
vote
0
answers
51
views
cpp: how to compute epsMachine in -Ofast
How do I compute the correct value for the machine round-off unit of a given typename in presence of arbitrary compiler optimization flags? If impossible, let's restrict the set of possible compiler ...
0
votes
0
answers
147
views
cxx compiler suggests "use quotes instead": compile option to not distinguish between quotes and angles?
I use an mpicc compiler from openmpi 4.1.5 to compile my source files on an ubuntu system.
My source code consists of a single line of code -- a header to a third-party library called deal.II:
//step-...
0
votes
0
answers
58
views
Function inlined in the header increments the wrong attribute: subtle bug
The setup (source files are listed at the bottom). There is a Counters class with 2 counter members and 2 methods to increment them and a 3rd extra #ifndef NDEBUG-guarded "debug" counter and ...
1
vote
1
answer
774
views
How to rebuild newlib under a prebuilt ARM GCC toolchain?
I normally would build the toolchain from the ground up, but it seems that ARM does not post the source for their releases, just the prebuilt toolchains. I need to rebuild the toolchain with the ...
2
votes
1
answer
524
views
Make Compile Fail on Non-Exhaustive Match in Scala 3
Since Scala 2.13, -Wconf compiler flag allows to precisely control over which warnings should be handled as errors. The configuration string for -Wconf however is not always the same when migrating to ...
2
votes
2
answers
131
views
Does even a single g++ flag warn about nullpointer dereferencing?
I wanted to check whether a g++ compiler-flag exists that warns me about nullpointer-dereferencing. When compiling this code with g++ (GCC) 13.1.1 and these compiler flags: -Wnull-dereference, -...
2
votes
1
answer
101
views
-Wlarger-than warning when using regular expressions c++
Compiling a program with anything from <regex> leads to -Wlarger-than warning and weirdly long compilation time.
While compiling this code
#include <regex>
int main()
{
std::regex ...
1
vote
2
answers
745
views
How to add custom C++ compiler flags to a conda-build flow?
How do I inject my own desired C++ compiler flags into a conda-build flow?
I tried this, in my conda_build_config.yaml file:
cxx_compiler:
- gxx # [linux]
- clangxx -Wno-c++...
2
votes
0
answers
175
views
configure: error: --with-readline=yes (default) and headers/libs are not available | R-4.2.2
I already read about this error and solutions in some forums, but i don't know what is happening.
I have this error compiling R (using GCC 12.2.0):
checking for readline/history.h... yes
checking for ...
0
votes
0
answers
440
views
Compiler flags for C++ using OpenGL, GLUT, GLEW
When I am compiling simple examples it works with the following compiler instructions, but I don't understand them in detail:
clang -o name name.cpp -L/usr/local/lib -lglfw -lGLEW -framework OpenGL
I ...
0
votes
1
answer
70
views
Prepending custom dirs ($ZPFX/{include,libs}) to CPP..../LDFLAGS with use of config.site file of autotools?
I'm using a $CONFIG_SITE set to $ZPFX/share/config.site file containing:
CPPFLAGS="-I$ZPFX/include $CPPFLAGS"
LDFLAGS="-L$ZPFX/lib $LDFLAGS"
where $ZPFX variable is my custom user ...
0
votes
1
answer
170
views
using .rodata and -fPIE in compliation [duplicate]
I'm a student currently taking a computer structures course and I have an assignement for writing in aseembly and C. I've found an issue I don't quite understand. We were given a makefile for running ...
0
votes
1
answer
128
views
compile c file from outside of workspace
I have a c file that it's located in the folder /my_test as shown below. I can run the command below successfully if I'm located on the "my_test" directory.
~/my_test$ strace -e write -f gcc ...
1
vote
1
answer
427
views
Extract compiler and linker flags from Bazel
I need to extract the compiler flags and linker flags for a certain application that is built by Bazel.
Is there a specific command to do so?
0
votes
0
answers
232
views
In GCC, how to convert a predefined optimization level into a list of finer grained optimization flags?
I'm measuring how optimization flag number affects the coverage of GCC when it is compiling some test cases. I know GCC has predefined optimization levels, such as -O1 and -O2. I also know how to ...
6
votes
1
answer
4k
views
Difference between "-fno-pie" and "-no-pie"
I don't find any useful information on the differences between "-fno-pie" and "-no-pie". Are they gcc flags or ld flags? Are they both necessary or not?
I found a piece of makefile ...
1
vote
0
answers
125
views
Makefile Flags selections
Just a general question regarding Makefile, which flags are recommended that I always have when compiling my C++ code to guarantee that the compilation is made as safe as possible ?
For now I am using ...
0
votes
1
answer
701
views
When (if ever) is it okay to use whitespace / indentation in CMake generator expressions?
The CMake documentation on generator expressions is fairly clear that "A common mistake is to try to split a generator expression across multiple lines with indenting". Here is the example ...
1
vote
1
answer
672
views
How to disable intelllisense errors in vscode when using macros defined with -D flag?
I have a CMake file which defines PROJECT_PATH macro for my project with the -D flag. I want to be able to use that macro in code to access a file relative to that path, like this:
auto file = ...
0
votes
1
answer
98
views
What do the GCC compiler messages tell me to focus on to get the loop to vectorize?
My problem: I am trying to get GCC to vectorize a nested loop.
Compiler flags I added to the basic flags:
-fopenmp
-march=native
-msse2 -mfpmath=sse
-ffast-math
-funsafe-math-optimizations
-ftree-...
0
votes
1
answer
242
views
How do I enable and get the loop vectorization report from GCC run under Code Blocks?
MY QUESTION IS: Re. loop vectorizer report generated by GCC. i get no report (optrpt.txt) also although i want a printed report what is stderr?. What compiler flags should i be using to generate the ...
2
votes
0
answers
328
views
Can the next-generation intel compiler add code-paths for multiple instruction sets?
The Intel Classic Compiler had a compilation flag -ax which I'd use to generate additional code paths for multiple instructions sets, such as AVX512, which was very convenient as I'd only build and ...
8
votes
1
answer
1k
views
Fast floating point model broken on next-generation intel compiler
Description
I'm trying to switch over from using the classic intel compiler from the Intel OneAPI toolkit to the next-generation DPC/C++ compiler, but the default behaviour for handling floating point ...
1
vote
1
answer
726
views
CMake: add compile flag for header only library
Unsure about how to use CMake properly here. I have one library, which is a template header only library which uses C++20 features. Therefore, I want to make sure that any [downstream/consumer/...
0
votes
0
answers
58
views
How to Make gcc -S main.c Produce Less Verbose Code? [duplicate]
I wanted to try and learn some assembly recently, and, having some knowledge of the C programming language, I thought that it'd be a good idea to look at the assembly equivalent of my C code.
main.c:
...
0
votes
1
answer
93
views
-Xlint doesn't warn when the inferred type arg is widened too much
Tour of Scala: Lower Type Bounds says compiling the code with -Xlint shoud give me a warning.
Here is my adaptation of the code. But I don't get any warning when I run scalac -Xlint test.scala. Why?
...
0
votes
0
answers
139
views
Can I force GCC Mips to generate integer multiplication instructions instead of shifts for known numbers?
This code here
u32 foo;
foo = foo*11
Naturally compiles assembly along the lines of
lui t3, $hi(foo)
LW t0, $lo(foo)(t3)
sll t1, t0, $3
sll t2, t0, $1
add t1, t1, t2
add t0, t0, t1
sw t0, $lo(foo)(t3)...
-2
votes
1
answer
848
views
Add compile flags per default clang++
I want to add some flags per default, so as not to type them at each compilation.
is there any way to add compile flags per default ?
Like optimisation flags or whatever. I found a solution with alias,...
0
votes
1
answer
1k
views
How to add a compiler flag to only one target in Podfile?
I have a podfile setup as below and I would like to install a compiler flag to a dependency which is installed for both "Target1" and "Target2". My problem is that I only want to ...
0
votes
1
answer
218
views
Is GCC keeping inlined version of function when linking with --gc-sections
I would like to detect unused functions in my code by using the combination of -ffunctions-sections compiler options, and the --gc-sections,--print-gc-sections
However, it shows false positive. Here ...