/r/gcc

Photograph via snooOG

Created by the GNU project GCC is a compiler system for C, C++, Objective-C, Fortran, Java, Ada, and Go.

Created by the GNU project GCC is a compiler system for C, C++, Objective-C, Fortran, Java, Ada, and Go.

Related Subreddits

/r/gcc

2,349 Subscribers

0

Famous in Kuwait

Kuwait is famous for several things, including:

  1. Kuwait Towers – Iconic landmarks of the country, offering panoramic views of Kuwait City.

  2. Oil Industry – One of the world's largest oil producers with a significant impact on the global energy market.

  3. The Grand Mosque – The largest mosque in Kuwait, known for its stunning architecture.

  4. Souq Al-Mubarakiya – A historic market offering traditional Kuwaiti goods, spices, and souvenirs.

  5. Modern Skyscrapers – Such as Al Hamra Tower, one of the tallest buildings in the region.

  6. Failaka Island – A historical island with archaeological sites from ancient civilizations.

  7. Kuwaiti Cuisine – Known for dishes like Machboos (spiced rice with meat) and Mutabbaq Samak (fish with rice).

  8. Shopping Malls – Luxury shopping destinations like The Avenues, one of the largest malls in the Middle East.

  9. Maritime Heritage – Traditional dhow-building and the historic pearl-diving industry.

  10. Hospitality & Culture – Kuwaiti culture is deeply rooted in Arabian traditions and generosity.

Would you like details on any of these?

1 Comment
2025/02/03
22:26 UTC

1

Ancient gcc compared to more recent versions

Hi, I seem to recall reading a blog post years ago comparing the performance of code compiled with 2.95 versus a more modern version (7 perhaps?). Does someone have a link for that ? I'm curious about the gains in execution speed due to the compiler optimizations alone, for example comparing the encoding/decoding performance of a recent ffmpeg compiled with gcc 4 vs 14.

0 Comments
2025/02/03
15:15 UTC

1

crt0.o don't linking to 0x10000

Hi, I intend to use a custom newlib, but the linker is not linking crt0.o to the 0x10000 (I made an error in the post title) location. Instead, it's linking _start to:

000000000001037c <_start>:

The first .text executable section is:

0000000000010120 <__do_global_dtors_aux>:

I'm using the internal link script of riscv64-unknown-ld. Here's my compilation command:

riscv64-unknown-elf-gcc -march=rv64imafdc_zicsr -mcmodel=medany -mabi=lp64d -Wall -fno-builtin --save-temps -nostartfiles -nostdlib -nodefaultlibs -g gcc/rv64imafdc/lp64d/crti.o gcc/rv64imafdc/lp64d/crtbegin.o -o output.elf msetteste.o platform.o memset.o syscall.o build-gcc-newlib-stage2/gcc/rv64imafdc/lp64d/crtend.o build-gcc-newlib-stage2/gcc/rv64imafdc/lp64d/crtn.o build-newlib/riscv64-unknown-elf/rv64imafdc/lp64d/libgloss/riscv/crt0.o build-newlib-nano/riscv64-unknown-elf/newlib/libc.a build-newlib-nano/riscv64-unknown-elf/newlib/libm.a riscv64-unknown-elf/newlib/libg.a build-gcc-newlib-stage2/gcc/rv64imafdc/lp64d/libgcc.a build-gcc-newlib-stage2/gcc/rv64imafdc/lp64d/libgcov.a

Can someone help me figure out why the linker is not placing crt0.o at the correct location?

0 Comments
2025/01/18
15:49 UTC

2

Any books to learn about the details of GCC?

I want to learn the applications and maybe some implementation details...

Please tell me some resources that can help me go on the deep dive into these and help make code better!

3 Comments
2025/01/14
16:22 UTC

1

Newbie needs help

Just started to do programming for C/C++ and I got this issue when I tried to run a basic output.The issue is always saying

gcc: error: missing filename after '-o'

Could someone please help me out here?

2 Comments
2025/01/04
17:45 UTC

1

Modula-2 in GCC

