Hot answers tagged

361

Summary: The primary reason for switching from GCC to Clang is the incompatibility of GCC's GPL v3 license with the goals of the FreeBSD project. There are also political issues to do with corporate investment, as well as user base requirements. Finally, there are expected technical advantages to do with standards compliance and ease of debugging. Real world ...


68

Make does this using its built-in rules. These tell it in particular how to compile C code and how to link single-object programs. You actually don't even need a Makefile: make test would work without one. To see the hidden rules that make all of this possible, use the -p option with no Makefile: make -p -f /dev/null As pointed out by alephzero, Make ...


38

One thing worth considering is that FreeBSD is currently using GCC 4.2.1 as noted in ire_and_curses answer thus the performance comparisons aren't of 4.5 or even 4.6 aren't truly relevant to the project. Therefore, the questions you should be asking are: What are the performance gains of the new Clang vs the older GCC that the project uses? How do the same ...


30

AFAIK the only way to be completely sure of security would be to write a compiler in assembly language (or modifying the disk directly yourself). Only then can you ensure that your compiler isn't inserting a backdoor - this works because you're actually eliminating the compiler completely. From there, you may use your from-scratch compiler to bootstrap e.g. ...


27

GCC has a number of phases to its compilation, and it uses different internal commands to do each phase. C in particular is first preprocessed with cpp, then is compiled into assembly, assembled into machine language, and then linked together. cc1 is the internal command which takes preprocessed C-language files and converts them to assembly. It's the ...


26

In the latest versions of gcc compiler require that libraries follow the object or source files. So to compile this it should be: gcc pthread_sample.c -lpthread Normally though pthread code is compiled this way: gcc -pthread pthread_sample.c


26

From the output you've given, you are trying to compile a 32-bit build of apache on a 64 bit system. This is from the intput to configure here: --host=x86_32-unknown-linux-gnu host_alias=x86_32-unknown-linux-gnu CFLAGS=-m32 LDFLAGS=-m32 Also see the output lines confirming this: configure:3629: checking build system type configure:3643: result: x86_64-...


26

The option is shown as "-l_library_" (no space) or "-l _library_" (with a space) and c is the library argument, see https://linux.die.net/man/1/gcc -lc will link libc (-lfoobar would link libfoobar etc.) General information about options and arguments UNIX commands often accept option arguments with or without whitespace. If you have an option o which ...


22

One possible way, although it would take an exceedingly long time in practice, would be to go back to the roots. Development of GNU began in 1984, and the original version of Minix (which was used during early Linux development for bootstrapping purposes) was released in 1987. This entire answer is based on your premise that "[you] or others have the ...


19

Even though GCC is GPLv3, the resulting binaries produced by GCC never had any license constraint. In clear you can use GCC to build software that falls under the license you want. Even the C library that comes with GCC and that is included in the binary is license-free. http://www.gnu.org/licenses/gcc-exception-faq.html Section 2 of the GNU GPLv3: You ...


19

After about 4.5 hours it finished. P.S. Not sure why this question deserved a negative rating. Hopefully it will still help some folks, should they find their compile time take excessively long.


17

Don't worry about these errors: gcc: error: unrecognized command line option '-V' and gcc: error: unrecognized command line option '-qversion' Those are unsuccessful probes but the configure script perseveres after them. Do worry about these: /usr/bin/ld: cannot find crt1.o: No such file or directory /usr/bin/ld: cannot find crti.o: No such file or ...


16

GCC On gcc (man gcc) the checks are enabled by -fstack-protector Emit extra code to check for buffer overflows, such as stack smashing attacks. >This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with >buffers larger than 8 bytes. The guards are ...


16

You can install GCC 4.9 by building it from ports with cd /usr/port/lang/gcc49; make install clean or if you have portmaster portmaster -DHB lang/gcc49 or if you prefer packages with pkg install lang/gcc49 If you change lang/gcc49 to lang/gcc you will install the most recent stable version of GCC currently this is GCC 4.7. When you want to build all ...


16

Get gcc-doc package In order to be able to fetch this packages with the apt-get install command we need to edit our sources.list file to include both contrib and non-free repositories. For example, here's my /etc/apt/sources.list file: deb http://httpredir.debian.org/debian/ jessie main contrib non-free deb-src http://httpredir.debian.org/debian/ jessie ...


