Archive

Posts Tagged ‘gcc’

Compiler writing in the next decade

December 22nd, 2009 Derek-Jones No comments

What will be the big issues in compiler writing in the next decade? Compilers sit between languages and hardware, with the hardware side usually providing the economic incentive.

Before we set off to follow the money, what about the side that developers prefer to talk about. The last decade has not seen any convergence to a very small number of commonly used languages, if anything there seems to have been a divergence with more languages in widespread use. I will not attempt to predict whether there will be a new (in the sense of previously limited to a few research projects) concept that is widely integrated and used in many languages (i.e., the integrating of object oriented features into languages in the 90s).

Where is hardware going?

  • Moore’s law stops being followed. Moore’s law is an economic one that has a number of technical consequences (e.g., less power consumed and until recently increasing clock rates). Will the x86 architecture evolution dramatically slow down once processor manufacturers are no longer able to cram more transistors onto the same amount of chip real estate? Perhaps processor designers will start looking to compiler writers to suggest functionality that could be made use of by compilers to generate more optimal code. To date my experience of processor designers is that they look to Moore’s law to get a ‘free’ performance boost.

    There are a number of things a compiler code tell the processor, such as when a read or write to a cache line is the last one that will occur for a long time (enabling that line to be moved to the top of the reuse list).

  • Not plugged into the mains. When I made a living writing optimizers the only two optimizations choices were code size and performance. There are a surprising number of functional areas in which a compiler, given processor support, can potentially generate code that consumes less power. More on this issue in a later post.
  • More than one processor. Figuring out how to distribute a program across multiple, loosely coupled, processors remains a difficult research topic. If anybody ever comes up with a solution to this problem it might make more commercial sense for them to keep it secret, selling a compiling service rather than selling compilers.
  • Application Specific Instruction-set Processors. Most processors in embedded systems only ever run a single program. The idea of each program being executed on a processor optimized to its requirements sounds seductive. At the moment the economics are such that it is cheaper to take an existing, very low cost, processor and shoe-horn the application onto it. If the economics change the compiler used for each processor is likely to be automatically generated.

Enough of the hardware, this site is supposed to be about code:

  • New implementation techniques. These include GLR parsing and genetic algorithms to improve the generated code quality. The general availability of development machines containing more than 4G of memory will make it worthwhile for compiler writers to implement more whole program optimizations (which are currently being hemmed in by storage limits)
  • gcc will continue its rise to world domination. The main force at work here is not the quality of gcc but the disappearance of the competition. Compiler writing is not a big bucks business and compiler companies are regularly bought up by much larger hardware outfits looking to gain some edge. A few years go by, plans change, the compiler group are not making enough profit to warrant the time being spent on them by upper management and they are closed down. One less compiler vendor and a bunch of developers are forced to migrate to another compiler, which may or may not be gcc.
  • Figuring out what the developer meant to write based on what they actually wrote, and some mental model of software developers, is my own research interest. This is somewhat leading edge stuff, in other words nothing major has been achieved so far. Knowledge of developer intent looks like it will open the door to whole classes of new optimization techniques.

Compiler writing: The career path to World domination

November 7th, 2009 Derek-Jones 3 comments

Compiler writing is not usually thought of as a career path that leads to becoming Ruler of the World. Perhaps this is because compiler writing is a relatively new profession and us compiler writers are still toiling in obscurity awaiting the new dawn.

What might be a workable plan for a compiler writer to become Ruler of the World? One possibility is to write a compiler for the language in which most of the World’s critical software is written (i.e., C) and for that compiler to become the one that the vendors of this critical software all use (i.e., gcc). This compiler needs to do more that just compile the source code it is feed, it also needs to generate code that creates a backdoor in important programs (e.g., the login program).

But, you say, this cannot happen with gcc because its source is available for everybody to read (and spot any backdoor generator). In his 1984 Turing acceptance lecture Ken Thompson showed how a compiler could contain a backdoor that was not visible in its source. The idea is for the compiler writer to modify a compiler to detect when it is being used to compile itself and to insert the backdoor generating code into its own executable. This modified compiler is then used to compile itself and the resulting executable made the default compiler; the backdoor modifications are then removed from the compiler source, they are no longer needed because the previously compiled compiler will spot when it is being used to compile its own source and generate the code necessary to propagate the backdoor code into the executable it creates.

How would the world counter the appearance of such a modified gcc? Obviously critical programs would need to be recompiled by a version of gcc that did not contain the backdoor. Today there are several companies and many amateur groups that distribute their own Linux distributions which they build from source. It should be relatively easy to obtain a usable executable of gcc from 10 years ago; remember what is needed is a version capable of compiling the latest gcc sources.

The ideal time to create a backdoor’ed version of gcc is while its development was under the control of one person, so early in the development history that all versions available anywhere are very likely to be derived from it. How can we prove that the original author of gcc did not do just this?

It could be argued that the very substantial changes to the gcc sources (most of the source has probably been rewritten several times) mean that the coding patterns searched for by the executable to detect that it is compiling itself have long gone and at some point the backdoor failed to propagate itself to the next executable.

Compilers other than gcc might also include backdoors that propagate themselves. However, the method of propagation is likely to be different. Compiling the gcc sources with a non-gcc compiler creates an executable that should exhibit the same behavior as a gcc-compiled executable. Differences in the behavior of these independently built executables is a cause for concern (one difference might be caused by differences in the conversion of floating-point literals, a recent PhD thesis provides more detail).

The problem with compiling the gcc sources is that they make use of language extensions that few, if any, other compilers support. I know IBM added modified one of their C compilers to support those gcc extensions needed to compile the Linux kernel, but I don’t know if this compiler is capable of compiling the gcc sources. The LLVM project intended to support many gcc extensions but I don’t know if they aim to be able to compile the gcc sources.

Another option is to compare the assembler generated when gcc compiles itself against the corresponding source code. A very expensive task for source code measured in hundreds of thousands of lines. Adding the necessary language extension support to another compiler would probably be cheaper and also create a tool that could be used to check future releases of gcc.

Searching for the source line implementing 3n+1

June 30th, 2009 Derek-Jones No comments

I have been doing some research on the variety of ways that different developers write code to implement the same specification and have been lucky enough to obtain the source code of approximately 6,000 implementations of a problem based on the 3n+1 algorithm. At some point this algorithm requires multiplying a value by three and adding one, e.g., n=3*n+1;.

While I expected some variation in the coding of many parts of the algorithm I did not expect to see much variation in the 3n+1 part, perhaps somebody might write n=n*3+1;. I was in for a surprise, the following are some of the different implementations I have seen so far:

n = n + n + n + 1 ;
n += n + n + 1;
n = (n << 1) + n + 1;
n += (n << 1) + 1;
n *= 3; n++;
t = (n << 1) ; n = t + n + 1;
n = (n << 2) - n + 1;

I was already manually annotating the source and it was easy for me to locate the line implementing 3n+1 to annotate it. But what if I wanted to automate the search for the line of code containing this calculation, what tool could I use? Would I have to write down every possible ways in which 3n+1 could be implemented, with/without parenthesis and all possible orderings of operands? I am not aware of any automatic tool that could be told to locate expressions that calculated 3n+1. What is needed is abstract interpretation over short sequences of statements.

I mentioned this search problem over drinks after a talk I gave at the Oxford branch of the ACCU last week and somebody (Huw ???) suggested that perhaps the code generated by gcc would be the same no matter how 3n+1 was implemented. I could see lots of reasons why this would not be the case, but the idea was interesting and worth investigation.

At the default optimization level the generated x86 code is different for different implemenetations, but optimizing at the “-O 3″ level results in all but one of the above expressions generating the same evaluation code:

   leal 1(%rax,%rax,2), %eax

The exception is (n << 2) - n + 1 which results in shift/subtract/add. Perhaps I should report this as a bug in gcc :-)

I was surprised that gcc exhibited this characteristic and I plan to carry out more tests to trace out the envelope of this apparent "same generated code for equivalent expressions" behavior of gcc.

Predictions for 2009

December 31st, 2008 Derek-Jones No comments

If the shape of code does change over time, it changes very slowly. Styles become more or less popular, but again the time-scale is generally longer than a year. Anyway, here are my predictions for goings on the in the community that shapes code.

1) Functional programming will continue to entrance the young whose idealism will continue to be dashed when they have to deal with the real world. Ok, I started with something obvious that will still be true in 20 years and I promise not to to to keep repeating myself on this one every year.

2) The LLVM project will die. I am surprised that it has lasted this long, but it is probably costing Apple so little that it is not on management’s radar. Who needs another C compiler; perhaps 10 years ago they could have given the moribund gcc project a run for its money, but an infusion of keen people and a complete reworking of its internals has kept gcc as the leading contender to be the only C compiler developers use in 10 years time.

3) Static analysis will go mainstream. The driving force will not be developers loosing their aversion to being told of their mistakes, but because the world’s economic predicament will force them to deliver better performance in less time, ie they will be forced to use tools to help them find coding faults. The fact that various groups are starting to add hooks to the mainstream compilers (e.g., Microsoft’s Phoenix, gcc’s Dehydra), ensuring compatibility with an existing code base and making it easier for developers use, also helps. The gcc people may yet shoot themselves in the foot. Of course people will continue to develop new stand-alone tools and extract money from government to do something that sounds useful.

4) Natural language programming will finally gain a foothold. One of the big unnoticed announcements of the year was the Attempto project releasing the source code of their controlled English system.

5) The rate of gcc’s progress to world domination will accelerate. There are still quite a few market niches where gcc is a minority player (eg, embedded systems) and various compilers need to disappear for it to gain market share. Compiler writing has never been a very profitable business and compiler companies usually go bust or are taken over by hardware vendors looking for customer lock-in. The current economic situation means that compiler companies are both more likely to go bust and to not be brought, ie, their compilers will (commercially) disappear.

6) The number of people involved in writing software will continue to decline in the West and increase in the East. These days there is not a lot of difference in cost between east/west, it is the quality of developers (or rather there are more of a reasonable standard available). The declining standards in science/engineering education is the driving factor, the economic situation is just creating extra exposure.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com cialis tablets foreign

cialis fast delivery

levitra online us

canada meds viagra

cialis and ketoconazole

buy 5 mg cialis

buy propecia online

generic cialis soft tabs

canada cheap propecia

cialis to buy

cialis delivered overnight

get levitra online

online cheap viagra

for sale levitra

canada viagra generic

best price generic propecia

how to buy cialis in canada

canadian pharmacy viagra

lowest propecia prices in canada

buy propecia generic

buy online prescription propecia

buying generic propecia

buy fast propecia

buy cialis in usa

cialis cheap

brand viagra professional

order levitra online

cialis professional 100 mg

china viagra

get levitra

online cialis

generic cialis sale

name brand cialis

brand name cialis

levitra next day delivery

cialis alternative

levitra from canadian pharmacy

buy cialis cannada

levitra online sales

online propecia uk

discount propecia rx

info levitra

does generic cialis work

5 mg daily cialis

buy levitra uk

order propecia

mail order levitra

best viagra

cheap fast levitra

low cost canadian viagra

cialis daily in canada

canadian pharmacy

low cost levitra

buy branded viagra

buy levitra online from canada

canadian viagra 50mg

cheap levitra without prescription

cialis soft pills

generic propecia fda approved

levitra online overnight delivery

buying online propecia

cialis 20 mg

cialis 50 mg

levitra online

cialis 100 mg

brand viagra over the net

cialis online

buy cialis usa

lowest price for propecia

cialis buy overnight

cialis transdermal

cheap levitra

cialis strenght mg

buy propecia canada

levitra for sale

cialis for woman

buy prescription propecia without

levitra now online

canadian healthcare

cialis in mexico

natural viagra

getting cialis from canada

cheap prescription propecia

cheap propecia no prescription

cheap levitra tablets

buy real viagra online

low price levitra

cheapest viagra

buy viagra online

order generic levitra

how to get viagra

buy cialis online uk

buy viagra mexico

combine cialis and levitra

levitra in india

buy cheapest propecia

cialis dosage mg

discount propecia online

canadian viagra and healthcare

once a day viagra

buy cialis canada

cialis headaches

buy cialis 5 mg

discount levitra purchase

indian viagra

bestellen levitra online

buy levitra us

order cheap propecia

cialis 5 mg buy

levitra cheap fast

get propecia online pharmacy

how much is viagra

buy cialis online canada

lowest propecia 1 mg

buy viagra

how much cialis

i need to buy propecia

cheap propecia online

cialis price

cheap discount levitra

cheapest overnight cialis

cheap propecia uk

generic cialis from india

levitra viagra cialis

cheapest viagra online

generic levitra canada

cialis overnight delivery

cheapest viagra usa

cheap viagra from uk

ordering cialis gel

buy generic propecia

brand name cialis overnight

bio viagra herbal

levitra tabs

buy viagra on line

lowest price on non generic levitra

levitra in canada

low cost propecia

buy dosages levitra

cialis purchase

cialis from mexico

generic levitra overnight delivery

generic propecia for sale

cialis by mail

cialis professional no prescription

generic propecia online pharmacy

buy viagra online cheap us

cialis woman

generic propecia finasteride

lowest price propecia best

levitra canadian

how to get cialis in canada

cheap levitra prescription

cialis on women

cialis professional 20 mg

canadian pharmacy cialis

best price for generic cialis

cialis discounts

canadian healthcare pharmacy

cheap order prescription propecia

buy propecia online from usa pharmacy

buy propecia on line

lowest priced propecia

get cialis online

generic propecia 5mg

generic viagra made in usa

overnight delivery viagra

canadian viagra india

canada viagra pharmacies scam

cheap viagra online

generic viagra 100 mg

order cheap levitra

cheapest propecia uk

cialis one a day

daily dosage cialis

discount levitra online

cheap propecia 5mg

canada online pharmacy levitra

discount propecia propecia

cialis next day

buy propecia now

ordering propecia online

buy discount viagra

discount us propecia

cheap cialis from india

levitra discount

how strong is 5 mg of cialis

canadian healthcare viagra

cialis uk

cialis and diarrhea

cialis next day delivery

cheap cialis soft

cost of viagra

buying generic cialis mexico rx

best price cialis

levitra prescription

order cheapest propecia online

canada propecia prescription

cheap canadian viagra

buying cialis

cialis prescription

lowest price propecia

cialis overnight

generic propecia sale

buy generic cialis

lowest price levitra

online propecia prescription

canada online pharmacy propecia

buy cialis without prescription

levitra online no prescription

levitra online prescription

female viagra pills

can i get viagra in mexico

mexico levitra

mexico pharmacy cialis

canadian propecia rx

generic propecia effective

discount cialis india

discount drug propecia

discount generic propecia

generic propecia alternative

how much does cialis cost

cheapest propecia sale uk

levitra buy online

cialis generic 100 mg

generic levitra vardenafil

levitra where to buy

canada generic propecia

indian generic levitra

cost of daily cialis

indian cialis generic

levitra mail order

generic viagra canadian

cialis 5 mg

buying viagra in canada

levitra cost

buy cheap levitra

generic levitra cheap

buying cialis next day delivery

cialis 100 mg generic

get cialis

gele viagra

once daily cialis

cheap cialis

buy now propecia

lowest cost levitra

canadian pharmacy discount code viagra

best price for propecia

buy viagra without prescription

buying propecia

cialis en mexico

next day delivery cialis

indian cialis

next day viagra

generic levitra purchase

cialis daily dosage pharmacy

internet pharmacy propecia

discount levitra rx

cialis refractory

generic viagra made in india

buying propecia online

buy viagra china

buy cheap levitra online

cialis quick shipment

best price levitra

obtain viagra without prescription

5 mg original brand cialis

generic viagra online

canadian drugs propecia

levitra pill

cheapest prices for viagra

ganeric cialis

cialis vs levitra

buy levitra online no prescription

buy propecia online prescription

canadian pharmacies cialis

overnight delivery cialis

buy cialis for daily use

cheapest propecia prescription

cheap viagra canada or india

cialis from canada

herbal propecia

buy levitra online viagra

levitra sales uk

online ordering propecia

buy real cialis

cialis and canada custom

hydrochlorothiazide cialis

cialis profesional

50 mg cialis

genuine cialis pills

online propecia prescriptions

levitra order prescription

levitra viagra online

buy canada levitra

cialis 5 mg italia

brand cialis for sale

generic viagra canada

cost levitra low

buy cialis once daily