Hello, it's been 35 years since I last programmed. But I have an itch to fiddle with Modula-2. (Long story). I understand Modula-2 is now in GCC. I don't know a thing about GCC. I assume it's all command line? I'm on x86. What would be an appropriate IDE? Any GUI tools? I need a Dummies level advice on install and use. Thanks and Happy New Year.

2 Comments
2025/01/01
16:18 UTC

1

Does libgo require kqueue?

Just for fun, as I've patched GCC 6.5.0 for IRIX, I decided to try building libgo:

https://pastebin.com/dUrTrP3x

This happened. Do I have to have a kqueue implementation to run libgo or is this a case of mistaken OS identity? I haven't messed with/added any code to libgo to make it identify IRIX, my fixes were entirely to the C/C++ and GCC core.

0 Comments
2024/12/24
21:53 UTC

4

How to tell libstdc++v3 we don't have functional wcstof?

Building libstdc++v3 on an obsolete architecture. The architecture is not important but unfortunately we are having an issue building it. We are attempting to build GCC 4.8.5. basic_string.h pulls in our wchar headers, which block use of wcstof unless c99. I have tried modifying the system headers: it doesn't work. GCC believes that it's not a member of std.

This system does not have glibc, and it has notoriously broken multibyte. I know that GCC can get around this issue because I have seen it done before with other missing C/C++ functions. I'm sure it has its own implementation somewhere. How do I tell libstdc++v3 to use that during compilation instead of the system one?

For the record, the header in question and it's internal guard the function using the __c99 macro. But here's the interesting thing, even if I start the building entirely over and guard it further using GNUC to exclude its ability to use that function, the pre-processor doesn't care (or presumably another macro overwrites it???)

Some versions of the compiler on this OS potentially have a fixinclude to fix this, but they produce broken code and don't allow a functional libstdc++v3. Cannot do cross compilation, because that equally has in the past broken shit.

Is there a definitive flag that I can pass to to this, or better yet, how can I tell GCC to just use the libstdc++v3 in use by the current compiler instead of trying to build it? It's only one major version apart (4.7.4) so it might work well enough.

9 Comments
2024/12/21
07:29 UTC

1

Configuring GCC to enable monotonic and realtime clocks

Hi all, I've been tinkering with GCC trying to build a RISC-V compiler from source, attempting to get a couple macros supporting realtime and monotonic clocks to be enabled in the libstdc++ header "c++config.h".

I got my source from the riscv-gnu-toolchain repo.

Specifically I want to enable the macros _GLIBCXX_USE_CLOCK_REALTIME and _GLIBCXX_USE_CLOCK_MONOTONIC so I can use them in my software's clock_gettime implementation.

I tried setting the configure flag --enable-libstdcxx-time=yes as that seems to vaguely relate to the clocks, but I haven't had any luck. Been looking at documentation for awhile now and figured I could ask for some help.

Here's the configure + make command I'm using:

../riscv-gnu-toolchain/configure --prefix=/nobackup/builddir/riscv64-unknown-elf --with-target-cflags=-Os -mcmodel=medany" --with-target-cxxflags="-Os -mcmodel-medany" --enable-multilib --with-abi=lp64d
--with-arch=rv64imafdc_zicsr_zifencei --with-languages=c,c++

GCC_EXTRA_CONFIGURE_FLAGS="--enable-libstdcxx-time=yes" make

2 Comments
2024/12/18
23:48 UTC

2

No warning when using uninitialized local variable.

Hi. I can't find the compiler flags to trigger a warning for the following code that clearly uses an unitialized local variable.

#include <stdio.h>

void f1(){
        char secret[]="secret";
        printf("f1 %s\n", secret);
}

void f2() {
        char not_secret[7];
        printf("f2 %s\n", not_secret);
}

int main(){
        f1();
        f2();
}

Compile with

gcc -O1 -pedantic -Wall -Wextra -Wmaybe-uninitialized -Wuninitialized -Winit-self f1.c 

And run:

./a.out
f1 secret
f2 secret

I've added a link to this on godbolt

Can anyone suggest how to trigger a warning on this code?

