Skip to main content
Filter by
Sorted by
Tagged with
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, ...
einpoklum's user avatar
  • 130k
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;...
jarufi's user avatar
  • 23
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 ...
Jed's user avatar
  • 2,060
-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=...
pmor's user avatar
  • 6,255
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 ...
Jina Lee's user avatar
  • 119
-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 ...
Francesco Vezzi's user avatar
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); ...
Noah's user avatar
  • 43
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 ...
Greg Kennedy's user avatar
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 ...
Amit's user avatar
  • 39
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 ...
einpoklum's user avatar
  • 130k
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 ...
Invader88's user avatar
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 ...
user19471767's user avatar
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 ...
TheFortyTwo's user avatar
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 ...
RTwTools's user avatar
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 ...
K_D's user avatar
  • 147
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 ...
StoneThrow's user avatar
  • 6,235
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 ...
loonatick's user avatar
  • 1,107
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)....
swineone's user avatar
  • 2,774
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 ...
rzickler's user avatar
  • 627
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: ./...
pinnaclex's user avatar
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 ...
user avatar
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-...
SolidMechanicsFan's user avatar
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 ...
rtviii's user avatar
  • 897
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 ...
prz's user avatar
  • 25
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 ...
alessandro candolini's user avatar
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, -...
Eldinur the Kolibri's user avatar
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 ...
AVladi's user avatar
  • 21
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++...
dbanas's user avatar
  • 1,878
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 ...
euduca's user avatar
  • 33
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 ...
Maxibongo99's user avatar
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 ...
psprint's user avatar
  • 23
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 ...
someone's user avatar
  • 29
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 ...
pekoms's user avatar
  • 63
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?
Ma.Ha's user avatar
  • 11
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 ...
潇洒张's user avatar
  • 339
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 ...
Francesco's user avatar
  • 640
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 ...
Pedro Lopes's user avatar
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 ...
Neal Kruis's user avatar
  • 2,277
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 = ...
Maksymilian K's user avatar
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-...
user45664's user avatar
  • 111
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 ...
user45664's user avatar
  • 111
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 ...
Yattabyte's user avatar
  • 1,480
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 ...
Yattabyte's user avatar
  • 1,480
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/...
user93114's user avatar
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: ...
William Ryman's user avatar
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? ...
Duh Huh's user avatar
  • 139
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)...
Kaze Emanuar's user avatar
-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,...
user avatar
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 ...
Hunor Gocz's user avatar
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 ...
shodanex's user avatar
  • 15.4k

1
2 3 4 5
11