C++ Logo

sg15

Advanced search

Re: [isocpp-sg15] Compiler private dir discussion thu morning

From: Boris Kolpackov <boris_at_[hidden]>
Date: Thu, 28 Nov 2024 17:13:14 +0200
Jussi Pakkanen <jpakkane_at_[hidden]> writes:

> I don't understand what you are trying to say here. Let's use an
> example instead for concreteness.
>
> Suppose we have source file foo.cc, two executables e1 and e2 and a
> utility library l.
>
> Foo.cc goes directly to e1 and also to l which is linked to e2.
>
> When foo.cc is compiled for e1, the extra files go to e1's private
> directory (it has to be compiled a second time as the flags might be
> different).

Or they might not in which case it's perfectly valid to link the same
object file to several executables. Here it is expressed in make:

e1: foo.o
e2: foo.o
foo.o: foo.cc


> There is one special case which is that the end user can tell (in
> Meson at least, dunno about other build systems) that they want to
> "steal" the object file from l and use it directly [...]

In other build systems it's not a special case and nobody needs to
commit any crimes. In build2, for example, there is no conceptual
difference between object targets and library targets and just as
you can list the same library target as a prerequisite of multiple
executables, so you can do it with the same object target.

Received on 2024-11-28 15:12:09