Re: C No Operation doubt

Discussion in 'C Programming' started by Keith Thompson, May 26, 2014.

  1. Keith Thompson

    Kaz Kylheku Guest

    Actually, this philosophy requires programs to do at least three things well:
    scan/parse text, do whatever it is they are supposed to do, and format the
    output for the next program's scanner and parser.
    Kaz Kylheku, May 29, 2014
    1. Advertisements

  2. We need an assembler anyway, so to build redundant logic into the
    compiler seems like a waste of effort--and a source of bugs. This is
    magnified because gcc and gas have a staggering list of targets; most
    compilers have only one target, maybe two or three in a few cases.

    Stephen Sprunk, May 29, 2014
    1. Advertisements

  3. Keith Thompson

    Kaz Kylheku Guest

    There are also bugs that arise out of using the wrong version of binutils with
    a given version of gcc. If you're a toolchain/distro maintainer person, you
    have to choose which version of gcc and binutils are packaged together,
    and when to upgrade which one and to what version.
    Kaz Kylheku, May 29, 2014
  4. Keith Thompson

    David Brown Guest

    There are a variety of command-line switches in gcc, as well as ones
    that get passed on to gas (the assembler), which can make the assembly
    clearer. The ones I use are:

    -fverbose-asm -Wa,-adchls=foo.lst

    This generates a listing file with the assembly and at least /some/
    useful annotation.
    David Brown, May 29, 2014
  5. Keith Thompson

    David Brown Guest

    And binutils supports more targets than gcc.
    This is not a common problem - binutils is mostly quite stable, as there
    is not a lot of change in the assembler or linker world. Sometimes
    there are major new features, such as link-time optimisation or
    additional debugging formats, but mismatches there are not likely to be
    a source of bugs (you simply can't use the new features without support
    at each part of the toolchain).
    David Brown, May 29, 2014
  6. Keith Thompson

    BartC Guest

    Thanks. (The -fverbose-asm option adds comments which identify the relevant
    variables, and also the temp values it uses, giving an interesting insight.)
    BartC, May 29, 2014
  7. Really? That seems odd.

    They're not "packaged together"; they're separate packages, revised
    every time a new release comes out, and users just type one command to
    install (or upgrade to) the latest version of both, which will almost
    certainly work together just fine.

    This isn't like commercial software where users are charged for upgrades
    that break everything and thus want to stay on old versions forever,
    which necessitates building ugly interop matrices. OSS users are
    encouraged to upgrade early and often, and since OSS developers are
    users themselves, they make it as easy as possible.
    New instructions are added to x86(-64) on a regular basis, and entirely
    new targets are added every year, so there's a fairly regular stream of

    But I'd agree that binutils updates are not driven by bugs, and in most
    cases, you can go for years without updating, unlike gcc where you'll
    want to update frequently for better optimization.
    Indeed; if you run into such a problem after updating one package, you
    just update the other one and everything works again.

    Stephen Sprunk, May 30, 2014
  8. Keith Thompson

    David Brown Guest

    It's obvious that binutils must support at least as many targets as gcc
    (in theory, gcc output can be compiled and linked by other
    assembler/linker combinations, but it's rare in practice). Assemblers
    are useful even without a compiler, and it is a relatively small job to
    get a new target into binutils. So if you have a new cpu architecture,
    step 1 is to get full binutils support. Getting gcc support, along with
    a library, is orders of magnitude more difficult. There are therefore
    architectures for which there is binutils support but no working gcc, or
    for which the gcc port is not (yet) integrated back into the mainline gcc.
    Many of these new instructions are not generated by the compiler, except
    perhaps as "builtins". Of course, you can't use these new instructions
    without support from newer binutils.
    You may also want to update gcc for newer features and language support,
    and for bug fixes. Better optimisations are usually just a nice bonus.

    Another difference is that binutils versions are usually entirely
    backwards compatible - you would rarely want to use an older version if
    you have a newer one on hand. gcc is far more complex software - new
    versions are not necessarily backwards compatible, they introduce new
    bugs, remove old features, generate different code (that may not be
    better for /your/ particular use), etc.
    David Brown, May 30, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.