Page MenuHomeFreeBSD

shells/bash-static: Exclude PORTS_READLINE and NLS options with STATIC
Needs ReviewPublic

Authored by ehaupt on Mar 1 2025, 10:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 14, 5:09 AM
Unknown Object (File)
Tue, May 13, 1:01 PM
Unknown Object (File)
Tue, Apr 29, 8:57 PM
Unknown Object (File)
Sun, Apr 27, 11:08 AM
Unknown Object (File)
Apr 14 2025, 4:12 PM
Unknown Object (File)
Apr 14 2025, 12:05 PM
Unknown Object (File)
Apr 5 2025, 8:25 PM
Unknown Object (File)
Mar 29 2025, 1:38 PM
Subscribers
This revision needs review, but there are no reviewers specified.

Details

Summary

When building the static version of bash, runtime dependencies on
gettext-runtime and readline should not be present as the binary is
statically linked. This change excludes the PORTS_READLINE and NLS
options in the slave port to avoid unnecessary dependencies.

Diff Detail

Repository
R11 FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ehaupt created this revision.

Why can't these archive files be leveraged:

osipovmi@deblndw011x:/usr/local/lib
$ ll . | grep -e readline.a -e gettext.*.a -e intl.a -e btextstyle.a -e history.a
-rw-r--r--   1 root  wheel    3093882 2025-01-09 17:56 libgettextlib.a
-rw-r--r--   1 root  wheel     887444 2025-01-09 17:56 libgettextpo.a
-rw-r--r--   1 root  wheel     723450 2025-01-09 17:56 libgettextsrc.a
-rw-r--r--   1 root  wheel      73148 2025-01-09 17:53 libhistory.a
-rw-r--r--   1 root  wheel     268444 2025-01-09 17:53 libintl.a
-rw-r--r--   1 root  wheel     703534 2025-01-09 17:53 libreadline.a
-rw-r--r--   1 root  wheel    1497002 2025-01-09 17:53 libtextstyle.a

in contrast to

$ ldd -a /usr/local/bin/bash
/usr/local/bin/bash:
        libreadline.so.8 => /usr/local/lib/libreadline.so.8 (0x3d9c55c21000)
        libhistory.so.8 => /usr/local/lib/libhistory.so.8 (0x3d9c55465000)
        libncursesw.so.9 => /lib/libncursesw.so.9 (0x3d9c57482000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x3d9c5658b000)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x3d9c594a1000)
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/usr/local/lib/libreadline.so.8:
        libncursesw.so.9 => /lib/libncursesw.so.9 (0x3d9c57482000)
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/usr/local/lib/libhistory.so.8:
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/lib/libncursesw.so.9:
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/usr/local/lib/libintl.so.8:
        libthr.so.3 => /lib/libthr.so.3 (0x3d9c58d4f000)
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/usr/lib/libdl.so.1:
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
/lib/libthr.so.3:
        libc.so.7 => /lib/libc.so.7 (0x3d9c57bb6000)
[preloaded]
        [vdso] (0x7ffffffff000)

?

Just tried in poudriere, previously all dynamically linked, now statically:

root@134-release-amd64-default-head-common:/usr/ports/shells/bash # ls -l /usr/local/bin/bash
-rwxr-xr-x  1 root  wheel  2434520 Mar  1 21:27 /usr/local/bin/bash

What am I missing?

static port:

cd /usr/ports/shells/bash-static
make rmconfig
pkg delete -y bash-static || pkg delete -y bash
BATCH=yes make install clean
ldd `which bash`
ldd: /usr/local/bin/bash: not a dynamic ELF executable

dynamic port:

cd /usr/ports/shells/bash
make rmconfig
pkg delete -y bash-static || pkg delete -y bash
BATCH=yes make install clean
ldd `which bash`
/usr/local/bin/bash:
        libreadline.so.8 => /usr/local/lib/libreadline.so.8 (0x358f2f726000)
        libhistory.so.8 => /usr/local/lib/libhistory.so.8 (0x358f30541000)
        libtinfow.so.9 => /lib/libtinfow.so.9 (0x358f31405000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x358f325a7000)
        libdl.so.1 => /usr/lib/libdl.so.1 (0x358f316e1000)
        libc.so.7 => /lib/libc.so.7 (0x358f33544000)
        libthr.so.3 => /lib/libthr.so.3 (0x358f34ef2000)
        [vdso] (0x358f2f53e000)