gcc --version
gcc (GCC) 13.2.0
...
2 Comments
2024/12/11
16:47 UTC

1

Binary conversion identifier %b with GCC 14.2.0 on Windows

Hi,

I encountered a problem using GCC 14.2.0 (with VS Code and the latest version of MinGW-w64 on a Windows 11 system).

This is the problem: I have not found a way to get printf() to print a binary value: using the binary conversion identifier %b in the format string all I get is printing the character 'b'.

Conversely, declaring a variable with the prefix %b seems to work correctly: int a = 0b11, assigns the value 3 to the integer variable a as you would expect.

(I set the option "-std=c23" in tasks.json configuration file, and got '202000' as __STDC_VERSION__ value)

Am I doing something wrong?

Thanks in advance.

4 Comments
2024/12/09
23:05 UTC

6

Why does GCC allow function calls without required parameters?

I haven't used GCC in a while, but I'm doing some development on a Raspberry Pi Pico and that's the default compiler in the provided toolchain.

I encountered some perplexing behavior, then noticed that I'm calling a function without any of the parameters it requires. Why does this compile? I did a search on the issue, but it's surprisingly hard to find an answer; it seems that most people ask about the opposite scenario (calling a function with unspecified parameters).

My function is declared:

void setUpEncoder(uint gpio_a, uint gpio_b, uint gpio_switch)

but the compiler doesn't complain when I call it like

    setUpEncoder();

Why?

This is the build command:

/Users/me/.pico-sdk/toolchain/13_3_Rel1/bin/arm-none-eabi-gcc -DLIB_BOOT_STAGE2_HEADERS=1 -DLIB_PICO_ATOMIC=1 -DLIB_PICO_BIT_OPS=1 -DLIB_PICO_BIT_OPS_PICO=1 -DLIB_PICO_CLIB_INTERFACE=1 -DLIB_PICO_CRT0=1 -DLIB_PICO_CXX_OPTIONS=1 -DLIB_PICO_DIVIDER=1 -DLIB_PICO_DIVIDER_HARDWARE=1 -DLIB_PICO_DOUBLE=1 -DLIB_PICO_DOUBLE_PICO=1 -DLIB_PICO_FLASH=1 -DLIB_PICO_FLOAT=1 -DLIB_PICO_FLOAT_PICO=1 -DLIB_PICO_INT64_OPS=1 -DLIB_PICO_INT64_OPS_PICO=1 -DLIB_PICO_MALLOC=1 -DLIB_PICO_MEM_OPS=1 -DLIB_PICO_MEM_OPS_PICO=1 -DLIB_PICO_NEWLIB_INTERFACE=1 -DLIB_PICO_PLATFORM=1 -DLIB_PICO_PLATFORM_COMPILER=1 -DLIB_PICO_PLATFORM_PANIC=1 -DLIB_PICO_PLATFORM_SECTIONS=1 -DLIB_PICO_PRINTF=1 -DLIB_PICO_PRINTF_PICO=1 -DLIB_PICO_RUNTIME=1 -DLIB_PICO_RUNTIME_INIT=1 -DLIB_PICO_STANDARD_BINARY_INFO=1 -DLIB_PICO_STANDARD_LINK=1 -DLIB_PICO_STDIO=1 -DLIB_PICO_STDIO_UART=1 -DLIB_PICO_STDLIB=1 -DLIB_PICO_SYNC=1 -DLIB_PICO_SYNC_CRITICAL_SECTION=1 -DLIB_PICO_SYNC_MUTEX=1 -DLIB_PICO_SYNC_SEM=1 -DLIB_PICO_TIME=1 -DLIB_PICO_TIME_ADAPTER=1 -DLIB_PICO_UTIL=1 -DPICO_32BIT=1 -DPICO_BOARD=\\\"pico\\\" -DPICO_BUILD=1 -DPICO_CMAKE_BUILD_TYPE=\\\"Debug\\\" -DPICO_COPY_TO_RAM=0 -DPICO_CXX_ENABLE_EXCEPTIONS=0 -DPICO_NO_FLASH=0 -DPICO_NO_HARDWARE=0 -DPICO_ON_DEVICE=1 -DPICO_RP2040=1 -DPICO_TARGET_NAME=\\\"hello_pwm\\\" -DPICO_USE_BLOCKED_RAM=0 -I/Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_atomic/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_stdlib_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_gpio/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_base_headers/include -isystem /Users/me/data/pi/pico/hello_pwm/build/generated/pico_base -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/boards/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2040/pico_platform/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2040/hardware_regs/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_base/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_platform_compiler/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_platform_panic/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_platform_sections/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2040/hardware_structs/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/hardware_claim/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_sync/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_sync_spin_lock/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_irq/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_uart/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_resets/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_clocks/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_pll/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_vreg/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_watchdog/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_ticks/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_bootrom/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/boot_picoboot_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/boot_bootrom_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_boot_lock/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_flash/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_time/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_timer/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_sync/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_util/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_time_adapter/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_xosc/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_divider/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_runtime/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_runtime_init/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_bit_ops_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_divider_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_double/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_float/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_malloc/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/pico_binary_info/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_printf/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_stdio/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_stdio_uart/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_multicore/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/common/boot_picobin_headers/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_int64_ops/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/pico_mem_ops/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2040/boot_stage2/include -isystem /Users/me/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_pwm/include -mcpu=cortex-m0plus -mthumb -Og -g -std=gnu11 -ffunction-sections -fdata-sections -o CMakeFiles/hello_pwm.dir/hello_pwm.c.o -c /Users/me/data/pi/pico/hello_pwm/hello_pwm.c

