Skip to contentSkip to conversation

The external toolchain can be used statically.

PATCH New Serj Kalichev 2 participants 7 messages Dec 7, 2010 – Dec 8, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 The external toolchain can be used statically.

I tried to build minimal busybox-only project for using as initramfs. I use external buildroot toolchain. The buildroot copy the .so libraries from external toolchain to the target dir unconditionally. But I build busybox statically and don't need shared libraries (the size of resulted image is too big with unneeded libraries).

The patch use BR2_PREFER_STATIC_LIB to find out if the project prefer static linking and if the static linking is preferred don't copy shared libraries to the target dir.

---
 toolchain/toolchain-external/ext-tool.mk |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
toolchain/toolchain-external/ext-tool.mk +2 -0
index 7e4645d..895ef5f 100644
@@ -99,6 +99,7 @@ else
 	$(Q)$(call check_glibc,$(SYSROOT_DIR))
 endif
 	mkdir -p $(TARGET_DIR)/lib
+ifneq ($(BR2_PREFER_STATIC_LIB),y)
 	@echo "Copy external toolchain libraries to target..."
 	$(Q)for libs in $(LIB_EXTERNAL_LIBS); do \
 		$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
@@ -106,6 +107,7 @@ endif
 	$(Q)for libs in $(USR_LIB_EXTERNAL_LIBS); do \
 		$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/usr/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
 	done
+endif
 	@echo "Copy external toolchain sysroot to staging..."
 	$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
 	# Create lib64 symbolic links if needed
Signature · 1 line
1.7.3.3
#1 lore raw

PATCH 1/1 The external toolchain can be used statically.

Quoted 5 lines · On Tuesday, December 07, 2010 10:48:14 Serj Kalichev wrote:

I tried to build minimal busybox-only project for using as initramfs. I use external buildroot toolchain. The buildroot copy the .so libraries from external toolchain to the target dir unconditionally. But I build busybox statically and don't need shared libraries (the size of resulted image is too big with unneeded libraries).

this isnt entirely correct. glibc will still load shared libs on the fly such as nss and iconv.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101207/c4ca3415/attachment.pgp>

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw

PATCH 1/1 The external toolchain can be used statically.

---------- Forwarded message ----------
From: Pkun <[email protected]>
Date: 2010/12/8
Subject: Re: [Buildroot] [PATCH] The external toolchain can be used statically.
To: Mike Frysinger <[email protected]>

Ok.
May be the right way is to copy only
"/usr/lib/libnss*.so*" and
"/usr/lib/gconv"
when the static is preferred?

Or make the shared libraries copying optional in Config.in? Or make checkboxes especially for libnss and conv libraries to force copying?

2010/12/8 Mike Frysinger <[email protected]>

Quoted 7 lines · On Tuesday, December 07, 2010 10:48:14 Serj Kalichev wrote:
Quoted 1 line

I tried to build minimal busybox-only project for using as initramfs. I

use

Quoted 4 lines

external buildroot toolchain. The buildroot copy the .so libraries from external toolchain to the target dir unconditionally. But I build busybox statically and don't need shared libraries (the size of resulted image is too big with unneeded libraries).

Quoted 5 lines

this isnt entirely correct. glibc will still load shared libs on the fly such
as nss and iconv.
-mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101208/515f01fa/attachment.html>

author
#4 lore raw

PATCH 1/1 The external toolchain can be used statically.

In reply to Mike Frysinger

Ok.
May be the right way is to copy only
"/usr/lib/libnss*.so*" and
"/usr/lib/gconv"
when the static is preferred?

Or make the shared libraries copying optional in Config.in? Or make checkboxes especially for libnss and conv libraries to force copying?

P.S. Sorry for message duplication. Send this message to get to thread.

2010/12/8 Mike Frysinger <[email protected]>

Quoted 8 lines · On Tuesday, December 07, 2010 10:48:14 Serj Kalichev wrote:
Quoted 1 line

I tried to build minimal busybox-only project for using as initramfs. I

use

Quoted 4 lines

external buildroot toolchain. The buildroot copy the .so libraries from external toolchain to the target dir unconditionally. But I build busybox statically and don't need shared libraries (the size of resulted image is too big with unneeded libraries).

Quoted 5 lines

this isnt entirely correct. glibc will still load shared libs on the fly such
as nss and iconv.
-mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101208/4824d582/attachment.html>

#5 lore raw

PATCH 1/1 The external toolchain can be used statically.

Quoted 1 line · On Wednesday, December 08, 2010 05:40:17 Pkun wrote:

Ok.

please dont top post

Quoted 4 lines

May be the right way is to copy only
"/usr/lib/libnss*.so*" and
"/usr/lib/gconv"
when the static is preferred?

no, because that wont pull in the libraries that those libraries need. like libc.so, libresolv.so, ld-linux.so, ...... at which point you might as well leave them alone.

Quoted 3 lines

Or make the shared libraries copying optional in Config.in? Or make checkboxes especially for libnss and conv libraries to force copying?

i think the only safe way would be to let end users remove the files they know they wont need at runtime.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101208/098ded21/attachment.pgp>

author
#6 lore raw

PATCH 1/1 The external toolchain can be used statically.

What about checkbox "Don't copy toolchain libraries to the target dir" that depends on PREFERRED_STATIC. So users who use dynamic linking don't see this checkbox at all. But users who use static linking can manually choose to copy or don't copy shared libraries. It's usefull to create initramfs images at least. It's unlikely that someone make initramfs with complex soft. Usually it will be a static busybox.

2010/12/8 Mike Frysinger <[email protected]>

Quoted 16 lines · On Wednesday, December 08, 2010 05:40:17 Pkun wrote:
Quoted 1 line

Ok.

please dont top post

Quoted 4 lines

May be the right way is to copy only
"/usr/lib/libnss*.so*" and
"/usr/lib/gconv"
when the static is preferred?

no, because that wont pull in the libraries that those libraries need.
like
libc.so, libresolv.so, ld-linux.so, ...... at which point you might as well
leave them alone.

Quoted 9 lines
Quoted 3 lines

Or make the shared libraries copying optional in Config.in? Or make checkboxes especially for libnss and conv libraries to force copying?

i think the only safe way would be to let end users remove the files they know
they wont need at runtime.
-mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101208/6595aa47/attachment.html>

#7 lore raw

PATCH 1/1 The external toolchain can be used statically.

On Wednesday, December 08, 2010 06:26:52 Pkun wrote:

again, please do not top post

Quoted 6 lines

What about checkbox "Don't copy toolchain libraries to the target dir" that depends on PREFERRED_STATIC. So users who use dynamic linking don't see this checkbox at all. But users who use static linking can manually choose to copy or don't copy shared libraries. It's usefull to create initramfs images at least. It's unlikely that someone make initramfs with complex soft.

that's up to Peter, but anything you add will need to include warnings such as ive already spewed

Quoted 1 line

Usually it will be a static busybox.

even a static busybox could try to load those libraries depending on the nss configuration. nss handles simple things like user/group look ups in
/etc/passwd and /etc/group to more complicated like host resolving.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101208/faca16d7/attachment-0001.pgp>