The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: random832@fastmail.com (Random832)
Subject: [TUHS] What did cc -2 do?
Date: Tue, 27 Jun 2017 13:35:13 -0400	[thread overview]
Message-ID: <1498584913.364854.1023002800.3B8D3CB5@webmail.messagingengine.com> (raw)
In-Reply-To: <20170627135406.21EAD137A42A@macaroni.inf.ed.ac.uk>

On Tue, Jun 27, 2017, at 09:54, Richard Tobin wrote:
> The "scc" man page for System V may be enlightening, as it mentions
> similarly-named files:

Hmm. It seems that the truth is a little bit more convoluted than that,
but it was a good starting point.

The equivalent functionality in V7/usr/src/cmd/standalone uses "libsa"
(in addition to, rather than instead of, libc) and srt0.o, and was used
with a "cc+ld-stand" script which read as follows:
cc -c -O -DSTANDALONE ../$1.c
ld -s -o $1 srt0.o $1.o -lsa -lc
rm $1.o

The equivalent manpage in System III mentions crt20.o instead.

System III scc invokes cc with "-2x" (System V uses -Z2). So, mystery
solved, I guess, except for why it appears in the V6 (and V5, and V2) cc
with no trace of the needed libraries, and V7 with the libraries having
a different structure.

My guess is that the V7 library structure was a post-V6 change that
didn't make it into USG Unix. My assumption is that it's dead code at
that point. The v7 cc+ld-stand script doesn't seem to have been suitable
for multi-file programs, either - no other version has this script,
either (Ultrix and BSD seem to both have standalone systems derived from
it, but both just have the relevant cc and ld commands in their
makefiles)

So, my theorized timeline: This began as an internal tool in V2*. USG
Unix and V7 diverged, and V7 effectively abandoned the use of a magic
flag and hardcoded library names in "cc" (but for some reason retained
the actual associated functionality in "cc" itself, where it survived
into Ultrix 3.1 and 3BSD but not 4BSD). Ultrix and BSD took V7's version
of the functionality.

*specifically, it appears in V2/cmd/cc.c which comes from s1-bits. It
does not appear in V2/c/ncc.c which comes from last1120c.

>   NAME
>     scc - C compiler for stand-alone programs
> 
>   SYNOPSIS
>     scc [ +[ lib ] ] [ option ] ... [ file ] ...
>     
>   DESCRIPTION
>     Scc prepares the named files for stand-alone execution.
>     [...]
>     
>   FILES
>     /lib/crt2.o       execution start-off
>     /usr/lib/lib2.a   stand-alone library    
>     /usr/lib/lib2A.a  +A configuration library
>     /usr/lib/lib2B.a  +B configuration library


  reply	other threads:[~2017-06-27 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 13:54 Richard Tobin
2017-06-27 17:35 ` Random832 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-06-25  0:50 Random832

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498584913.364854.1023002800.3B8D3CB5@webmail.messagingengine.com \
    --to=random832@fastmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).