I am not sure exactly what you mean. Could you elaborate a bit more in detail on what you're testing? Could you also please clarify the "leveraging" part?

This revision was not accepted when it landed; it landed in state Needs Review.Mar 2 2025, 3:22 PM
This revision was automatically updated to reflect the committed changes.

This looks perfectly fine:

root@134-release-amd64-default-head-common:/usr/ports/shells/bash # pkg info bash
bash-5.2.37
Name           : bash
Version        : 5.2.37
Installed on   : Sun Mar  2 18:59:55 2025 UTC
Origin         : shells/bash
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : shells
Licenses       : GPLv3+
Maintainer     : [email protected]
WWW            : https://www.gnu.org/software/bash/
Comment        : GNU Project's Bourne Again SHell
Options        :
        DOCS           : on
        FDESCFS        : on
        HELP           : on
        NLS            : on
        PORTS_READLINE : on
        STATIC         : on
        SYSBASHRC      : on
        SYSLOG         : off
Annotations    :
        FreeBSD_version: 1304000
        build_timestamp: 2025-03-02T18:58:50+00:00
        built_by       : poudriere-git-3.4.99.20250209
        cpe            : cpe:2.3:a:gnu:bash:5.2.37:::::freebsd13:x64
        port_checkout_unclean: no
        port_git_hash  : ddd71f4562b6
        ports_top_checkout_unclean: no
        ports_top_git_hash: be43a1389fac
Flat size      : 10.1MiB
Description    :
This is GNU Bash.  Bash is the GNU Project's Bourne Again SHell,
a complete implementation of the POSIX.2 shell spec, but also
with interactive command line editing, job control on architectures
that support it, csh-like features such as history substitution and
brace expansion, and a slew of other features.
root@134-release-amd64-default-head-common:/usr/ports/shells/bash # bash
[root@134-release-amd64-default-head-common /usr/ports/shells/bash]# echo $BASH
$BASH                 $BASHPID              $BASH_ARGC            $BASH_ARGV0           $BASH_COMMAND         $BASH_LOADABLES_PATH  $BASH_SUBSHELL        $BASH_VERSION
$BASHOPTS             $BASH_ALIASES         $BASH_ARGV            $BASH_CMDS            $BASH_LINENO          $BASH_SOURCE          $BASH_VERSINFO
[root@134-release-amd64-default-head-common /usr/ports/shells/bash]# echo $BASH
/usr/local/bin/bash
[root@134-release-amd64-default-head-common /usr/ports/shells/bash]# ldd /usr/local/bin/bash
ldd: /usr/local/bin/bash: not a dynamic ELF executable
[root@134-release-amd64-default-head-common /usr/ports/shells/bash]# file /usr/local/bin/bash
/usr/local/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 13.4, FreeBSD-style, stripped

The message from ldd is expected because the executable isn't dynamic. Does this make sense for you?

The message from ldd is expected because the executable isn't dynamic. Does this make sense for you?

You chose:

STATIC : on

LDD reports:

[root@134-release-amd64-default-head-common /usr/ports/shells/bash]# ldd /usr/local/bin/bash
ldd: /usr/local/bin/bash: not a dynamic ELF executable
  • Makes sense

file reports:

/usr/local/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 13.4, FreeBSD-style, stripped
  • Makes sense

@ehaupt, do you want to close this out as a user problem and not a port problem?

@ehaupt, do you want to close this out as a user problem and not a port problem?

Yes. I'd like to do that. If the user wants to have a static version without any port readline or gettext he can simply rebuild shells/bash-static without those options. Sure, no pre-built pkgs but that's just the way it is.

@ehaupt, do you want to close this out as a user problem and not a port problem?

Yes. I'd like to do that. If the user wants to have a static version without any port readline or gettext he can simply rebuild shells/bash-static without those options. Sure, no pre-built pkgs but that's just the way it is.

True, but I don't see a problem to have both statically linked. It works, IMHO.

OSZAR »