All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/tini: compile executable static
@ 2019-11-20 13:09 Simon Rowe
  2019-11-23 21:15 ` Yann E. MORIN
  2019-12-03 13:59 ` [Buildroot] [PATCH v2] " Simon Rowe
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Rowe @ 2019-11-20 13:09 UTC (permalink / raw)
  To: buildroot

tini is intended to be used as the init process within containers and
therefore needs to be independent of the C runtime library.

Signed-off-by: Simon Rowe <simon.rowe@citrix.com>
---
 package/tini/tini.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/tini/tini.mk b/package/tini/tini.mk
index 5dd9877..986e612 100644
--- a/package/tini/tini.mk
+++ b/package/tini/tini.mk
@@ -10,6 +10,7 @@ TINI_LICENSE = MIT
 TINI_LICENSE_FILES = LICENSE
 
 TINI_CFLAGS = $(TARGET_CFLAGS) \
+	-static \
 	-DTINI_VERSION=\"$(TINI_VERSION)\" \
 	-DTINI_GIT=\"\"
 
-- 
1.8.3.1

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-11-20 13:09 [Buildroot] [PATCH 1/1] package/tini: compile executable static Simon Rowe
@ 2019-11-23 21:15 ` Yann E. MORIN
  2019-11-25  9:23   ` Simon Rowe
  2019-12-03 13:59 ` [Buildroot] [PATCH v2] " Simon Rowe
  1 sibling, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2019-11-23 21:15 UTC (permalink / raw)
  To: buildroot

Simon, All,

On 2019-11-20 13:09 +0000, Simon Rowe spake thusly:
> tini is intended to be used as the init process within containers and
> therefore needs to be independent of the C runtime library.
> 
> Signed-off-by: Simon Rowe <simon.rowe@citrix.com>
> ---
>  package/tini/tini.mk | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/package/tini/tini.mk b/package/tini/tini.mk
> index 5dd9877..986e612 100644
> --- a/package/tini/tini.mk
> +++ b/package/tini/tini.mk
> @@ -10,6 +10,7 @@ TINI_LICENSE = MIT
>  TINI_LICENSE_FILES = LICENSE
>  
>  TINI_CFLAGS = $(TARGET_CFLAGS) \
> +	-static \

That can't work as-is, because this would break with BR2_SHARED_LIBS=y,
in which case only shared libraries are available.

Furthermore, the commit message introducing tini explicitly states "it
is not necessary to compile Tini statically for many non-docker
container environments". So, what has changed since then?

Besides, I would expect that the init process of a container would be
provided inside the container, not come from the host system. As such,
the init system of the container can be dynamically linked with the
runtime of the container itself.

In any case, this patch is incorrect in the shared-only setup, so I
marked it as rejected for now. If you can provide a beter way to do what
you need, then we can revisit it later with a different implementation
(and more explanations on how this is used in the wild).

Regards,
Yann E. MORIN.

>  	-DTINI_VERSION=\"$(TINI_VERSION)\" \
>  	-DTINI_GIT=\"\"
>  
> -- 
> 1.8.3.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-11-23 21:15 ` Yann E. MORIN
@ 2019-11-25  9:23   ` Simon Rowe
  2019-11-25 12:12     ` Simon Rowe
  2019-12-01 14:41     ` Arnout Vandecappelle
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Rowe @ 2019-11-25  9:23 UTC (permalink / raw)
  To: buildroot

On 23/11/2019 21:15, Yann E. MORIN wrote:

> That can't work as-is, because this would break with BR2_SHARED_LIBS=y,
> in which case only shared libraries are available.

Thanks for pointing this out.

> Furthermore, the commit message introducing tini explicitly states "it
> is not necessary to compile Tini statically for many non-docker
> container environments". So, what has changed since then?
> 
> Besides, I would expect that the init process of a container would be
> provided inside the container, not come from the host system. As such,
> the init system of the container can be dynamically linked with the
> runtime of the container itself.

Passing --init to "docker run" takes whatever the executable docker-init 
in the OS filesystem is and uses it as the process for pid 1 in the 
container. If the OS is buildroot and the container uses glibc that 
doesn't work.

> In any case, this patch is incorrect in the shared-only setup, so I
> marked it as rejected for now. If you can provide a beter way to do what
> you need, then we can revisit it later with a different implementation
> (and more explanations on how this is used in the wild).

I can add the static linking as an option. I would have done so but it 
was suggested here

http://lists.busybox.net/pipermail/buildroot/2017-October/204974.html

that an init should always be statically linked.

In summary I can make this optional and mutually exclusive with 
BR2_SHARED_LIBS, would that be acceptable?

Simon

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-11-25  9:23   ` Simon Rowe
@ 2019-11-25 12:12     ` Simon Rowe
  2019-12-01 14:41     ` Arnout Vandecappelle
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Rowe @ 2019-11-25 12:12 UTC (permalink / raw)
  To: buildroot

