haskell / haskeline

A Haskell library for line input in command-line programs.
https://hackage.haskell.org/package/haskeline
BSD 3-Clause "New" or "Revised" License
221 stars 75 forks source link

CentOS 7 install failure #79

Closed rbarden closed 6 years ago

rbarden commented 6 years ago

As part of another program I am installing, I get the following error:

[rbarden ~]$ stack install haskeline-0.7.4.2
haskeline-0.7.4.2: configure
haskeline-0.7.4.2: build

--  While building custom Setup.hs for package haskeline-0.7.4.2 using:
      /home/rbarden/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /home/rbarden/.stack/global-project/.stack-work/logs/haskeline-0.7.4.2.log

    Configuring haskeline-0.7.4.2...
    Preprocessing library for haskeline-0.7.4.2..
    /tmp/stack31890/haskeline-0.7.4.2/In file included from .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/System/Console/Haskeline/Backend/Posix_hsc_make.c:1:0:
    Posix.hsc: In function ‘main’:
    /tmp/stack31890/haskeline-0.7.4.2/Posix.hsc:70:16: error: ‘TIOCGWINSZ’ undeclared (first use in this function)
    /home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
         if ((x) < 0)                                      \
              ^
    /tmp/stack31890/haskeline-0.7.4.2/Posix.hsc:70:16: note: each undeclared identifier is reported only once for each function it appears in
    /home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
         if ((x) < 0)                                      \
              ^
    compiling .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/System/Console/Haskeline/Backend/Posix_hsc_make.c failed (exit code 1)
    command was: /bin/gcc -c .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/System/Console/Haskeline/Backend/Posix_hsc_make.c -o .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/System/Console/Haskeline/Backend/Posix_hsc_make.o -std=gnu99 -fno-stack-protector -std=gnu99 -fno-stack-protector -fPIC -fuse-ld=gold -D__GLASGOW_HASKELL__=802 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iincludes -DTERMINFO -I.stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/autogen -I.stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/global-autogen -include .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/autogen/cabal_macros.h -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/process-1.6.1.0/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/directory-1.3.0.2/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/unix-2.7.2.2/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/time-1.8.0.2/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/bytestring-0.10.8.2/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/base-4.10.1.0/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/integer-gmp-1.0.1.0/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/include -I/home/rbarden/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/include/
[rbarden ~]$ stack --version
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0

Having tried to install anything and everything the internet tells me to to get TIOCGWINSZ and not finding anything about the other note, I'm at a loss.

hvr commented 6 years ago

@rbarden any chance you could try building the same release with cabal to get another data point, i.e. via

$ cabal get haskeline-0.7.4.2
$ cd haskeline-0.7.4.2
$ cabal update
$ cabal new-build -j1

?

judah commented 6 years ago

Thanks for the report. This sounds like an issue with not importing the right C headers on your OS. Haskeline has a special case for Solaris and Android to use a different header for that definition; possibly it needs a similar special case for CentOS.

See: https://github.com/judah/haskeline/blob/master/haskeline.cabal#L108 https://github.com/judah/haskeline/blob/master/System/Console/Haskeline/Backend/Posix.hsc#L45

I'm not familiar with CentOS specifically, but a good first step would be to try @hvr's steps for building Haskeline manually and then seeing whether changing Posix.hsc to refer to a different header fixes it on your machine.

rbarden commented 6 years ago

I will do that probably tomorrow. Just for more context, someone else on a fresh centos VM did not run into this problem.

rbarden commented 6 years ago

Actually, I ended up just doing it now. This is the result, same error:

[rbarden haskeline-0.7.4.2]$ cabal new-build -j1

Resolving dependencies...
In order, the following will be built (use -v for more details):
 - stm-2.4.5.0 (lib) (requires download & build)
 - haskeline-0.7.4.2 (lib) (first run)