6 Comments
2024/12/07
02:34 UTC

2

32-bit pointers on 64-bit target?

Are there any runtime flags and/or compile-time configuration options in GCC which would allow the use of 32-bit pointers on a 64-bit system? I have a system here (Xbox 360, powerpc64-be) who's OS uses 32-bit memory addressing but is 64 bit.

Of course, there are other changes which need to be made to the GCC code but I am just asking about the memory addressing as I cannot find any resources on doing such a thing.

Thanks in advance.

7 Comments
2024/12/06
04:35 UTC

3

Looking for a list of compiler recognised expressions

Anything in the math/bitwise operation range I'm looking for. For example the commonly recognised #define ROR (((A) << (B)) | ((A) >> ((sizeof(B) * CHAR_BIT) - (B))) which when used on say uint C = ROR(10u,30); would instead be compiled down to uint C = 0x10000010u;

Currently what I'm trying to put in that context is these 5:

/* BitWise Sign bit */
#define TEMPLATE_FORMULA_PAWINT_BWS(N) \
	({(__typeof__(N)) X = 1; X << (bitsof(X) - 1);})

#define PAWINT_BWS(N) _Generic((N), \
	int: NPAWD_MIN, \
	unsigned int: NPAWD_MIN, \
	long: NPAWLD_MIN, \
	unsigned long: NPAWLD_MIN, \
	long long: NPAWLLD_MIN, \
	unsigned long long: NPAWLLD_MIN, \
	default: TEMPLATE_FORMULA_PAWINT_BWS )

/* Count Leading Zeros */
#define TEMPLATE_FORMULA_PAWINT_CLZ(N) \
	({ \
		pawru num = 0; \
		__typeof__(N) X = N; \
		const __typeof__(N) L = TEMPLATE_FORMULA_PAWINT_BWS(N); \
		for ( __typeof__(N) X = N; X && !(X & L); X <<= 1, ++num ); \
		num; \
	})

#define PAWINT_CLZ(N) _Generic((N), \
	int: __builtin_clz, \
	unsigned int: __builtin_clz, \
	long: __builtin_clzl, \
	unsigned long: __builtin_clzl, \
	long long: __builtin_clzll, \
	unsigned long long: __builtin_clzll, \
	default: TEMPLATE_FORMULA_PAWINT_CLZ )

/* Count Trailing Zeros */
#define TEMPLATE_FORMULA_PAWINT_CTZ(N) \
	({ \
		pawru num = 0; \
		__typeof__(N) X = N; \
		for ( ; X && !(X & 1); X >>= 1, --num ); \
		num; \
	})

