Tag Info

Hot answers tagged

269

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


30

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


13

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


12

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


11

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


10

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


10

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

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.


9

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


9

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


9

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


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


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

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


7

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


7

It looks like you need to install g++. This is available via yum: yum 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 yum whatprovides <command>


6

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


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

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

Debian 6.0 is Squeeze (currently stable); Lenny was 5.0 (currently oldstable). I'll assume you meant Squeeze. Use apt-pinning to safely add Wheezy (currently testing) to your sources.list, then install gcc-4.7/wheezy. In other words, your /etc/apt/sources.list should look something like this: deb local.debian.mirror squeeze main deb local.debian.mirror ...


6

lex.yy.c is the default output file name for lex, the lexical analyzer preprocessor for C (and C++). The linker (ld) is looking for a file called libfl.so (if linking dynamically; it would be libfl.a if linking statically). This is the runtime library required by lexers generated by Flex, a lex implementation. If you generated lex.yy.c yourself with flex, ...


6

src/math.h:23:24: error: openssl/bn.h: No such file or directory src/math.h:24:25: error: openssl/rsa.h: No such file or directory src/math.h:25:25: error: openssl/sha.h: No such file or directory I'm guessing you don't have OpenSSL installed, or at least not the development package that includes headers. If you do, the headers aren't in /usr/include or ...


6

The files were extracted but they are in /dev/... I doubted that could happen when I first read your question, because tar programs have for many years been stripping leading / from paths automatically for security reasons. Without that protection, you could ship someone a malicious tarball that overwrote system files. Think of the fun you could have by ...


6

The -march flag permits the compiler to use instructions that are not supported by other CPUs. There are a few instructions that are legal to use with -march=athlon64 that your i7 does not support. These are the 3DNow! and Enhanced 3DNow! instructions that weren't included in MMX or integer SSE. If the code uses instructions like PFPNACC it will fault on ...


6

How could curl know that the file is executable? Well technically it could examine its contents but it's well beyond what curl is meant to do. The default permissions are determined by umask (http://en.wikipedia.org/wiki/Umask) and on top of the permissions derived from umask the program may add the executable bit (or use different permissions altogether). ...


5

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