Downloading stm-2.4.5.0...
Configuring library for stm-2.4.5.0..
Preprocessing library for stm-2.4.5.0..
Building library for stm-2.4.5.0..
[ 1 of 10] Compiling Control.Concurrent.STM.TBQueue ( Control/Concurrent/STM/TBQueue.hs, dist/build/Control/Concurrent/STM/TBQueue.o )
[ 2 of 10] Compiling Control.Concurrent.STM.TChan ( Control/Concurrent/STM/TChan.hs, dist/build/Control/Concurrent/STM/TChan.o )
[ 3 of 10] Compiling Control.Concurrent.STM.TMVar ( Control/Concurrent/STM/TMVar.hs, dist/build/Control/Concurrent/STM/TMVar.o )
[ 4 of 10] Compiling Control.Concurrent.STM.TQueue ( Control/Concurrent/STM/TQueue.hs, dist/build/Control/Concurrent/STM/TQueue.o )
[ 5 of 10] Compiling Control.Concurrent.STM.TVar ( Control/Concurrent/STM/TVar.hs, dist/build/Control/Concurrent/STM/TVar.o )
[ 6 of 10] Compiling Control.Concurrent.STM.TArray ( Control/Concurrent/STM/TArray.hs, dist/build/Control/Concurrent/STM/TArray.o )
[ 7 of 10] Compiling Control.Monad.STM ( Control/Monad/STM.hs, dist/build/Control/Monad/STM.o )
[ 8 of 10] Compiling Control.Concurrent.STM ( Control/Concurrent/STM.hs, dist/build/Control/Concurrent/STM.o )
[ 9 of 10] Compiling Control.Concurrent.STM.TSem ( Control/Concurrent/STM/TSem.hs, dist/build/Control/Concurrent/STM/TSem.o )
[10 of 10] Compiling Control.Sequential.STM ( Control/Sequential/STM.hs, dist/build/Control/Sequential/STM.o )
Installing library in /home/rbarden/.cabal/store/ghc-8.2.2/incoming/new-25847/home/rbarden/.cabal/store/ghc-8.2.2/stm-2.4.5.0-79b0730c6921a0e18c071902e31d6f90e20c3f3d80283bef1ecdd0b7f5fe4995/lib
Configuring library for haskeline-0.7.4.2..
Preprocessing library for haskeline-0.7.4.2..
In file included from /home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/System/Console/Haskeline/Backend/Posix_hsc_make.c:1:0:
Posix.hsc: In function ‘main’:
Posix.hsc:70:16: error: ‘TIOCGWINSZ’ undeclared (first use in this function)
/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
     if ((x) < 0)                                      \
          ^
Posix.hsc:70:16: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/template-hsc.h:38:10: note: in definition of macro ‘hsc_const’
     if ((x) < 0)                                      \
          ^
compiling /home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/System/Console/Haskeline/Backend/Posix_hsc_make.c failed (exit code 1)
command was: /bin/gcc -c /home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/System/Console/Haskeline/Backend/Posix_hsc_make.c -o /home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/System/Console/Haskeline/Backend/Posix_hsc_make.o -std=gnu99 -fno-stack-protector -std=gnu99 -fno-stack-protector -fuse-ld=gold -D__GLASGOW_HASKELL__=802 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Iincludes -DTERMINFO -I/home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/autogen -I/home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/global-autogen -include /home/rbarden/haskeline-0.7.4.2/dist-newstyle/build/x86_64-linux/ghc-8.2.2/haskeline-0.7.4.2/build/autogen/cabal_macros.h -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/process-1.6.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/directory-1.3.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/unix-2.7.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/time-1.8.0.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/bytestring-0.10.8.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/base-4.10.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/integer-gmp-1.0.1.0/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/include -I/usr/local/haskell/ghc-8.2.2-x86_64/lib/ghc-8.2.2/include/
hvr commented 6 years ago

