Tag Info

Hot answers tagged

99

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


10

One thing worth considering is that FreeBSD is currently using GCC 4.2.1 as noted above 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 binaries compiled ...


9

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


8

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


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

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


7

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.


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


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

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


6

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


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


5

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


5

You can ask gcc where it will look for those binaries: (this works on FC16's gcc-4.6.3 and CentOS 5.3 gcc-4.1.3, so it should work with your 4.2) gcc -print-search-dirs You can set your search path via GCC_EXEC_PREFIX environment variable.


5

Compile your source file prog.c with: $ gcc prog.c this will generate an executable named a.out. Execute it with: $ ./a.out To specify the name of the executable during compilation: $ gcc prog.c -o prog execute with: $ ./prog gcc is also the C++ compiler. There are plenty command line options available, so it's worth getting to know the man ...


5

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


5

Use the --prefix option with the configure command. I won't try to give a complete configure command here, since GCC is one of those programs most often given complex configuration options, but adding something like --prefix=$HOME/my-gcc-4.7 will work. Upon installation, you will get a tree under that directory containing things like bin/gcc. Once it's ...


4

The easiest method I can think of is to make a ~/bin directory inside your $HOME, add a symlink ~/bin/gcc to /usr/bin/gcc-4.4 or wherever your gcc-4.4 is located, and make sure ~/bin is at the beginning of your $PATH like this: export PATH=~/bin:$PATH


4

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


4

Many GNU projects, including GCC, license their documentation under the GNU Free Documentation License. There is a long-standing dispute between the Free Software Foundation and the Debian project, which considers the GFDL to be non-free, mostly because it can forbid some sections of the documentation from being modified. For this reason, the GCC ...


4

I'm no expert, but my understanding is Clang/LLVM uses fewer resources than GCC and is quicker. http://clang.llvm.org/features.html#performance If you're running an environment where you need to build a lot of stuff, a lot of times, that performance may turn into real savings in energy costs and time. If it's real.


4

To quote from the manual: Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging information. . I don't mean to be a RTFM guy but in this case, reading the manual section on -g will answer your question. As per -o, you're right.


3

This is in process. Going to http://wiki.debian.org/Hardening leads to http://wiki.debian.org/ReleaseGoals/SecurityHardeningBuildFlags, which leads to Raphael Hertzog's message to debian-devel-announce, on behalf of the dpkg developers. See the para beginning * dpkg-buildflags now returns hardening build flags by default So, this feature may be in the ...


3

Broadly speaking, a core file is a dump of the entire memory used by a process plus the CPU registers state. So, in general, the information you can retrieve from a core file is the same that you could get by attaching a debugger to the process just before it crashed. If I do not strip symbols from my application and libraries, are the core files still ...


3

Those sections are marked GNU_RELRO (readonly relocations), which means that as soon as the dynamic loader has fixed up (at load time, there are no lazy relocations there) all the relocations, it marks those sections read-only. Note that most of .got.plt is on another page, so doesn't get the treatment. You can see the linker script with ld --verbose, if ...


3

I can tell why it's failing, although I don't actually know what part of the system is responsible. While .dtors is marked writable in the binary, it looks like it (along with .ctors, the GOT, and a few other things) are being mapped into a separate, non-writable page in memory. On my system, .dtors is getting put at 0x8049f14: $ readelf -S test [17] ...


3

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


3

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


3

You should add the non-free and contrib repositories to your sources list and run apt-get update afterwards. Now you can install the gcc-doc package which should contain the man-pages with: apt-get install gcc-doc The problem is that the gcc documentation is released under the Gnu Free Docuemntation License which is considered non-free by Debian.



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