From fc2ff6dd7496a33bf68165b28f37f40b7d647418 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 3 Oct 2018 15:36:55 +0200 Subject: Make GHC (the library) flexible in the choice of integer library Summary: We have more and more users of GHC as a library, for example the Haskell-to-WebAssembly-compiler https://github.com/tweag/asterius. These need to make different decisions about various aspects of code generation than the host compiler, and ideally GHC-the-library allows them to set the `DynFlags` as needed. This patch adds a new `DynFlag` that configures which `integer` library to use. This flag is initialized by `cIntegerLibraryType` (as before), and is only used in `CorePrep` to decide whether to use `S#` or not. The other code paths that were varying based on `cIntegerLibraryType` are no now longer varying: The trick is to use `integer-wired-in` as the `-this-unit-id` when compiling either `integer-gmp` or `integer-simple`. Test Plan: Validate is happy. Reviewers: hvr, bgamari Reviewed By: bgamari Subscribers: TerrorJack, adamse, simonpj, rwbarton, carter GHC Trac Issues: #13477 Differential Revision: https://phabricator.haskell.org/D5079 --- libraries/integer-gmp/integer-gmp.cabal | 5 ++++- libraries/integer-simple/integer-simple.cabal | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'libraries') diff --git a/libraries/integer-gmp/integer-gmp.cabal b/libraries/integer-gmp/integer-gmp.cabal index 5d2f89039c..52834bb4ea 100644 --- a/libraries/integer-gmp/integer-gmp.cabal +++ b/libraries/integer-gmp/integer-gmp.cabal @@ -60,7 +60,10 @@ library UnliftedFFITypes build-depends: ghc-prim ^>= 0.5.1.0 hs-source-dirs: src/ - ghc-options: -this-unit-id integer-gmp -Wall + -- We need to set the unit ID to integer-wired-in + -- (without a version number) as it's magic. + -- See Note [The integer library] in PrelNames + ghc-options: -this-unit-id integer-wired-in -Wall cc-options: -std=c99 -Wall include-dirs: include diff --git a/libraries/integer-simple/integer-simple.cabal b/libraries/integer-simple/integer-simple.cabal index 231619c6c7..96c2e2358e 100644 --- a/libraries/integer-simple/integer-simple.cabal +++ b/libraries/integer-simple/integer-simple.cabal @@ -26,6 +26,7 @@ Library other-modules: GHC.Integer.Type default-extensions: CPP, MagicHash, BangPatterns, UnboxedTuples, UnliftedFFITypes, NoImplicitPrelude - -- We need to set the unit ID to integer-simple + -- We need to set the unit ID to integer-wired-in -- (without a version number) as it's magic. - ghc-options: -this-unit-id integer-simple -Wall + -- See Note [The integer library] in PrelNames + ghc-options: -this-unit-id integer-wired-in -Wall -- cgit v1.2.1