@rbarden I just tried on a CentOS box (and couldn't reproduce your issue), and libtinfo is provided by ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm; whereas TIOCGWINSZ is defined in asm-generic/ioctls.h which is provided by kernel-headers-3.10.0-693.17.1.el7.x86_64

It would be worth a try, trying to compile a simple C program which tests for the presence of the TIOCGWINSZ macro, and see whether your C compiler environment is working as expected.

Specifically, for me, a simple test.c file such as

#include <sys/ioctl.h>

#if !defined(TIOCGWINSZ)
#error not defined
#endif

compiles successfully on CentOS, as it should.

rbarden commented 6 years ago

@hvr which command did you run to compile it? Do I need to specifically link anything? If not, then I get an error. Also, my ncurses-devel and kernel-headers are the same versions.

hvr commented 6 years ago

@rbarden simply gcc -c test.c; ok, then something's strange with your setup/installation. It's very unusual on a Linux box that TIOCGWINSZ can't be found via <sys/ioctl.h>...

does anything change if you also add #include <termios.h> to test.c?

rbarden commented 6 years ago

Still undefined. I know it is very strange, I've never had a problem like this before. Considering just backing up data and reinstalling the OS.

hvr commented 6 years ago

@rbarden one thing you could try before reinstalling everything,

invoke gcc -E test.c

and look at which files the C preprocessor loads up (the line pragmas starting with a # sign tell you which files cpp loaded); see if there's anything suspicious; compare the output to the output from another CentOS box.

rbarden commented 6 years ago
# 1 "simple.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "simple.c"
# 1 "/usr/include/sys/ioctl.h" 1 3 4
# 21 "/usr/include/sys/ioctl.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 375 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 392 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 393 "/usr/include/sys/cdefs.h" 2 3 4
# 376 "/usr/include/features.h" 2 3 4
# 399 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 3 4
# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 11 "/usr/include/gnu/stubs.h" 2 3 4
# 400 "/usr/include/features.h" 2 3 4
# 22 "/usr/include/sys/ioctl.h" 2 3 4

# 1 "/usr/include/bits/ioctls.h" 1 3 4
# 23 "/usr/include/bits/ioctls.h" 3 4
# 1 "/usr/include/asm/ioctls.h" 1 3 4
# 24 "/usr/include/bits/ioctls.h" 2 3 4
# 27 "/usr/include/sys/ioctl.h" 2 3 4

# 1 "/usr/include/bits/ioctl-types.h" 1 3 4
# 24 "/usr/include/bits/ioctl-types.h" 3 4
# 1 "/usr/include/asm/ioctls.h" 1 3 4
# 25 "/usr/include/bits/ioctl-types.h" 2 3 4

struct winsize
  {
    unsigned short int ws_row;
    unsigned short int ws_col;
    unsigned short int ws_xpixel;
    unsigned short int ws_ypixel;
  };

struct termio
  {
    unsigned short int c_iflag;
    unsigned short int c_oflag;
    unsigned short int c_cflag;
    unsigned short int c_lflag;
    unsigned char c_line;
    unsigned char c_cc[8];
};
# 30 "/usr/include/sys/ioctl.h" 2 3 4

# 1 "/usr/include/sys/ttydefaults.h" 1 3 4
# 37 "/usr/include/sys/ioctl.h" 2 3 4

extern int ioctl (int __fd, unsigned long int __request, ...) __attribute__ ((__nothrow__ , __leaf__));

# 2 "simple.c" 2
# 1 "/usr/include/termios.h" 1 3 4
# 29 "/usr/include/termios.h" 3 4
# 1 "/usr/include/bits/types.h" 1 3 4
# 27 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 28 "/usr/include/bits/types.h" 2 3 4

typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;

typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;

typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;

typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
# 130 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 131 "/usr/include/bits/types.h" 2 3 4

typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;

typedef int __daddr_t;
typedef int __key_t;

typedef int __clockid_t;

typedef void * __timer_t;

typedef long int __blksize_t;

typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;

typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;

typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;

typedef long int __fsword_t;

typedef long int __ssize_t;

typedef long int __syscall_slong_t;

typedef unsigned long int __syscall_ulong_t;

typedef __off64_t __loff_t;
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;

typedef long int __intptr_t;

typedef unsigned int __socklen_t;
# 30 "/usr/include/termios.h" 2 3 4

typedef __pid_t pid_t;

# 1 "/usr/include/bits/termios.h" 1 3 4
# 23 "/usr/include/bits/termios.h" 3 4
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;

struct termios
  {
    tcflag_t c_iflag;
    tcflag_t c_oflag;
    tcflag_t c_cflag;
    tcflag_t c_lflag;
    cc_t c_line;
    cc_t c_cc[32];
    speed_t c_ispeed;
    speed_t c_ospeed;

  };
# 41 "/usr/include/termios.h" 2 3 4
# 49 "/usr/include/termios.h" 3 4
extern speed_t cfgetospeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));

extern speed_t cfgetispeed (const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));

extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));

extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));

extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __attribute__ ((__nothrow__ , __leaf__));

extern int tcgetattr (int __fd, struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));

extern int tcsetattr (int __fd, int __optional_actions,
        const struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));

extern void cfmakeraw (struct termios *__termios_p) __attribute__ ((__nothrow__ , __leaf__));

extern int tcsendbreak (int __fd, int __duration) __attribute__ ((__nothrow__ , __leaf__));

extern int tcdrain (int __fd);

extern int tcflush (int __fd, int __queue_selector) __attribute__ ((__nothrow__ , __leaf__));

extern int tcflow (int __fd, int __action) __attribute__ ((__nothrow__ , __leaf__));

extern __pid_t tcgetsid (int __fd) __attribute__ ((__nothrow__ , __leaf__));

# 1 "/usr/include/sys/ttydefaults.h" 1 3 4
# 106 "/usr/include/termios.h" 2 3 4

# 3 "simple.c" 2
simple.c:5:2: error: #error not defined
 #error not defined
  ^
rbarden commented 6 years ago

A kernel update just came out and I ran it and I had no problems this time. I'll say it was a bug with the last kernel and leave it at that.