Questions tagged [gcc]
GCC is the GNU Compiler Collection. It's the de facto standard compiler for C, C++, Go, Fortran, and Ada on Linux and supports many other languages and platforms as well.
38,797
questions
0
votes
0
answers
2
views
How to run GCC for ARM cross compiling in WSL2 via WINE?
I'm trying to pack my Windows Toolchain into a container image. For that, I use WSL2 and Docker. To run Windows binaries, I use Wine. This works for many Windows tools, but unfortunately, gcc does not ...
0
votes
0
answers
19
views
Linux RaspberryPi: how to temporarily switch to newer GLIBC? (undefined symbol: __nptl_set_robust_list_avail)
On my Linux raspberrypi 5.10.63 (32-bit armv7l), I've built the GLIBC v2.34 from source (here are the steps). I installed the GLIBC into /opt/glibc-2.34/.
I need to use this GLIBC when I link my app ...
0
votes
0
answers
21
views
undefined reference to `log` [duplicate]
A very weird bug happened to me with gcc/9.3.0. Below is the minimal reproduced code test.c.
#include <stdio.h>
#include <math.h>
int main()
{
double tmp[] = {3.0000, 2.0000, 1.0000, ...
0
votes
0
answers
13
views
How can I better identify and fix this RISC V linker error?
I have what was a monolithic software project - Riscyforth (https://github.com/mcmenaminadrian/riscyforth) which I want to make much more extensible. That means allowing libraries to be dynamically ...
0
votes
1
answer
25
views
Interfacing external C code with duplicate method names using Cython
I want to provide a native interface to some C code from my Python code. For this I decided on Cython.
In this specific case, I have some C files which have duplicate names, resulting in compilation ...
0
votes
1
answer
18
views
Python docker image build fails due to gcc error
I am studying Nornir and want to containerize my application, here is the Dockerfile content:
FROM alpine
RUN apk update && apk upgrade
RUN apk add gcc && apk add py3-pip && ...
2
votes
2
answers
45
views
Convert static_assert in if constexpr for type checking to C++14
I am working to downgrade a C++ 17 project to C++ 14. I found the following code:
#include <iostream>
#include <type_traits>
#include <typeinfo>
template <bool flag = false>
...
2
votes
1
answer
43
views
How does the inline assembly in this compare-exchange function work? (%H modifier on ARM)
static inline unsigned long long __cmpxchg64(unsigned long long *ptr,unsigned long long old,unsigned long long new)
{
unsigned long long oldval;
unsigned long res;
prefetchw(ptr);
...
4
votes
0
answers
117
views
Why does memcpy cause compilers to seemingly forget about strict aliasing?
Consider the following C++ code:
std::uint32_t func(std::uint32_t* p1, std::uint64_t* p2) {
*p2 = *p1;
return *p1;
}
Compiling with -O3 yields the following disassembly on Clang (GCC is ...
0
votes
0
answers
22
views
Modelica external C function call to DLL results in exit with code 0xffffffffc0000135
In short, my question is: How do I build a DLL in Windows 11 using mingw-gcc that can be used as an external function for a Modelica simulation in OpenModelica?
I am able to get the simulation to ...
0
votes
0
answers
20
views
Why GCC use '-g' to debug?
I'm curious why the devlopers of GCC choose -g rather than -dbg or -d or others to flag this debug option? What does -g really mean? Does it mean 'generate' or something?
Other related questions:
...
0
votes
0
answers
22
views
`relocation R_X86_64_32S against symbol` error when accessing global variables in dynamic library with assembly codes
I'm trying to add a global data label to 64-bit assembly code which i'd like to assemble to a shared library. Part of code is as followed.
# 64bit out.s
.section .text
...
.globl export_func
.type ...
1
vote
0
answers
59
views
Compile C++ and MASM together
I'm doing an exercise of an online course about MASM, specifically a project that use both C++ and MASM.
The code of the C++ file is this:
#include <stdlib.h>
#include <iostream>
extern &...
0
votes
0
answers
33
views
How do I build a C++ image for aarch64-none-elf
Some background:
I'm writing a bare-metal C++ app/OS for the Raspberry Pi 4B (in 64-bit mode, so booting kernel8.elf off of an SD card) and I've been running into strange crashes/hangs (where logging ...
0
votes
1
answer
33
views
MSYS2 + mingw refuses to compile 64-bit vim for Windows
I was following the guide in https://github.com/vim/vim/blob/master/src/INSTALLpc.txt
(Section 2 - Msys2 with MinGW)
I've installed msys2 and ran it through the mingw64 file in the msys64 directory, ...
0
votes
0
answers
45
views
Using Attribute Scalar_Storage_Order in ada with gcc 6.2.1
I'm currently trying to find a solution to control the storage order for elements within a record in ADA.
I'm using gcc 6.2.1 which doesnt recognize the Scalar_Storage_Order attribute ( even though ...
4
votes
1
answer
129
views
Why does clang make the Quake fast inverse square root code 10x faster than with GCC? (with *(long*)float type punning)
I'm trying to benchmark the fast inverse square root. The full code is here:
#include <benchmark/benchmark.h>
#include <math.h>
float number = 30942;
static void ...
-1
votes
0
answers
7
views
How to update Conda Python 3.10.4 from GCC 7.5.0 to GCC 11.2.0
I installed Ubuntu 22.04 LTS. When I run python or python3 I get
Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
But when I got the Anaconda3 newest release and "upgraded" to python ...
0
votes
0
answers
12
views
Unable to build environment for MIT 6.828 lab using M1 chip
I am building environment using parallels ubuntu-linux-20-04.2 ARM64 but stuck on
parallels@ubuntu-linux-20-04-desktop:~/6.828/lab$ sudo make
***
*** Error: Couldn't find an i386-*-elf version of GCC/...
0
votes
1
answer
30
views
In Ubuntu gcc reports function declaration errors that did not report in macOS
I am trying to build a simple language compiler using lex and yacc with my teammate. Everything goes well on my macOS, however in win10 and Ubuntu gcc reported errors.
At first I include "lex.yy....
2
votes
1
answer
29
views
can a bare metal targeted binary be executed on a musllibc linux
my binary file compiled use toolchain from https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi.tar.xz,
with link flag:
-lstdc++ -Wl,-...
0
votes
0
answers
30
views
Compiler behavior for code intended to optimize out function call through a pointer [duplicate]
I have some C code like this:
#include <stdint.h>
typedef struct {
int16_t x1;
int16_t x2;
} XSTATE;
typedef struct {
int16_t s1;
int32_t s2;
XSTATE x;
} STATE;
typedef ...
0
votes
0
answers
58
views
Why do `gcc -v` and `whereis gcc` output different paths?
I get the following output when I run respectively gcc -v and whereis gcc:
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /...
0
votes
1
answer
20
views
Linking with TensorFlow on Arm: GLIBC_2.32, GLIBC_2.33, GLIBC_2.34 - which one?
I've built an Arm TensorFlow shared library libtensorflowlite_c.so on my Linux machine using the Linux->Arm crossbuild toolchain.
Then I switched to Arm platform and tried to build an app linked ...
0
votes
0
answers
49
views
Error: make: *** No rule to make target `.f90', needed by `.o'. Stop
I'm trying to run a case for the software [ExoPlaSim] (https://github.com/alphaparrot/ExoPlaSim) on my MacBook.
While the software is built primarily for Linux, it can run on Mac according to the ...
0
votes
1
answer
21
views
gcc -M flag (phony runes) fast compilation
I have a relatively large project, it's compilation takes normally 13 mins.
I was trying to optimize it's compilation and I saw the -M flag in gcc man, it has something to do with phony rules in ...
0
votes
0
answers
14
views
Defining TOC & SDA in GNU-PPC Linker Script
Im using the GCC Compiler for Tricore and PPC since a while.
On the PPC side, i didn't figured out until now, how i can define TOC & SDA addresses for the compiler to use to shorten the code.
Im ...
0
votes
0
answers
38
views
Aarch64 GCC equivalent option for "-mfpu=neon"?
I have a C code which uses Neon Intrinsics which will run in a Raspberry Pi 4 (Cortex-A72).
When I compile the code with the built-in GCC:
In Raspberry Pi OS 32-bits (ARM - armv7l), if I run
gcc -o ...
0
votes
0
answers
13
views
How to fix /bin/sh: gcc-11.3.0_1: command not found
When trying to install RTidyHTML remotely from Github on RStudio (2022.02.2 Build 485) with R version 4.2.0, I'm told /bin/sh: gcc-11.3.0_1: command not found. This is after installing gcc through ...
0
votes
0
answers
18
views
How to compile C code with Neon Intrinsic on 64 bit raspberrypi4 running Linux (using either gcc or clang)?
Q: Which compiler options should be used to compile C code with NEON intrinsic
using #include <arm_neon.h> on raspberry-pi4 (cortex-a72, neon-fp-armv8) running a 64bit Linux OS (Ubuntu)?
On ...
0
votes
1
answer
19
views
C++ debugging doesn't start in vscode
I am Windows 10 with Cygwin installed. I am able to run c++ code from vscode's terminal as follows:
However I am not able to configure the debug file in vscode.
When I try to add launch configuration,...
0
votes
1
answer
25
views
g++ cannot change include path with -I
I'm on kubuntu using g++ 7.5.0 / GNU make for C++. My file structure:
bin
| .o files
header
|archiver.h
source
|main.cpp
|archiver.cpp
makefile
I want my source files to be able to detect header ...
0
votes
1
answer
32
views
C++: CLion error: the clang compiler does not support '-march=core2
I have a problem with CLion compilation after updating CL tools - it must have overwritten some configurations in gcc/clang, but can't see how to change them.
When trying to compile with CLion or ...
0
votes
1
answer
25
views
aarch64-gcc simd inline asm, result always 0
I try to do SIMD multiplication with inline assembler. However, the result is always zero or (in other cases) gets ununderstandable (for me) values.
#include <stdio.h>
int main(void)
{
...
0
votes
1
answer
39
views
Creating list of unique_ptr using initialization list and make_unique fails in GCC 5.4
I am using GCC 5.4 for compiling a test program in C++ 14.
#include <type_traits>
#include <list>
#include <iostream>
#include <memory>
int main()
{
int VALUE = 42;
...
0
votes
0
answers
79
views
Install GCC compiler without having C compiler [duplicate]
I have a problem that has caused me quite a few headaches and I would like some help from one of you.
I have a Linux operating system installed on my computer. The problem is that it doesn't have the ...
1
vote
0
answers
13
views
ld_library_path does not work in makefile
The makefile has the following commands:
exrtl:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:libs
clean:
export LD_LIBRARY_PATH=""
But nothing happens after them. If you then ...
0
votes
0
answers
13
views
How can I convert an .ll file to an object without LLC, or can I use LLC with a language not in the C family?
I've built my own compiler for a language with a custom extension, out of boredom. It's very bare-bones at the moment, but to proceed I want to use LLC to convert the .ll file generated by my LLVM ...
1
vote
1
answer
43
views
Redirect a raw C array data into a data file in embedded system industries
I have seen some codes that have no function. They just have data and the file is supposed to be converted to a data file not an executable.
For example, it is something like
config.c
const unsigned ...
0
votes
0
answers
37
views
I can get my shellcode to execute when my program is compiled using gcc-3.4(older version), but it doesn't work when compiled on newer versions of gcc
I am on Linux. The hack I am trying get to work is a buffer overflow which overflows into the return address of the program's main() stackframe replacing it with the address pointing to the ...
0
votes
0
answers
21
views
Building GCC 11.2 on Amazon Linux 2
While attempting to build GCC version 11.3 for Linux-x86_64 (with multilib and multiarch support enabled), I am getting the following error:
In file included from /usr/include/features.h:447,
...
-3
votes
0
answers
21
views
Receiving error in C language on VS Code, using gcc. Sending its screenshot. I have started coding today only so have no idea about it
Error in VS Code Terminal panel for C programming using gcc
1
vote
1
answer
58
views
Declaration vs definition: is GCC wrong?
According to ISO9899:2017 § 6.7-5:
A declaration specifies the interpretation and attributes of a set of
identifiers. A definition of an identifier is a declaration for that
identifier that: — for an ...
2
votes
1
answer
85
views
Why does gcc use the size-aware delete operator by default when optimizing?
If I define my own new and delete operators as shown below:
#include <cstdio>
#include <cstdlib>
#include <new>
void* operator new (size_t count)
{
printf("Calling custom ...
1
vote
1
answer
34
views
How to link a subfolder with gcc in C?
I have the below tree:
├── cminpack
│ ├── hybrd.c
│ ├── hybrd.o
│ ├── hybrj1.c
│ ├── hybrj1.o
│ ├── hybrj.c
│ ├── hybrj.o
│ ├── libminpack.a
│ ├── Makefile
│ ├── minpack.h
│ ├── ...
1
vote
2
answers
87
views
std::aligned_alloc() never returns a null pointer. How?
I am using std::aligned_alloc() in one of my projects to allocate aligned memory for optimized PCIe read/write.
When I read about aligned_alloc from here, it says:
Defined in header <stdlib.h>
...
4
votes
1
answer
89
views
Inline assembly array sum benchmark near-zero time for large arrays with optimization enabled, even though result is used
I have written two functions that gets the sum of an array, the first one is written in C++ and the other is written with inline assembly (x86-64), I compared the performance of the two functions on ...
9
votes
0
answers
120
views
Disable every single gcc extensions (C++)
The title is quite clear, is there a way to disable every single non-standard feature of gcc (extension) when compiling some C++ code. I've previously always used -pedantic-errors alongside -Wall and -...
42
votes
1
answer
3k
views
Is this GCC 12.1 const problem a bug or feature? "Attempts to call non-const function with const object"
We're seeing C++ code, that compiles successfully in GCC 11.3 and Visual Studio 2022, have issues with GCC 12.1. The code is on Compiler Explorer: https://godbolt.org/z/6PYEcsd1h (Thanks to @...
1
vote
0
answers
55
views
Accidentally compiled my c file into [readonly][noeol][converted] in Ubuntu Vim
I am a new programer and while trying to compile my .c file in the Ubuntu terminal I accidentally wrote:
gcc -o file.c file -Wall
Instead of:
gcc -o file file.c -Wall
Now I have a file marked as [...