sabotage-linux / netbsd-curses

libcurses and dependencies taken from netbsd and brought into a portable shape (at least to musl or glibc)
Other
147 stars 14 forks source link

dvtm: vt.c:(.text+0x134e): undefined reference to `forkpty' #18

Open githububub opened 7 years ago

githububub commented 7 years ago

Unable to build dvtm against netbsd-curses...

==> Starting build()... cleaning cleaning dvtm build options: CC dvtm.c CC vt.c CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED LDFLAGS = -lcurses CC = cc vt.c: In function ‘vt_forkpty’: vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result] chdir(cwd); ^~~~~~ CC -o dvtm vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference toforkpty' collect2: error: ld returned 1 exit status make: *** [Makefile:25: dvtm] Error 1 ==> ERROR: A failure occurred in build(). Aborting...

Using the Sabotage build recipe as a guideline...

==> Starting build()... cleaning cleaning dvtm build options: CC dvtm.c CC vt.c CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED LDFLAGS = -lncurses CC = cc vt.c: In function ‘vt_forkpty’: vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result] chdir(cwd); ^~~~~~ CC -o dvtm vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference toforkpty' collect2: error: ld returned 1 exit status make: *** [Makefile:25: dvtm] Error 1 ==> ERROR: A failure occurred in build().

With system LDFLAGS build failure...

==> Starting build()... cleaning cleaning dvtm build options: CC dvtm.c CC vt.c CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED LDFLAGS = -Wl,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro -lcurses -lterminfo CC = cc vt.c: In function ‘vt_forkpty’: vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result] chdir(cwd); ^~~~~~ CC -o dvtm vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference toforkpty' collect2: error: ld returned 1 exit status make: *** [Makefile:25: dvtm] Error 1 ==> ERROR: A failure occurred in build(). Aborting...

rofl0r commented 7 years ago

thanks, i updated dvtm package and made a number of fixes : https://github.com/sabotage-linux/sabotage/commit/7e1f9c6ffb83b942a787c288384f99c6064bd39a

forkpty() is a function offered by libc, not by (n)curses. in musl it is in libc.so, but for GLIBC it may be needed to add -lutil to LDFLAGS (see https://linux.die.net/man/3/forkpty ). so the entire LDFLAGS stanza for you would probably be -lcurses -lterminfo -lutil.

githububub commented 7 years ago

Build completed successfully with both -lutil -lcurses -lterminfo and -lc -lutil -lcurses -lterminfo. Thanks :) . This may be more of a dvtm issue so I posed a related question to the dvtm GitHub repo...

rofl0r commented 7 years ago

@githububub i pushed a new release 0.2.0 that should address all issues you've had. let me know how it goes, thanks.

githububub commented 7 years ago

Awesome. Will do when I get to a workstation :) . EDIT: I am not at a personal station so I cannot look into this much further, but running checksec against the binaries in the 0.2.0 build/package directory returns no canary for tabs:

$ checksec -d /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin RELRO STACK CANARY NX PIE RPATH RUNPATH FORTIFY Checked Total Filename Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 4 4 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/infocmp Full RELRO No canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 1 1 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tabs Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 4 7 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tic Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 2 2 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tput Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 2 4 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tset

But this is unrelated to the original issue and just an aside...