#define PAWINT_CTZ(N) _Generic((N), \
	int: __builtin_ctz, \
	unsigned int: __builtin_ctz, \
	long: __builtin_ctzl, \
	unsigned long: __builtin_ctzl, \
	long long: __builtin_ctzll, \
	unsigned long long: __builtin_ctzll, \
	default: TEMPLATE_FORMULA_PAWINT_CTZ )

/* Find First Set bit */
#define TEMPLATE_FORMULA_PAWINT_FFS(N) \
	({ \
		pawru pos = 0; \
		__typeof__(N) X = N; \
		for ( ; X && !(X & 1); X >>= 1, ++pos ); \
		pos; \
	})

#define PAWINT_FFS(N) _Generic((N), \
	int: __builtin_ffs, \
	unsigned int: __builtin_ffs, \
	long: __builtin_ffsl, \
	unsigned long: __builtin_ffsl, \
	long long: __builtin_ffsll, \
	unsigned long long: __builtin_ffsll, \
	default: TEMPLATE_FORMULA_PAWINT_FFS )

/* Find Last Set bit */
#define TEMPLATE_FORMULA_PAWINT_FLS(N) \
	({ \
		__typeof__(N) X = N; \
		pawru pos = bitsof(X); \
		const __typeof__(N) L = TEMPLATE_FORMULA_PAWINT_BWS(N); \
		for ( ; X && !(X & L); X <<= 1, ++pos ); \
		pos; \
	})

#define PAWINT_FLS(N) _Generic((N), \
	int: __builtin_fls, \
	unsigned int: __builtin_fls, \
	long: __builtin_flsl, \
	unsigned long: __builtin_flsl, \
	long long: __builtin_flsll, \
	unsigned long long: __builtin_flsll, \
	default: TEMPLATE_FORMULA_PAWINT_FLS )

Though I'm hoping to do more later (and yes I did some copy pasting with the generics, I'll fix those later).

13 Comments
2024/11/16
07:58 UTC

1

Possible obscure bug, not sure

Hey!

I'm writing some C code using a Raspberry Pi v5 (long story, don't ask), and pushing the code to GitHub, which runs a series of tests.

My issue is with the format checking, specifically checking of types. The CFLAGS specifies -Wformat=2 in each makefile, and the GitHub actions do catch errors like this:

printf("%d", sizeof(int)); //wrong type

However, for some reason the GCC on my rpi doesn't report any issues here at all. Why are these two platforms inconsistent? IDK what to do or even how to report this as a bug.

Thanks in advance.

Contexts:

8 Comments
2024/10/30
09:56 UTC

7

Porting GCC to custom architecture

Does anyone know a good tutorial or something about how to port GCC to a custom processor architecture? I am working on a VM as a school project, and I have made my own assembly-like language for it. It is a 32bit processor if that helps

3 Comments
2024/10/09
11:39 UTC

3

Is there an extension that declares to GCC this typedef is an error type and should always be handled?

Let's say I have this:

enum
{
  foo_err_nomem = ENOMEM,
  ...
} foo_err_t;

foo_err_t foo(...);

Is there a way to make gcc throw compile time errors if all the outputs of foo() is not handled? The only thing I can think of is this:

enum
{
  foo_err_nomem = ENOMEM,
  ...
} foo_err_t;

foo_err_t _foo(...);
#define foo(...) switch ( _foo(...) )

Not ideal since dev could just use _foo() directly but it's the only solution I can think of. Is there some better way that gcc, clang, etc would support? I'm mainly after gcc or maybe winegcc depending on how things go with my project. I'm locking my custom library and whatnot into GNU binaries to avoid ABI issues so using extensions in the library interface is a non-issue.

2 Comments
2024/09/24
08:20 UTC

6

How would you set cache size compilation flags for CPUs which don't have homogeneous cache sizes for their cores?