On 25/11/2019 09:23, Simon Rowe wrote:
> If the OS is buildroot and the container uses glibc that 
> doesn't work.

I meant to say "If buildroot uses musl and the container uses glibc ..."

Simon

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-11-25  9:23   ` Simon Rowe
  2019-11-25 12:12     ` Simon Rowe
@ 2019-12-01 14:41     ` Arnout Vandecappelle
  2019-12-03 13:14       ` Simon Rowe
  1 sibling, 1 reply; 9+ messages in thread
From: Arnout Vandecappelle @ 2019-12-01 14:41 UTC (permalink / raw)
  To: buildroot



On 25/11/2019 10:23, Simon Rowe wrote:
> On 23/11/2019 21:15, Yann E. MORIN wrote:
> 
>> That can't work as-is, because this would break with BR2_SHARED_LIBS=y,
>> in which case only shared libraries are available.
> 
> Thanks for pointing this out.

 Well, actually, we really should keep at least libc.a around even if
BR2_SHARED_LIBS=y, because some packages (with no dependencies, and that don't
use NSS - like tini) may still want to link statically.

 In fact, I think we already keep libc.a around in all possible cases even if
BR2_SHARED_LIBS=y, so I think this patch will work as is...


>> Furthermore, the commit message introducing tini explicitly states "it
>> is not necessary to compile Tini statically for many non-docker
>> container environments". So, what has changed since then?

 Maybe Christian can explain? I vaguely remember that discussion from a year
ago. IIRC, Christian initially did exactly this: link tini statically, always.
But then it turned out not to be needed.


>> Besides, I would expect that the init process of a container would be
>> provided inside the container, not come from the host system. 

 No, the point of tini is exactly to avoid using the init inside the container -
either because it's doing too much (e.g. full systemd) or because it doesn't
exist (container image with just the application).

>> As such,
>> the init system of the container can be dynamically linked with the
>> runtime of the container itself.
> 
> Passing --init to "docker run" takes whatever the executable docker-init in the
> OS filesystem is and uses it as the process for pid 1 in the container. If the
> OS is buildroot and the container uses glibc that doesn't work.
> 
>> In any case, this patch is incorrect in the shared-only setup, so I
>> marked it as rejected for now. If you can provide a beter way to do what
>> you need, then we can revisit it later with a different implementation
>> (and more explanations on how this is used in the wild).
> 
> I can add the static linking as an option. I would have done so but it was
> suggested here
> 
> http://lists.busybox.net/pipermail/buildroot/2017-October/204974.html
> 
> that an init should always be statically linked.
> 
> In summary I can make this optional and mutually exclusive with BR2_SHARED_LIBS,
> would that be acceptable?

 Could you check with BR2_SHARED_LIBS=y and the current patch if it's possible
to build tini for all cases? I.e., external toolchain, internal with musl,
glibc, uClibc. If not, then you can make it conditional on !shared like this:

	$(if $(BR2_SHARED_LIBS),,-static)

 And of course, we still need an explanation why it is needed after all while
before we thought it wasn't.

 Regards,
 Arnout

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-12-01 14:41     ` Arnout Vandecappelle
@ 2019-12-03 13:14       ` Simon Rowe
  2019-12-03 13:29         ` Arnout Vandecappelle
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Rowe @ 2019-12-03 13:14 UTC (permalink / raw)
  To: buildroot

On 01/12/2019 14:41, Arnout Vandecappelle wrote:

>   Could you check with BR2_SHARED_LIBS=y and the current patch if it's possible
> to build tini for all cases? I.e., external toolchain, internal with musl,
> glibc, uClibc. If not, then you can make it conditional on !shared like this:
> 
> 	$(if $(BR2_SHARED_LIBS),,-static)

I've run the current patch with the following toolchains

* internal, only shared libraries, musl
* internal, only shared libraries, uClibc
* internal, only shared libraries, glibc
* external, only shared libraries, musl

and tini is built correctly.

>   And of course, we still need an explanation why it is needed after all while
> before we thought it wasn't.

Does this need an expansion of the commit message or something elsewhere?

Simon

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

* [Buildroot] [PATCH 1/1] package/tini: compile executable static
  2019-12-03 13:14       ` Simon Rowe
