Skip to content

Failed to build with GHCJS #419

Description

@vrom911

I'm trying to build the project that has network library as a dependency using GHCJS compiler, but, unfortunately, I get the following error:

Failed to build network-3.1.0.1.
Build log (
/home/vrom911/.cabal/logs/ghcjs-8.4.0.1/network-3.1.0.1-c2dd67eaf943e0b241f84c699a37a0c8bfce83a37ecc86e20e87d1023fb261cd.log
):
Configuring network-3.1.0.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking for an ANSI C-conforming const... yes
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/types.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/uio.h usability... yes
checking sys/uio.h presence... yes
checking for sys/uio.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking netinet/tcp.h usability... yes
checking netinet/tcp.h presence... yes
checking for netinet/tcp.h... yes
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking net/if.h usability... yes
checking net/if.h presence... yes
checking for net/if.h... yes
checking netioapi.h usability... no
checking netioapi.h presence... no
checking for netioapi.h... no
checking for struct ucred... yes
checking for gai_strerror... yes
checking for gethostent... yes
checking for accept4... yes
checking for getpeereid... no
checking whether AI_ADDRCONFIG is declared... yes
checking whether AI_ALL is declared... yes
checking whether AI_NUMERICSERV is declared... yes
checking whether AI_V4MAPPED is declared... yes
checking whether IPV6_V6ONLY is declared... yes
checking whether IPPROTO_IP is declared... yes
checking whether IPPROTO_TCP is declared... yes
checking whether IPPROTO_IPV6 is declared... yes
checking whether SO_PEERCRED is declared... yes
checking for struct msghdr.msg_control... yes
checking for struct msghdr.msg_accrights... no
checking for struct sockaddr.sa_len... no
configure: creating ./network.buildinfo
configure: creating ./config.status
config.status: creating include/HsNetworkConfig.h
configure: WARNING: unrecognized options: --with-compiler
Preprocessing library for network-3.1.0.1..
Building library for network-3.1.0.1..
[ 1 of 24] Compiling Network.Socket.Imports ( Network/Socket/Imports.hs, dist/build/Network/Socket/Imports.js_o )
[ 2 of 24] Compiling Network.Socket.If ( Network/Socket/If.hs, dist/build/Network/Socket/If.js_o )
[ 3 of 24] Compiling Network.Socket.Cbits ( dist/build/Network/Socket/Cbits.hs, dist/build/Network/Socket/Cbits.js_o )
[ 4 of 24] Compiling Network.Socket.Fcntl ( Network/Socket/Fcntl.hs, dist/build/Network/Socket/Fcntl.js_o )

Network/Socket/Fcntl.hs:26:29: error:
    Not in scope: ‘System.Posix.Internals.setCloseOnExec’
    Perhaps you meant ‘System.Posix.Internals.setCooked’ (imported from System.Posix.Internals)
    Module ‘System.Posix.Internals’ does not export ‘setCloseOnExec’.
   |
26 | setCloseOnExecIfNeeded fd = System.Posix.Internals.setCloseOnExec fd
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build network-3.1.0.1 (which is required by exe:issue-wanted
from issue-wanted-0.0.0.0 and exe:frontend-exe from frontend-0.0.0.0). See the
build log above for details.

Could you help me to fix this?

I'm using ghcjs-8.4. building with cabal-install version 3.1.0.0.

