The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] What did cc -2 do?
@ 2017-06-27 13:54 Richard Tobin
  2017-06-27 17:35 ` Random832
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Tobin @ 2017-06-27 13:54 UTC (permalink / raw)


> Browsing the source for "cc" in v6 and v7, if invoked with -2 would
> replace crt0.o with crt2.o. If the -2 were followed by another character
> (probably intended to be -20), it would use crt20.o and use -l2 instead
> of -lc.
> 
> These options seem to be undocumented, and I can't find any source code
> of these libraries or indication as to what the purpose was.

The "scc" man page for System V may be enlightening, as it mentions
similarly-named files:

  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

-- Richard

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] What did cc -2 do?
  2017-06-27 13:54 [TUHS] What did cc -2 do? Richard Tobin
@ 2017-06-27 17:35 ` Random832
  0 siblings, 0 replies; 3+ messages in thread
From: Random832 @ 2017-06-27 17:35 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] What did cc -2 do?
@ 2017-06-25  0:50 Random832
  0 siblings, 0 replies; 3+ messages in thread
From: Random832 @ 2017-06-25  0:50 UTC (permalink / raw)


Browsing the source for "cc" in v6 and v7, if invoked with -2 would
replace crt0.o with crt2.o. If the -2 were followed by another character
(probably intended to be -20), it would use crt20.o and use -l2 instead
of -lc.

These options seem to be undocumented, and I can't find any source code
of these libraries or indication as to what the purpose was.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-27 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 13:54 [TUHS] What did cc -2 do? Richard Tobin
2017-06-27 17:35 ` Random832
  -- strict thread matches above, loose matches on Subject: below --
2017-06-25  0:50 Random832

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).