gcc

What is the OPTION in the GCC's option "-Wl,OPTION"

When I read the GCC's info manual, I found the link option -Wl,OPTION: `-Wl,OPTION' Pass OPTION as an option to the linker. If OPTION contains commas, it is split into multiple options at the commas. But I could not find the definition of the OPTION. Who can tell me where to find it? I have google it, but nothing found. ...

In C++, when does a process retain allocated memory even though delete is called?

I would like to understand what is going on in the GCC runtime in the following situation. I have a C++ program that allocates many blocks of memory and then deletes them. What's puzzling is that the memory is not being returned to the OS by the GCC runtime. Instead, it is still being kept by my program, I assume in case I want to alloc...

Are libfoo.a and foo.lib compatabile formats?

Some build scripts (such as the one in numpy) simply does the following to make a gcc-compiled library archive work with the Visual Studio linker: copy libfoo.a foo.lib Surprisingly it seems to work. Does anyone know why? ...

Why does the library compiled on two slightly different machines behaves slightly different?

Here's the setup: My coworker has a Fedora x64_86 machine with a gcc 4.3.3 cross compiler (from buildroot). I have an Ubuntu 9.04 x64_86 machine with the same cross compiler. My coworker built an a library + test app that works on a test machine, I compiled the same library and testapp and it crashes on the same test machine. As far...

nanoseconds to milliseconds - fast division by 1000000

Hi, I'm wanting to convert the output from gethrtime to milliseconds. The obvious way to do this is to divide by 1000000. However, I'm doing this quite often and wonder if it could become a bottleneck. Is there an optimized divide operation when dealing with numbers like 1000000? Note: Any code must be portable. I'm using gcc and thi...

Are function static variables thread-safe in GCC ?

In the example code void foo() { static Bar b; ... } compiled with GCC is it guaranteed that b will be created and initialized in a thread-safe manner ? In gcc's man page, found the -fno-threadsafe-statics command line option: Do not emit the extra code to use the routines specified in the C++ ABI for thread-safe initiali...

C++: When (and how) are C++ Global Static Constructors Called?

Hi, I'm working on some C++ code and I've run into a question which has been nagging me for a while... Assuming I'm compiling with GCC on a Linux host for an ELF target, where are global static constructors and destructors called? I've heard there's a function _init in crtbegin.o, and a function _fini in crtend.o. Are these called by c...

How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake

Is it possible to compile a project in 32-bit with cmake and gcc on a 64-bit system? It probably is, but how do I do it? When I tried it the "ignorant" way, without setting any parameters/flags/etc, just setting LD_LIBRARY_PATH to find the linked libraries in ~/tools/lib it seems to ignore it and only look in subdirectories named lib64....

Randomizing function, etc. locations for shared libs

Currently, when I create a shared library, functions from within the same object files like to lie together. Is there a good solution (that does not involve splitting up source files) to try and spread function locations apart? We are currently using a cross-compiled, 4.2.1 version of gcc and the gnu tools. ...

gcc/gdb: How to embed absolute path to source file in debug information?

hello. i am just wondering if i can tell gcc to embed the absolute path to a source file in the debug information, even if i call gcc like gcc -g ../src/somecode.c -o ../bin/somecode.o as i see it atm, gcc just stores what you provide, so if you provide a relative path, at the end, gdb only knows the relative path as well. is there ...

How to get GNU AS to emit per-line debugging info or GDB to single step lines in (AVR) Assembly?

I cannot figure out how to get GAS to emit line number debugging information for gdb in assembly. Note that I'm using the avr-gcc cross compiler, but doubt that is relevant. I'm using the following command line options to assemble: avr-gcc -g -ggdb -Os -mmcu=atmega644 -ffunction-sections -fsigned-char -Winvalid-pch -Wall -Wno-long-lo...

Solaris process hanging in exit

On Solaris 9 and 10, both x86 and Sparc, we have a process that is hanging during exit: fe0b5994 lwp_park (0, 0, 0) fe0b206c slow_lock (ff388908, fe080400, 0, 0, 98, fe0abe00) + 58 ff376aa8 __deregister_frame_info_bases (2a518, 1, 0, 2daf0, 0, ff376be4) + 4c 00014858 ???????? (0, ff000000, 0, 0, 0, 0) 00019920 _fini (0, 0, 210fc, fe2...

gcc compiled binaries w/different sizes?

If the same code is built at different times w/gcc, the resulting binary will have different contents. OK, I'm not wild about that, but that's what it is. However, I've recently run into a situation where the same code, built with the same version of gcc, is generating a binary with a different size than a prior build (by about 1900 by...

Can gcc be configured to not print out a full path in warning/error messages?

When gcc prints out a warning or error, it shows the full path of the file that contains the error. Is there a flag to shorten the output to just the filename? ...

Array values changed automatically to 0.

Today I had a strange encounter with gcc. consider the following code: float len[ELEM+1]; len[1]=1.0; len[2]=2.0; len[3]=3.0; //length nod[1][1] = 1; nod[1][2] = 2; nod[2][1] = 2; nod[2][2] = 3; nod[3][1] = 3; nod[3][2] = 4; //CONNECTIVITY for(i=1;i<nnod;i++) for(j=1;j<nfree;j++) /* bl...

Interpreting the contents of the hs_err_pid file

Below is a part of the hs_err_pid Heap PSYoungGen total 13888K, used 9807K [0x8a330000, 0x8b140000, 0x914f0000) eden space 13504K, 69% used [0x8a330000,0x8ac67710,0x8b060000) from space 384K, 96% used [0x8b0e0000,0x8b13c6e0,0x8b140000) to space 448K, 0% used [0x8b060000,0x8b060000,0x8b0d0000) PSOldGen total 115456K...

Why does Mingw exist?

MSYS and UNIX-like build systems apart; why does Mingw exist? What I mean is, why isn't win32/64 just another target available in "vanilla GCC"? Are there technical reasons for this or are they "political"? It would seem to me that there isn't really anything special about the Windows platform that would make a GCC port to it "incompatib...

Elegant and safe way to determine if architecture is 32bit or 64bit

As title says, is there any elegant and safe way to determine if architecture is 32bit or 64bit. By elegant, you can think of precise, correct, short, clean, and smart way. By safe, think of safe in term of standard, C89/C99, and operating system independence. ...

Using GCC to produce readable assembly?

I was wondering how to use GCC on my C source file to dump a mnemonic version of the machine code so I could see what my code was being compiled into. You can do this with Java but I haven't been able to find a way with GCC. I am trying to re-write a C method in assembly and seeing how GCC does it would be a big help. ...

GCC / Linux: adding a static library to a .so?

I've a program that implements a plugin system by dinamically loading a function from some plugin_name.so (as usual) But in turn I've a static "helper" library (lets call it helper.a) whose functions are used both from the main program and the main function in the plugin. they don't have to inter-operate in any way, they are just helper...