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

Backport to 3.2 20201025 #7134

Merged
merged 9 commits into from
Oct 25, 2020
Merged

Conversation

bgamari and others added 6 commits October 25, 2020 13:39
Many toolchain tools written for POSIX systems rely on the exec system
call. Unfortunately, it is not possible to implement `exec` in a
POSIX-compliant manner on Windows. In particular, the semantics of the
`exec` implementation provided by the widely-used `msvcrt` C runtime
will cause process's waiting on the `exec`'ing process to incorrectly
conclude that the process has successfully terminated when in fact it is
still running in another process.

For this reason, the `process` library exposes the `use_process_jobs`
flag to use a more strict (although still not POSIX-compliant) mechanism
for tracking process completion. This is explained in this comment [2].

Unfortunately, job support in the `process` library is currently quite
broken and was only recently fixed [1]. Consequently, we only enable job
object support for process releases >= 1.6.8.

[1] haskell/process#168
[2] https://github.com/haskell/process/blob/master/System/Process.hs#L399
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.
Google uses `armv7-none-linux-androideabi`, analogous to
`armv7-unknown-linux-gnueabi` for e.g. a 32-bit regular linux.

The existing alias it not a mistake, it is the right one for 64 bit.
Google for that use `aarch64-linux-android`, analogous to
`aarch64-unknown-linux-android` for a 64-bi regular linux.

See https://developer.android.com/ndk/guides/standalone_toolchain for
evidence/details.
Fixes haskell#6421

To summarize, Cabal passes all C and C++ flags through GHC to the underlying C or C++ compiler using -optc. This works for GHC < 8.10, but now GHC expects C++ flags to come through -optcxx. This means that anything through -optc is ignored, so we cannot pass any flags to the C++ compiler. This change simply detects the GHC version and uses the correct arguments.

This PR has been tested manually and two PackageTests have been added to cabal-testsuite. They pass under GHC 8.8.4 and GHC 8.10.2.
@phadej phadej added this to the 3.2.1.0 milestone Oct 25, 2020
@phadej phadej force-pushed the backport-to-3.2-20201025 branch 2 times, most recently from f4791d6 to 5353990 Compare October 25, 2020 14:50
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.

5 participants