"compiling" libraries

11 risposte [Ultimo contenuto]
donttazeme
Offline
Iscritto: 03/16/2015

I'm not a programmer. I know you can compile an executable and if you turn on compiler optimizations it might speed it up but also might make bugs and limits it to one processor. Are libraries compiled? Is there any sort of optimization that can be done to them?

I read up on refactoring. Is there any program that automatically refactors?

onpon4
Offline
Iscritto: 05/30/2012

Compilation translates human-readable source code into machine-readable object code. It's something you have to do to execute the code, unless it's an interpreted language that interprets the actual source code rather than bytecode, such as JavaScript. In the case of a language like C, the object code is machine code: the native language of the CPU (think assembly). In interpreted languages like Python or Java, the object code is bytecode native to the interpreter.

Usually, when you're sent a binary (e.g. from the Trisquel repo), it's already compiled in the way that produces the best-optimized binary. Re-compiling won't do any harm, but it won't do any good either unless the person who compiled the binary cannot be trusted to give you the binary that actually corresponds with the source code.

marioxcc
Offline
Iscritto: 08/13/2014

>Are libraries compiled? Is there any sort of optimization that can be done to them?

It depends on programming language and implementation. For C and C++ which are the most common non-web (server side or client side) programming languages, libraries are compiled very similarity as how programs are compiled to executables. Almost all optimizations that can be used when compiling to executables can be used when compiling libraries. A notable exception is that when compiling native-code dynamically loaded libraries (Also called “shared libraries”, they have the file name extension “.so”), the machine code must be position independent (search for “position-independent code”) which is done with -fpic in GCC, that disables some optimizations.

Some programming languages have native-compiling, bytecode-compiling and interpreting implementations; for example: Common Lisp and Scheme.|

>I know you can compile an executable and if you turn on compiler optimizations it might speed it up but also might make bugs and limits it to one processor.

This is a misconception. You should raise your standard for what you think you know (research better before thinking you know something).

Optimization doesn't introduced bugs unless the compiler is buggy. If a program (whether executable or a library) is correct, then a correct compiler will produce a correct output (executable, shared library, bytecode, etcetera). Optimization sometimes trigger bugs (or it may hide bugs that would otherwise appear).

In GCC only some optimization options enable or disable instructions. It doesn't limit the program to only one CPU, but to the set of processors that implement those instructions. The main option to enable instructions is “-march”. Use “-march=local” if you will only run that executable or library in the CPU that you are using to compile it.

When compiling with GCC, the main optimization options are “-On” with a number in the range 0-3 in place of n (the higher, the more it will optimize, up to 3). “-O2” is the usual default option. As far as I know, using these optimizations options (the ones mentioned in this paragraph) will not enable more instructions, so you can use “-O3” without losing compatibility with CPUs that would be compatible otherwise.

When I use GCC, I usually compile with optimization options “-s -O3 -march=native -fomit-frame-pointer”. Consult the manual for more information.

Changelog 2015-03-17 18:46 UTC: Change “to only one process” to “to only one CPU”.

Magic Banana

I am a member!

I am a translator!

Offline
Iscritto: 07/24/2010

Rule of thumb: trust the developer who makes the package (especially if he or she is a Debian/Ubuntu/Trisquel developer).

marioxcc
Offline
Iscritto: 08/13/2014

For that matter, we could use Debian or Ubuntu and its proprietary software.

tomlukeywood
Offline
Iscritto: 12/05/2014

the last time i checked debian did not have non-free software

danieru
Offline
Iscritto: 01/06/2013

First of all. What is Debian? Debian is basically a collection of packages. Now it's true that all the essential system software and libraries are free software, and it's also true that only this packages are included by default. BUT, the repository non-free is still part of Debian, also packages in the repository contrib can have dependencies on non-free packages.

So, does Debian have non-free software?
Yes, because there is a whole official repository with lots of non-free packages.

The only thing that is true is that Debian doesn't include those by default.

marioxcc
Offline
Iscritto: 08/13/2014

It may be used fully free, but that's optional, and their idea of what is free software is different from the FSF definition so to have a fully free system according to the FSF idea you have to watch for the differences (I use Debian and also Trisquel, and that is what I do). It seems like you have been deceived by their practice of truth by decree: They claim that Debian is fully free, because although they distribute, document, support and invite to use proprietary software using the same infrastructure, they claim that it is not part of Debian. That deceiving practice is even supported by their social contract (see point 5 and compare it to point 1), hence that I call it truth by decree (instead of facts). In the past, they were even more hypocritical: the kernel (regardless of whether the user intended to install the proprietary software) came with proprietary blobs. See Debian Doubletalk for more information and also https://www.debian.org/vote/2004/vote_002.

Changelog: Replaced “but it's not [...] by default” with “but that's optional”; added “and compare it to point 1”.

Magic Banana

I am a member!

I am a translator!

Offline
Iscritto: 07/24/2010

I meant "trust the developers for turning on optimizations (that do not trigger bugs)". I did not mean that every package coming from Debian/Ubuntu is OK. Proprietary software is bad no matter who packages it.

SuperTramp83

I am a translator!

Offline
Iscritto: 10/31/2014

I've been using debian wheezy 7.8 for almost a week now - only the main repo. It works great (xfce DE). They really need to get rid of the contrib and non-free repos and stop suggesting "install flash player" in iceweasel. Other then that, it is a completely free OS by default. And one can easily keep it free. Just don't enable the two non-free repos and don't install nothing proprietary on it.

Legimet
Offline
Iscritto: 12/10/2013

They suggest installing flash player? I'm using Debian jessie (8) and it doesn't for me.

SuperTramp83

I am a translator!

Offline
Iscritto: 10/31/2014

On a fresh install (a week ago) I opened up iceweasel and installed the few addons I need and then started surfing the net and when I came across a website that used flash player for their videos a popup in the top left side (you know, the same popup that you see when you install an addon) displayed the message "do you want to install flash player?" or something similar..
You can choose between yes, ask me later and no. I selected "yes"! no.. wait.. just joking :)
I selected "no" and after that it remembered my preference and never asked me that stupid question again.

Good to know they removed that popup in 8. They used to ship nonfree firmware until the version 6. Maybe they are on the right road and version 9 will get rid of the contrib and non-free repos! which I highly doubt..