13

FreeBSD 10 will use the BSD-licensed Clang compiler instead of GCC for 32- and 64-bit Intel x86 systems. The only thing preventing a wholesale switch on all CPU platforms FreeBSD releases on is developer time and interest. As for FreeBSD 9 — which was just about to be released when this question was first posed — there was talk about making ...


13

It looks like you need to install g++. This is available via dnf: dnf install gcc-c++ In the future, if you see any variant of a command not found error, you can search for the package that provides the "command" with dnf whatprovides \*/bin/<command> It used to be that you could just say whatprovides <command> but Fedora now wants the full ...


13

I needed GCC 5+ installed on debian jessie and, as is available for debian testing (at least on jun-16) you can use apt-pinning to install packages available there (see https://wiki.debian.org/AptPreferences). To install GCC 5+ from testing on debian jessie using apt-pinning: Add debian testing repo to your apt sources by creating a file in the directory /...


12

Firstly, do not build it as root. Generally you will need root privilege with sudo only at the final step you install it in the system. ./configure make sudo make install According to config.log, you failed to build executables because libc and other libraries are missing on your system. On Debian based systems you can install essential tools and ...


12

It's easy to track this initialization, as for (almost) every process strace shows a very suspicious syscall during the very beginning of the process run: arch_prctl(ARCH_SET_FS, 0x7fc189ed0740) = 0 That's what man 2 arch_prctl says: ARCH_SET_FS Set the 64-bit base for the FS register to addr. Yay, looks like that's what we need. To find, ...


11

Boost is a mostly header-only library, so there is no library to link with (most of the time). As for the headers, Ubuntu place them in /usr/include/, which is one of the include paths GCC use by default. So any #include <boost/foreach.hpp> will work out of the box on Ubuntu.


11

TL;DR I have a different take on this as a Gentoo user. While I agree with peterph's approach of "Let the System Decide," I disagree when it comes to an ABI Update. An ABI Update is sometimes a major shift in behavior. In the case of GCC 4.7, the ABI Change was the adoption of the new C++11 Standard, which peterph also pointed out. Here is why I write ...


10

The start address is the address of main(), right? Not really: The start of a program isn't really main(). By default, GCC will produce executables whose start address corresponds to the _start symbol. You can see that by doing a objdump --disassemble Q1. Here's the output on a simple program of mine that only does return 0; in main(): 0000000000400e30 <...


10

gcc is the name of the suite cc is just the C compiler from this suite. the word cc it's also a generic name for any given c compiler under unix systems, for example it's not rare to find an environment variable called CC in a given building script or configure script, and if you want to be pedantic, this variable usually points to a c compiler that doesn't ...


10

Installing gcc puts a libstdc++.so.6 into both $PREXIF/lib and $PREFIX/lib64. Using the latter as RPATH for boost and my program solved the issue. Using only the former results in a fall-back to the system libstdc++.so.6.


10

You've combined together several different (but related) questions. A few of them aren't really on-topic here (e.g., coding standards), so I'm going to ignore those. I'm going to start with if the kernel is "technically incorrect C code". I'm starting here because the answer explains the special position a kernel occupies, which is critical to understanding ...


10

TL;DR: # pkg change-facet \ version-lock.system/library/gcc/gcc-c-runtime=false \ version-lock.system/library/gcc/gcc-c++-runtime=false and try again. So the issue is that gcc-5 is what's known as a "group" package. That is, it consists (at least primarily) of a bunch of group dependencies. A group dependency is one that will be installed if ...


10

Stack smashing is detected by libssp, which is part of gcc. It tries very hard to output the message to a terminal, and only if that fails does it log to the system log — so in practice you’ll see buffer overflow messages in the logs for daemons and perhaps GUI applications. Once it’s output its message, libssp tries a variety of ways to exit, including ...


10

How to install a specific version of GCC in Kali Linux? GCC 6 is available on kali linux it can be installed as follow : apt install g++-6 gcc-6 To switch between gcc6 and gcc7 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 1 --slave /usr/bin/g++ g++ /usr/bin/g++-7 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 2 --slave /...


Only top voted, non community-wiki answers of a minimum length are eligible