Tag Info

Hot answers tagged

315

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 ...


35

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 ...


25

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. ...


20

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 ...


16

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 ...


14

-O3 has several disadvantages: First of all it often produces slower code than -O2 or -Os. Sometimes it produces longer code due to loop unrolling which may be in fact slower due to worse cache performance of code. As it was said it sometimes produces wrong code. It may be either due to error in optimalization or error in code (like ignoring strict ...


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 ...


12

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


12

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 ...


10

You need to install the gcc-c++ package: yum install gcc-c++


10

Cross-compiling may be the solution for you It allows you to compile executables for one architecture on a system of a different architecture. Here's an introduction


10

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.


10

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 ...


10

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 ...


10

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 ...


9

If you need a trusted compiler, you could get a look at academic work, like the compcert project. It's a compiler built by the INRIA (a French IT public laboratory) designed to be ''certified'', i.e. to produce an executable semantically perfectly equivalent to the code (and of course, it has been mathematically proven).


8

You don't have the value of the PATH environment variable set to include whatever directory the HelloWorld executable file lives in. Supposing you have used cd to get to the directory, you can run HelloWorld with this command: ./HelloWorld Linux shells have a concept called PATH, which is a list of directories in which to look when the user issues a ...


8

It's likely out of necessity. Until recently, the BSD-licensed C compilers were probably few or didn't come close to feature parity with gcc. From FreeBSD Project Goals: That code in our source tree which falls under the GNU General Public License (GPL) or Library General Public License (LGPL) comes with slightly more strings attached, though at ...


8

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 ...


8

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 ...


8

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 ...


7

It's used in Gentoo, and I didn't notice anything unusual.


7

sudo zypper install gcc After that you're going to want to read some OpenSUSE documentation before you ask any more questions.


7

Create a Makefile like this. ifneq ($(KERNELRELEASE),) obj-m := mymodule.o else KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules install: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules_install %: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) $@ endif Assuming your module's ...


7

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: ...


7

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 ...


6

Note that large chunks of the toolchain (glibc in particular) flat out don't compile if you change optimization levels. The build system is setup to ignore your -O preferences for these sections on most sane distros. Simply put, certain fundamental library and OS features depend on the code actually doing what it says, not what would be faster in many ...


6

This doesn't exactly answer your question, but... First of all, ELF is the specification use by Linux for executable files (programs), shared libraries, and also object files which are the intermediate files found when compiling software. Object files end in .o, shared libraries end with .so followed by zero or more digits separated by periods, and ...


6

You should always use -lm when using functions from math.h if you want to keep your code/makefiles portable. Some of the things in that header are macros (which obviously don't need additional libraries), but which are is not specified (except for a few ones). Some other functions might be implemented as build-ins by your compiler (even replaced by ...


6

Obviously, since the program needs to be loaded into memory, -Os will result in lower memory usage. But that is the only effect on memory usage it will have.



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