Activity

  1. tomsmalley commented on Sep 24, 2019

    @tomsmalley

    We have a patch for this in reflex-platform: reflex-frp/reflex-platform#525

  2. vrom911 commented on Sep 26, 2019

    @vrom911
    MemberAuthor

    That's nice, @tomsmalley ! Would you like to propose this patch to the library here as well?

  3. tomsmalley commented on Sep 26, 2019

    @tomsmalley

    Unfortunately that particular patch is unsuitable for inclusion here: we'd really need the || defined(ghcjs_HOST_OS), but for some reason that wasn't working for me.

  4. kazu-yamamoto commented on Sep 27, 2019

    @kazu-yamamoto
    Collaborator

    I have zero knowledge about GHCJS. Is the unix package of GHCJS different from that of Haskell?

  5. tomsmalley commented on Sep 27, 2019

    @tomsmalley

    setCloseOnExec comes from base. GHCJS patches around the definition too:

    https://github.com/ghcjs/ghcjs/blob/ghc-8.6/lib/patches/base.patch#L608

    The patch for network should probably be done in the same place.

  6. kazu-yamamoto commented on Sep 27, 2019

    @kazu-yamamoto
    Collaborator

    Thanks. Since ghcjs_HOST_OS is officially supported in GHC, we should use it in network, too.
    I will take care of this in the next week.

  7. vrom911 commented on Nov 6, 2019

    @vrom911
    MemberAuthor

    Hey @kazu-yamamoto, have you had a chance to check this out?

  8. avanov commented on Jun 21, 2023

    @avanov

    Hi! I'm getting the following error while compiling network-3.1.4.0 on Mac M2 chip from the main trunk of nixpkgs repository:

    checking build system type... aarch64-apple-darwin22.5.0
    checking host system type... Invalid configuration `js-ghcjs': machine `js-unknown' not recognized
    

    There's a patch for haskell.nix build environment that extends the supported platforms list that doesn't seem to be backported to this repo. And there's a further comment regarding another issue around autoreconf (that probably explains why it wasn't backported here).

    The full log:

    building '/nix/store/rjckcv44i9x4hj8gxr4pd7wdlwih6w1c-network-3.1.4.0.drv'...
    setupCompilerEnvironmentPhase
    Build with /nix/store/i3r1fkbgkjwhbp6ij4i0ridi3niiv487-ghcjs-8.10.7.
    unpacking sources
    unpacking source archive /nix/store/fjcj55yz46i3vmqkrgd7g71fw2p9kkyx-network-3.1.4.0.tar.gz
    source root is network-3.1.4.0
    setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file network-3.1.4.0/tests/Spec.hs
    patching sources
    compileBuildDriverPhase
    setupCompileFlags: -package-db=/private/tmp/nix-build-network-3.1.4.0.drv-0/tmp.4sfvkH6lTw/setup-package.conf.d -j8 -threaded -rtsopts
    [1 of 1] Compiling Main             ( Setup.hs, /private/tmp/nix-build-network-3.1.4.0.drv-0/tmp.4sfvkH6lTw/Main.o )
    Linking Setup ...
    updateAutotoolsGnuConfigScriptsPhase
    Updating Autotools / GNU config script to a newer upstream version: ./config.sub
    Updating Autotools / GNU config script to a newer upstream version: ./config.guess
    configuring
    configureFlags: --verbose --prefix=/nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0 --libdir=$prefix/lib/$compiler --libsubdir=$abi/$libname --docdir=/nix/store/1v4a4mhisvhfj8sjrbiwnzazgdd1m940-network-3.1.4.0-doc/share/doc/network-3.1.4.0 --with-gcc=clang --package-db=/private/tmp/nix-build-network-3.1.4.0.drv-0/tmp.4sfvkH6lTw/package.conf.d --ghc-options=-j8 --disable-split-objs --disable-library-profiling --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --disable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --disable-library-stripping --disable-executable-stripping --ghcjs --extra-include-dirs=/nix/store/nsyj66gs4kq1v95v5ibkjvszyyv8kn2a-libcxx-11.1.0-dev/include --extra-lib-dirs=/nix/store/ykbdajlwk2klq5p4wj28jrs8vzsbxyar-libcxx-11.1.0/lib --extra-include-dirs=/nix/store/vxmfdn3s9ji4mv9zljjfij3a2casfcgd-libcxxabi-11.1.0-dev/include --extra-lib-dirs=/nix/store/jaz1mic7ss4ka3ln779sam02mmgw1msp-libcxxabi-11.1.0/lib --extra-include-dirs=/nix/store/sgab4p8xa3vsqc6qc09fyrgr0k8sn59c-compiler-rt-libc-11.1.0-dev/include --extra-lib-dirs=/nix/store/bhwqg0slgwnnnmj7s9qnrxnykw6vswkg-compiler-rt-libc-11.1.0/lib --extra-lib-dirs=/nix/store/nzsnsxhc2grpc5628icn8drd0i03kijk-apple-framework-CoreFoundation-11.0.0/lib --extra-framework-dirs=/nix/store/nzsnsxhc2grpc5628icn8drd0i03kijk-apple-framework-CoreFoundation-11.0.0/Library/Frameworks --extra-include-dirs=/nix/store/dm123lgglzdl7nw4cnl135b4laxwgcs3-libobjc-11.0.0/include --extra-lib-dirs=/nix/store/dm123lgglzdl7nw4cnl135b4laxwgcs3-libobjc-11.0.0/lib
    Using Parsec parser
    Configuring network-3.1.4.0...
    Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.2.1.0 supports
    'ghc' version < 8.8):
    /nix/store/i3r1fkbgkjwhbp6ij4i0ridi3niiv487-ghcjs-8.10.7/bin/ghcjs is is based
    on GHC version 8.10.7
    Flags chosen: devel=False
    Dependency base >=4.9 && <5: using base-4.14.3.0
    Dependency bytestring >=0.10 && <0.12: using bytestring-0.10.12.0
    Dependency deepseq -any: using deepseq-1.4.4.0
    Dependency directory -any: using directory-1.3.6.0
    Source component graph: component lib
    Configured component graph:
        component network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz
            include base-4.14.3.0-D0KSEBqJsPj2jV088Mzd5k
            include bytestring-0.10.12.0-A1EizoKtfkUxRIgN0VmIs
            include deepseq-1.4.4.0-1l24lJnqQnGEBnHHreMAq3
            include directory-1.3.6.0-7XxNVUbKE5xYZT9KfdX7u
    Linked component graph:
        unit network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz
            include base-4.14.3.0-D0KSEBqJsPj2jV088Mzd5k
            include bytestring-0.10.12.0-A1EizoKtfkUxRIgN0VmIs
            include deepseq-1.4.4.0-1l24lJnqQnGEBnHHreMAq3
            include directory-1.3.6.0-7XxNVUbKE5xYZT9KfdX7u
            Network.Socket=network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz:Network.Socket,Network.Socket.Address=network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz:Network.Socket.Address,Network.Socket.ByteString=network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz:Network.Socket.ByteString,Network.Socket.ByteString.Lazy=network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz:Network.Socket.ByteString.Lazy,Network.Socket.Internal=network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz:Network.Socket.Internal
    Ready component graph:
        definite network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz
            depends base-4.14.3.0-D0KSEBqJsPj2jV088Mzd5k
            depends bytestring-0.10.12.0-A1EizoKtfkUxRIgN0VmIs
            depends deepseq-1.4.4.0-1l24lJnqQnGEBnHHreMAq3
            depends directory-1.3.6.0-7XxNVUbKE5xYZT9KfdX7u
    Using Cabal-3.2.1.0 compiled by ghc-8.10
    Using compiler: ghcjs-8.10.7
    Using install prefix:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0
    Executables installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/bin
    Libraries installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/lib/ghcjs-8.10.7/js-ghcjs-ghcjs-8.10.7-ghc8_10_7/network-3.1.4.0-EmT0GQui0WH4Ciys0PgxPz
    Dynamic Libraries installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/lib/ghcjs-8.10.7/js-ghcjs-ghcjs-8.10.7-ghc8_10_7
    Private executables installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/libexec/js-ghcjs-ghcjs-8.10.7-ghc8_10_7/network-3.1.4.0
    Data files installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/share/js-ghcjs-ghcjs-8.10.7-ghc8_10_7/network-3.1.4.0
    Documentation installed in:
    /nix/store/1v4a4mhisvhfj8sjrbiwnzazgdd1m940-network-3.1.4.0-doc/share/doc/network-3.1.4.0
    Configuration files installed in:
    /nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0/etc
    No alex found
    Using ar found on system at:
    /nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/ar
    No c2hs found
    No cpphs found
    No doctest found
    Using gcc version 11.1.0 given by user at:
    /nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/clang
    Using ghc version 8.10.7 found on system at:
    /nix/store/769cblzdzw9lxkli7vffi920ay9zibf7-ghc-8.10.7/bin/ghc
    Using ghc-pkg version 8.10.7 found on system at:
    /nix/store/769cblzdzw9lxkli7vffi920ay9zibf7-ghc-8.10.7/bin/ghc-pkg
    Using ghcjs version 8.10.7 found on system at:
    /nix/store/i3r1fkbgkjwhbp6ij4i0ridi3niiv487-ghcjs-8.10.7/bin/ghcjs
    Using ghcjs-pkg version 8.10.7 found on system at:
    /nix/store/i3r1fkbgkjwhbp6ij4i0ridi3niiv487-ghcjs-8.10.7/bin/ghcjs-pkg
    No greencard found
    Using haddock version 8.10.7 found on system at:
    /nix/store/i3r1fkbgkjwhbp6ij4i0ridi3niiv487-ghcjs-8.10.7/bin/haddock
    No happy found
    Using haskell-suite found on system at: haskell-suite-dummy-location
    Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
    No hmake found
    Using hpc version 0.68 found on system at:
    /nix/store/769cblzdzw9lxkli7vffi920ay9zibf7-ghc-8.10.7/bin/hpc
    Using hsc2hs version 0.68.7 found on system at:
    /nix/store/769cblzdzw9lxkli7vffi920ay9zibf7-ghc-8.10.7/bin/hsc2hs
    Using hscolour version 1.24 found on system at:
    /nix/store/pyywvwdrvh498zmw0lwakqv7vbx0r2af-hscolour-1.24.4/bin/HsColour
    No jhc found
    Using ld found on system at:
    /nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/ld
    No pkg-config found
    Using runghc version 8.10.7 found on system at:
    /nix/store/769cblzdzw9lxkli7vffi920ay9zibf7-ghc-8.10.7/bin/runghc
    Using strip found on system at:
    /nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/strip
    Using tar found on system at:
    /nix/store/dlmvg1bfqg584jkyq85c5f9fh15kx3nl-gnutar-1.34/bin/tar
    No uhc found
    /nix/store/ag6lcqchlfb3nsn71slrdr9c60a4gf88-bash-5.2-p15/bin/sh //private/tmp/nix-build-network-3.1.4.0.drv-0/network-3.1.4.0/configure '--host=js-ghcjs' '--with-compiler=ghcjs' '--prefix=/nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0' '--libdir=$prefix/lib/$compiler' 'CC=/nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/clang'
    configure: WARNING: unrecognized options: --with-compiler
    checking build system type... aarch64-apple-darwin22.5.0
    checking host system type... Invalid configuration `js-ghcjs': machine `js-unknown' not recognized
    configure: error: /nix/store/ag6lcqchlfb3nsn71slrdr9c60a4gf88-bash-5.2-p15/bin/bash //private/tmp/nix-build-network-3.1.4.0.drv-0/network-3.1.4.0/config.sub js-ghcjs failed
    error: builder for '/nix/store/rjckcv44i9x4hj8gxr4pd7wdlwih6w1c-network-3.1.4.0.drv' failed with exit code 1;
           last 10 log lines:
           > Using strip found on system at:
           > /nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/strip
           > Using tar found on system at:
           > /nix/store/dlmvg1bfqg584jkyq85c5f9fh15kx3nl-gnutar-1.34/bin/tar
           > No uhc found
           > /nix/store/ag6lcqchlfb3nsn71slrdr9c60a4gf88-bash-5.2-p15/bin/sh //private/tmp/nix-build-network-3.1.4.0.drv-0/network-3.1.4.0/configure '--host=js-ghcjs' '--with-compiler=ghcjs' '--prefix=/nix/store/dqj7l6as809mr3l0kv8l57jybchqrnj1-network-3.1.4.0' '--libdir=$prefix/lib/$compiler' 'CC=/nix/store/h2r0ivj6r22nbiaxak9lqgcx7pa69p9f-clang-wrapper-11.1.0/bin/clang'
           > configure: WARNING: unrecognized options: --with-compiler
           > checking build system type... aarch64-apple-darwin22.5.0
           > checking host system type... Invalid configuration `js-ghcjs': machine `js-unknown' not recognized
           > configure: error: /nix/store/ag6lcqchlfb3nsn71slrdr9c60a4gf88-bash-5.2-p15/bin/bash //private/tmp/nix-build-network-3.1.4.0.drv-0/network-3.1.4.0/config.sub js-ghcjs failed
           For full logs, run 'nix log /nix/store/rjckcv44i9x4hj8gxr4pd7wdlwih6w1c-network-3.1.4.0.drv'.
    error: 1 dependencies of derivation '/nix/store/w6n23r0gyf3n7i3hjls5clbfqqdgbmyf-ghcjs-8.10.7-with-packages.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/8za0vi763n00z028h1ig5iyy4d9bd8z2-nix-shell.drv' failed to build
    
  9. Gabriella439 commented on Jun 3, 2025

    @Gabriella439

    The reason the Nix build for the network package fails with GHCJS is because of the update-autotools-gnu-config-scripts.sh setup hook, which regenerates config.sub. The network package has a manual override to override config.sub to support the js-ghcjs configuration and the setup hook was wiping out that change.

    The fix is to change the network derivation to not run that setup hook, like this:

    network.overrideAttrs (old: {
      dontUpdateAutotoolsGnuConfigScripts = true;
    })
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions