Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ghci being launched before other sources are built #6923

Merged
merged 1 commit into from
Jul 7, 2020

Conversation

lukel97
Copy link
Contributor

@lukel97 lukel97 commented Jun 21, 2020

The following case previously failed

$ cat foo.c
int foo() { return 42; }
$ cat Lib.hs
module Lib where

foreign import ccall "foo" foo :: Int

bar = foo
$ cat cabal-csrc-repl.cabal
cabal-version:      2.4
name:               cabal-csrc-repl
version:            0.1.0.0
library
    exposed-modules:  Lib
    build-depends:    base ^>=4.14.0.0
    C-sources:        foo.c
    default-language: Haskell2010
$ cabal v2-repl
Resolving dependencies...
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - cabal-csrc-repl-0.1.0.0 (lib) (first run)
Configuring library for cabal-csrc-repl-0.1.0.0..
Preprocessing library for cabal-csrc-repl-0.1.0.0..
GHCi, version 8.10.1: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( Lib.hs, interpreted )
Ok, one module loaded.
*Lib> foo
ghc: ^^ Could not load '_foo', dependency unresolved. See top entry above.

Looks like an accident from a6e427a

@lukel97 lukel97 changed the title Fix ghci being launched before other sources were built Fix ghci being launched before other sources are built Jun 21, 2020
@lukel97 lukel97 force-pushed the fix-repl-build-deps branch 4 times, most recently from 8d72466 to d063542 Compare June 23, 2020 14:51
@lukel97
Copy link
Contributor Author

lukel97 commented Jun 23, 2020

ping @phadej

cabal-testsuite/src/Test/Cabal/Run.hs Show resolved Hide resolved
cabal-testsuite/src/Test/Cabal/Prelude.hs Outdated Show resolved Hide resolved
cabal-testsuite/src/Test/Cabal/Prelude.hs Outdated Show resolved Hide resolved
Cabal/Distribution/Simple/GHC.hs Show resolved Hide resolved
This looks like an accident from a6e427a
It causes cases like this to fail:

$ cat foo.c
int foo() { return 42; }
$ cat Lib.hs
module Lib where

foreign import ccall "foo" foo :: Int

bar = foo
$ cat cabal-csrc-repl.cabal
cabal-version:      2.4
name:               cabal-csrc-repl
version:            0.1.0.0
library
    exposed-modules:  Lib
    build-depends:    base ^>=4.14.0.0
    C-sources:        foo.c
    default-language: Haskell2010
$ cabal v2-repl
Resolving dependencies...
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - cabal-csrc-repl-0.1.0.0 (lib) (first run)
Configuring library for cabal-csrc-repl-0.1.0.0..
Preprocessing library for cabal-csrc-repl-0.1.0.0..
GHCi, version 8.10.1: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( Lib.hs, interpreted )
Ok, one module loaded.
*Lib> foo
ghc: ^^ Could not load '_foo', dependency unresolved. See top entry above.
@lukel97 lukel97 requested a review from phadej June 24, 2020 10:49
@lukel97 lukel97 force-pushed the fix-repl-build-deps branch from d063542 to e3d2608 Compare June 24, 2020 10:49
Copy link
Collaborator

@DanielG DanielG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cabal-testsuite/src/Test/Cabal/Run.hs Show resolved Hide resolved
@phadej phadej merged commit 2d78853 into haskell:master Jul 7, 2020
@phadej phadej added this to the 3.4.0.0-rc1 milestone Jul 10, 2020
@phadej
Copy link
Collaborator

phadej commented Jul 10, 2020

I have troubles writing a changelog entry for this fix.

The title of this PR doesn't make sense standalone.

@phadej phadej mentioned this pull request Jul 10, 2020
@lukel97
Copy link
Contributor Author

lukel97 commented Jul 11, 2020

@phadej maybe something like

Fix an issue where cabal repl would fail to build C sources before launching the GHCI session

@phadej
Copy link
Collaborator

phadej commented Aug 9, 2020

I'm suspecting changes in run cause haskell/network#474 regression.

If it so, I'll will revert this PR.

EDIT: see https://lists.gforge.inria.fr/pipermail/cado-nfs-commits/2015-August/005301.html

turns out configure can conceivably be called with fd 0 closed, e.g. in
an unattended cluster script. For example this groans.
$ (test -n "$DJDIR" || exec 7<&0) 0<&-
bash: 0: Bad file descriptor

fd 0 is stdin, IIRC

@phadej
Copy link
Collaborator

phadej commented Aug 9, 2020

Update, it wasn't that. With cabal-install-3.2.0.0 the

cabal install --lib network 0<&-

also fails.

I.e. inheriting stdin makes cabal fail configure.

@phadej
Copy link
Collaborator

phadej commented Oct 26, 2020

Backported to 3.2 in #7134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants