Thread: C++ vs C

  1. #76
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by grumpy View Post
    Compilers don't typically do significant code generation at link time. There are a few "smart linkers" that do, but not compilers. I've come across a couple of really neat smart linkers associated with (proprietary) C++ compilers, but have yet to come across such a smart linker associated with a pure C compiler.
    I have never heard of a compiler/linker that actually recompiles anything during linking. All LTO systems that I know instead compile the code to some intermediate representation and dump that to the object files instead of real object code, and have the linker only do optimization and final code generation during the linking.
    But that capability is actually quite common. Intel's and Microsoft's proprietary compilers can do it, of course, but so can GCC (when used with the gold linker) and LLVM (with the gold or Darwin linker, or LLVM's prelinker).

    But LTO is not something you enable during development.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #77
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    One of the proprietary (and paid-for in significant dollars) C++ compilers/linkers on Silicon Graphics (I can't remember the product name or version number offhand) in the mid 1990s handled templates with the help of an intermediate database. Based on information in object files (where template functions, etc were called) the linker would instantiate the templates by emitting object code using relevant information from the database. According to the documentation, function inlining was also done in the link phase, rather than when compiling.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #78
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You don't consider code generation from IL to be compiling? To me a linker is just a thing that links object code. The compiler is now split across two components (the "so-called-compiler" and the "so-called-linker") while the "so-called-linker" has both compilation and link-related functions. I think it's open to interpretation.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #79
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Well, the interpretation in the documentation for that particular product characterised it in the way I described.

    Depending on how you tie down the definition of a compiler, a linker is just a specialised compiler (with inputs being object files and libraries, and outputs being files in some executable formats) anyway.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #80
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by brewbuck View Post
    You don't consider code generation from IL to be compiling?
    In the context of this discussion, I took "compiling" to mean "turn C++ source code into machine code". Of course every transformation from one code representation to another may be called compiling. (Or at least any such transformation that goes from a form that is more abstracted from the machine to one that is less.)

    To me a linker is just a thing that links object code. The compiler is now split across two components (the "so-called-compiler" and the "so-called-linker") while the "so-called-linker" has both compilation and link-related functions. I think it's open to interpretation.
    It absolutely is.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed