tcsh-org / tcsh

This is a read-only mirror of the tcsh code repository.
https://www.tcsh.org/
Other
237 stars 42 forks source link

Build fails on RISC-V: `tc.func.c:(.text+0x1726): undefined reference to `crypt'` #111

Closed barracuda156 closed 1 month ago

barracuda156 commented 1 month ago
rm -f tcsh core
cc -o tcsh -L/opt/pkg-2024Q2/lib -Wl,-R/opt/pkg-2024Q2/lib -O2 -I/opt/pkg-2024Q2/include/ncurses -I. -I. sh.o sh.dir.o sh.dol.o sh.err.o sh.exec.o  sh.char.o sh.exp.o sh.file.o sh.func.o  sh.glob.o sh.hist.o sh.init.o sh.lex.o  sh.misc.o sh.parse.o sh.print.o sh.proc.o  sh.sem.o sh.set.o sh.time.o glob.o dotlock.o  mi.termios.o ma.setp.o vms.termcap.o tw.help.o tw.init.o tw.parse.o tw.spell.o  tw.comp.o tw.color.o ed.chared.o ed.refresh.o ed.screen.o ed.init.o  ed.inputl.o ed.defns.o ed.xmap.o ed.term.o tc.alloc.o tc.bind.o tc.const.o tc.defs.o  tc.disc.o tc.func.o tc.nls.o tc.os.o tc.printf.o  tc.prompt.o tc.sched.o tc.sig.o tc.str.o  tc.vers.o tc.who.o -ltermcap 
/usr/lib/gcc/riscv64-pine64-linux/11.3.0/../../../../riscv64-pine64-linux/bin/ld: tc.func.o: in function `.L0 ':
tc.func.c:(.text+0x1726): undefined reference to `crypt'
collect2: error: ld returned 1 exit status
*** Error code 1

Stop.
bmake: stopped making "all" in /home/pine64/Downloads/pkgsrc/pkgsrc/shells/tcsh/work/tcsh-6.24.13
*** Error code 1

Stop.
bmake[1]: stopped making "install" in /home/pine64/Downloads/pkgsrc/pkgsrc/shells/tcsh
*** Error code 1

Stop.
bmake: stopped making "install clean" in /home/pine64/Downloads/pkgsrc/pkgsrc/shells/tcsh
suominen commented 1 month ago

Which operating system are you using? If you compile from the tcsh distribution tarball directly, does that work? See instructions in https://github.com/tcsh-org/tcsh/blob/master/BUILDING.

suominen commented 1 month ago

Do you have the crypt library installed? E.g. on Debian this would be the libcrypt1 package (apt install libcrypt1).

suominen commented 1 month ago
# dpkg -s tcsh
Package: tcsh
Status: install ok installed
Priority: optional
Section: shells
Installed-Size: 1332
Maintainer: Josef Schneider <josef81sch@gmail.com>
Architecture: riscv64
Multi-Arch: foreign
Version: 6.24.13-2
Provides: c-shell
Depends: libc6 (>= 2.38), libcrypt1 (>= 1:4.1.0), libtinfo6 (>= 6)
[...]

Running on:

# uname -sm
Linux riscv64
# lsb_release -ics
Debian
trixie
suominen commented 1 month ago
~> sudo apt install build-essential libncurses-dev autoconf
[...]
~> curl -LO https://astron.com/pub/tcsh/tcsh-6.24.13.tar.gz
~> tar xf tcsh-6.24.13.tar.gz
~> cd tcsh-6.24.13
~/tcsh-6.24.13> ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... riscv64-unknown-linux-gnu
checking host system type... riscv64-unknown-linux-gnu
checking for gcc... gcc
[...]
checking for library containing crypt... -lcrypt
checking for library containing getspnam... none required
checking for library containing tgetent... -ltinfo
[...]
checking whether crypt is declared... yes
[...]
configure: LIBS                    -ltinfo -lcrypt
[...]
configure: tcsh_config_file        system/linux
configure: =========================================
~/tcsh-6.24.13> make
[...]
rm -f tcsh core
gcc -o tcsh  -g -O2 -I. -I. sh.o sh.dir.o sh.dol.o sh.err.o sh.exec.o sh.char.o sh.exp.o sh.file.o sh.func.o sh.glob.o sh.hist.o sh.init.o sh.lex.o sh.misc.o sh.parse.o sh.print.o sh.proc.o sh.sem.o sh.set.o sh.time.o glob.o dotlock.o mi.termios.o ma.setp.o vms.termcap.o tw.help.o tw.init.o tw.parse.o tw.spell.o tw.comp.o tw.color.o ed.chared.o ed.refresh.o ed.screen.o ed.init.o ed.inputl.o ed.defns.o ed.xmap.o ed.term.o tc.alloc.o tc.bind.o tc.const.o tc.defs.o tc.disc.o tc.func.o tc.nls.o tc.os.o tc.printf.o tc.prompt.o tc.sched.o tc.sig.o tc.str.o tc.vers.o tc.who.o  -ltinfo -lcrypt
[...]
~/tcsh-6.24.13> make test
[...]
## ------------- ##
## Test results. ##
## ------------- ##

196 tests were successful.
53 tests were skipped.
barracuda156 commented 1 month ago

Do you have the crypt library installed? E.g. on Debian this would be the libcrypt1 package (apt install libcrypt1).

Looks like pkgsrc does not declare a dependency on it: https://github.com/NetBSD/pkgsrc/blob/trunk/shells/tcsh/Makefile.common

suominen commented 1 month ago

Does adding it fix it for you? Can you provide a diff? Which operating system are you using?

barracuda156 commented 1 month ago

Does adding it fix it for you? Can you provide a diff? Which operating system are you using?

pinetabv-image-plasma from https://github.com/Fishwaldo/meta-pine64 I will add uname output in 10 min, away from machine right now.

I will try adding that package but if it is not available in pkgsrc then I need to figure out how to build it by hand. (Sorry, I always used MacPorts build system, which I know pretty well, but it needs some fixes for riscv to work. Figuring out how to install something from source on a system which I never used before takes time.)

barracuda156 commented 1 month ago
sh-5.1$ uname -a
Linux pinetabv 5.15.131 #1 SMP Thu Sep 21 04:12:12 UTC 2023 riscv64 riscv64 riscv64 GNU/Linux
suominen commented 1 month ago

You could try apt-cache search libcrypt shared library although that depends on "shared library" being part of the package description.

I don't think there is a mechanism in pkgsrc that would make the crypt library available. I think it is assumed to be available from the underlying operating system.

barracuda156 commented 1 month ago

It could be that BSD does not use anything of a sort, and Linux was not tested. Though pkgsrc explicitly claims support for Linux (unlike MacPorts).

On macOS tcsh does not use any crypto-related ports, whether for the build or for linking.

svacchanda@43-200 macports-ports-powerpc % otool -L /opt/local/bin/tcsh
/opt/local/bin/tcsh:
    /opt/local/lib/libncurses.6.dylib (compatibility version 6.0.0, current version 6.0.0)
    /opt/local/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)

So perhaps only Linux needs that for w/e reason.

Debian has libcrypt1 for riscv in unstable tree, but it requires a version of libc6 way higher than I have in the system. I tried to update libc6, but dpkg refused with an error message that it gonna break some other components…

But yeah, this is not your bug, obviously, but likely an issue with pkgsrc. (I cannot try installing via MacPorts yet, but since there is no claim of proper support for Linux, a failure won’t qualify as a bug.)

suominen commented 1 month ago

macOS has crypt() in its standard C library (as does e.g. OpenBSD). Most systems, though, have it in a separate crypt library. The configure script checks for this, and will add the library where needed.

You could, I guess, include the configure output from your attempt to install using pkgsrc, and it might provide further insight.

Still, I'm afraid it will boil down to the operating system having to make crypt() available. It is not provided by pkgsrc (or MacPorts, for that matter).