I'm trying to figure out how to best use cache size flags (--param=l1-cache-size=... --param=l2-cache-size=...) for modern intel processors (with E cores) and for some modern AMD processors (7950X3D) which do not have the same amount of L1 or L3 cache for all cores.
^(note: --param=l2-cache-size doesn't actually refer to L2, it refers to the cache "closest to RAM", so L3 for most if not all modern processors.)

For intel, E cores have lower amount of L1 cache than P cores, and for AMD, the 7950X3D has two 8 core-complexes where one has much more L3 cache than the other.

The way I see it, there are three ways of handling this:
a) Set the parameter to the greater of the two cache sizes
b) Set the parameter to the lesser of the two cache sizes
c) Leave the parameter unset so that gcc won't assume anything about the non-homogeneous cache size, only set the other homogeneous one (L3 for intel, L1 for AMD)

I think a) would be the worst because it might cause gcc to misoptimize thinking it has more cache than it actually does for some cores, which could cause unnecessary cache misses. I'm not so sure about b) and c) though. What do you think?

1 Comment
2024/09/13
09:04 UTC

1

GCC 5.2.0 for mips exposes many symbols

I created a gcc toolchain for mips-uclibc 32bit be and when I compile any executable many internal symbols end up in the dynamic symbol table. -fvisibillity=hidden did not solve this, using LTO left lto private symbols exposed. Any idea why this is happening and how to fix this?

0 Comments
2024/09/12
18:15 UTC

1

What does this look like to experienced people - gcc errors

The code I am compiling compiles on other systems but I am trying to make it build in nix.

I am getting invalid syntax errors, and a lot of stuff like
`_ISspace’ was not declared in this scope; did you mean ‘isspace`

where stuff is seemingly just slightly renamed.

Does this point towards a wrong version of gcc, wrong version of included libraries. Could anyone please point me in the right direction I've been hitting my head against the wall in total for 3 weeks in getting all this working

```
/nix/store/px65na1fysh9wb9mj30lgpf6c3njx7zv-gcc-13.3.0/include/c++/13.3.0/streambuf:135:57: error: no type named ‘int_type’ in ‘std::basic_streambuf<wchar_t>::traits_type’ {aka ‘struct std::char_traits<wchar_t>’}
135 | typedef typename traits_type::int_type int_type;
| ^~~~~~~~
In file included from /nix/store/px65na1fysh9wb9mj30lgpf6c3njx7zv-gcc-13.3.0/include/c++/13.3.0/bits/locale_facets.h:39,
from /nix/store/px65na1fysh9wb9mj30lgpf6c3njx7zv-gcc-13.3.0/include/c++/13.3.0/bits/basic_ios.h:37,
from /nix/store/px65na1fysh9wb9mj30lgpf6c3njx7zv-gcc-13.3.0/include/c++/13.3.0/ios:46:
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/tr1/cwctype: At global scope:
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/tr1/cwctype:47:14: error: ‘iswblank’ has not been declared in ‘std’
47 | using std::iswblank;
| ^~~~~~~~
In file included from /nix/store/px65na1fysh9wb9mj30lgpf6c3njx7zv-gcc-13.3.0/include/c++/13.3.0/bits/locale_facets.h:41:
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:49:35: error: ‘_ISupper’ was not declared in this scope; did you mean ‘isupper’?
49 | static const mask upper = _ISupper;
| ^~~~~~~~
| isupper
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:50:35: error: ‘_ISlower’ was not declared in this scope; did you mean ‘islower’?
50 | static const mask lower = _ISlower;
| ^~~~~~~~
| islower
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:51:35: error: ‘_ISalpha’ was not declared in this scope; did you mean ‘isalpha’?
51 | static const mask alpha = _ISalpha;
| ^~~~~~~~
| isalpha
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:52:35: error: ‘_ISdigit’ was not declared in this scope; did you mean ‘isdigit’?
52 | static const mask digit = _ISdigit;
| ^~~~~~~~
| isdigit
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:53:35: error: ‘_ISxdigit’ was not declared in this scope; did you mean ‘isxdigit’?
53 | static const mask xdigit = _ISxdigit;
| ^~~~~~~~~
| isxdigit
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:54:35: error: ‘_ISspace’ was not declared in this scope; did you mean ‘isspace’?
54 | static const mask space = _ISspace;
| ^~~~~~~~
| isspace
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:55:35: error: ‘_ISprint’ was not declared in this scope; did you mean ‘isprint’?
55 | static const mask print = _ISprint;
| ^~~~~~~~
| isprint
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:56:35: error: ‘_ISalpha’ was not declared in this scope; did you mean ‘isalpha’?
56 | static const mask graph = _ISalpha | _ISdigit | _ISpunct;
| ^~~~~~~~
| isalpha
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:56:46: error: ‘_ISdigit’ was not declared in this scope; did you mean ‘isdigit’?
56 | static const mask graph = _ISalpha | _ISdigit | _ISpunct;
| ^~~~~~~~
| isdigit
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:56:57: error: ‘_ISpunct’ was not declared in this scope; did you mean ‘ispunct’?
56 | static const mask graph = _ISalpha | _ISdigit | _ISpunct;
| ^~~~~~~~
| ispunct
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:57:35: error: ‘_IScntrl’ was not declared in this scope; did you mean ‘iscntrl’?
57 | static const mask cntrl = _IScntrl;
| ^~~~~~~~
| iscntrl
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:58:35: error: ‘_ISpunct’ was not declared in this scope; did you mean ‘ispunct’?
58 | static const mask punct = _ISpunct;
| ^~~~~~~~
| ispunct
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:59:35: error: ‘_ISalpha’ was not declared in this scope; did you mean ‘isalpha’?
59 | static const mask alnum = _ISalpha | _ISdigit;
| ^~~~~~~~
| isalpha
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:59:46: error: ‘_ISdigit’ was not declared in this scope; did you mean ‘isdigit’?
59 | static const mask alnum = _ISalpha | _ISdigit;
| ^~~~~~~~
| isdigit
/nix/store/skkw2fidr9h2ikq8gzgfm6rysj1mal0r-gcc-13.2.0/include/c++/13.2.0/x86_64-unknown-linux-gnu/bits/ctype_base.h:61:35: error: ‘_ISblank’ was not declared in this scope; did you mean ‘isblank’?
61 | static const mask blank = _ISblank;
| ^~~~~~~~
| isblank

```

3 Comments
2024/09/03
15:21 UTC

7

Can I tell GCC to put a functions and everything it calls into a specific section?

I have an interrupt service routine, which I want to put in a specific, non-standard, section, to be put in a special RAM region of my microcontroller. So far so good. But. Every function called from that interrupt service routine should also be put in that special RAM region. I realize [[gnu::flatten]] is an option, but I'd prefer something less drastic. Is that possible to do?

13 Comments
2024/08/20
00:09 UTC

1

-falign-functions=64:32:16:8

Hey guys , iam wondering if this is a correct syntax of the flag , and if its like what i understand is : align for 64 and 32 as fallback and so one and so fourth , if anyone had some depth understanding plz explain this flag

2 Comments
2024/08/09
19:34 UTC

11

r/GCC refers to the entire GNU compiler suite, not specifically the binary named 'gcc' that compiles C.

In other words, this is not a dedicated C-language subreddit. In the sidebar, do notice that r/C_programming and r/cpp_questions also exist.

0 Comments
2024/08/02
18:30 UTC

2

Is collect2 only needed for c++ code

... or, at least unnecessary for linking just C code (.o-s and libraries)

1 Comment
2024/07/18
18:15 UTC

2

Objdump - how to display source code for the library functions in the assembly output

When I use objdump with -S flag, only the main program's source code is displayed in the assembly output. How do I display the linked libraries' source code as well? For example, if I use pthread_create() function in my program, I want the source code of this function included as well. How do I do that?

1 Comment
2024/07/13
21:55 UTC

1

Why doesn’t gcc have an option to build in one command but retain the object files?

It seems the only command to save intermediate files is -save—temps, but this saves all intermediate files. Is the only way to save only .o files to use -c option and build in two commands?

3 Comments
2024/07/12
05:30 UTC

Back To Top