@ 2019-12-03 13:29         ` Arnout Vandecappelle
  0 siblings, 0 replies; 9+ messages in thread
From: Arnout Vandecappelle @ 2019-12-03 13:29 UTC (permalink / raw)
  To: buildroot



On 03/12/2019 14:14, Simon Rowe wrote:
> On 01/12/2019 14:41, Arnout Vandecappelle wrote:
> 
>> ? Could you check with BR2_SHARED_LIBS=y and the current patch if it's possible
>> to build tini for all cases? I.e., external toolchain, internal with musl,
>> glibc, uClibc. If not, then you can make it conditional on !shared like this:
>>
>> ????$(if $(BR2_SHARED_LIBS),,-static)
> 
> I've run the current patch with the following toolchains
> 
> * internal, only shared libraries, musl
> * internal, only shared libraries, uClibc
> * internal, only shared libraries, glibc
> * external, only shared libraries, musl
> 
> and tini is built correctly.

 Excellent!

 So the patch was OK, just the commit message should be updated.

> 
>> ? And of course, we still need an explanation why it is needed after all while
>> before we thought it wasn't.
> 
> Does this need an expansion of the commit message or something elsewhere?

 Commit message.

 Thanks!

 Regards,
 Arnout

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

* [Buildroot] [PATCH v2] package/tini: compile executable static
  2019-11-20 13:09 [Buildroot] [PATCH 1/1] package/tini: compile executable static Simon Rowe
  2019-11-23 21:15 ` Yann E. MORIN
@ 2019-12-03 13:59 ` Simon Rowe
  2019-12-03 22:08   ` Arnout Vandecappelle
  1 sibling, 1 reply; 9+ messages in thread
From: Simon Rowe @ 2019-12-03 13:59 UTC (permalink / raw)
  To: buildroot

One usecase for tini is as the init process for a container which has
a single executable and no C runtime library. It therefore needs to be
independent of any C runtime library within the container.

Tested with multiple toolchains and BR2_SHARED_LIBS=y.

Signed-off-by: Simon Rowe <simon.rowe@citrix.com>

---
Changes v1 -> v2:
  - tested with other toolchains
  - expanded reasoning for static linking
---
 package/tini/tini.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/tini/tini.mk b/package/tini/tini.mk
index 5dd9877..986e612 100644
--- a/package/tini/tini.mk
+++ b/package/tini/tini.mk
@@ -10,6 +10,7 @@ TINI_LICENSE = MIT
 TINI_LICENSE_FILES = LICENSE
 
 TINI_CFLAGS = $(TARGET_CFLAGS) \
+	-static \
 	-DTINI_VERSION=\"$(TINI_VERSION)\" \
 	-DTINI_GIT=\"\"
 
-- 
1.8.3.1

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

* [Buildroot] [PATCH v2] package/tini: compile executable static
  2019-12-03 13:59 ` [Buildroot] [PATCH v2] " Simon Rowe
@ 2019-12-03 22:08   ` Arnout Vandecappelle
  0 siblings, 0 replies; 9+ messages in thread
From: Arnout Vandecappelle @ 2019-12-03 22:08 UTC (permalink / raw)
  To: buildroot



On 03/12/2019 14:59, Simon Rowe wrote:
> One usecase for tini is as the init process for a container which has
> a single executable and no C runtime library. It therefore needs to be
> independent of any C runtime library within the container.
> 
> Tested with multiple toolchains and BR2_SHARED_LIBS=y.
> 
> Signed-off-by: Simon Rowe <simon.rowe@citrix.com>

 Applied to master, thanks. I've extended the commit message a bit.

 Regards,
 Arnout

> 
> ---
> Changes v1 -> v2:
>   - tested with other toolchains
>   - expanded reasoning for static linking
> ---
>  package/tini/tini.mk | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/package/tini/tini.mk b/package/tini/tini.mk
> index 5dd9877..986e612 100644
> --- a/package/tini/tini.mk
> +++ b/package/tini/tini.mk
> @@ -10,6 +10,7 @@ TINI_LICENSE = MIT
>  TINI_LICENSE_FILES = LICENSE
>  
>  TINI_CFLAGS = $(TARGET_CFLAGS) \
> +	-static \
>  	-DTINI_VERSION=\"$(TINI_VERSION)\" \
>  	-DTINI_GIT=\"\"
>  
> 

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

end of thread, other threads:[~2019-12-03 22:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 13:09 [Buildroot] [PATCH 1/1] package/tini: compile executable static Simon Rowe
2019-11-23 21:15 ` Yann E. MORIN
2019-11-25  9:23   ` Simon Rowe
2019-11-25 12:12     ` Simon Rowe
2019-12-01 14:41     ` Arnout Vandecappelle
2019-12-03 13:14       ` Simon Rowe
2019-12-03 13:29         ` Arnout Vandecappelle
2019-12-03 13:59 ` [Buildroot] [PATCH v2] " Simon Rowe
2019-12-03 22:08   ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.