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

cabal new-build is utterly unusable for cross-compilation #4939

Closed
angerman opened this issue Dec 8, 2017 · 7 comments
Closed

cabal new-build is utterly unusable for cross-compilation #4939

angerman opened this issue Dec 8, 2017 · 7 comments

Comments

@angerman
Copy link
Collaborator

angerman commented Dec 8, 2017

With new-build we apply the --with-PROG and --PROG-option(s) only to the current project local package. As such, they are not pushed down to dependencies. To illustrate this:

- a
  - b
    - d
  - c

so we have a -> b -> d and a -> c -> d

If we try to build with new-build:

$ cabal new-build --with-hsc2hs=myhsc2hs --hsc2hs-options=--cross-compile

we compile a with myshc2hs --cross-compile, but for b, c and d we get no hsc2hs in the package database, and as such do the canonical lookup, which gives us hsc2hs. Of course we are missing --cross-compile now as well.

Let us assume without restriction c has some .hsc files. c now fails to compile, and subsequently the complete build fails. Worse, I have no option to provide those via the cabal.project file, as the program-options and program-locations stanzas are seemingly not picked up as nodes of the package stanza.


Example:

packages: .

repository hackage.mobilehaskell
  url: http://hackage.mobilehaskell.org/
  secure: True
  root-keys: 8184c1f23ce05ab836e5ebac3c3a56eecb486df503cc28110e699e24792582da
             81ff2b6c5707d9af651fdceded5702b9a6950117a1c39461f4e2c8fc07d2e36a
             8468c561cd02cc7dfe27c56de0da1a5c1a2b1b264fff21f4784f02b8c5a63edd
  key-threshold: 3

repository head.hackage
   url: http://head.hackage.haskell.org/
   secure: True
   root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740
              2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb
              8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e
   key-threshold: 3

package zlib
  program-options
    ghc-options: -fllvmng
    hsc2hs-options: --cross-compile

  program-locations
    gcc-location: armv7-linux-androideabi-clang
    ghc-location: armv7-linux-androideabi-ghc
    ghc-pkg-location: armv7-linux-androideabi-ghc-pkg
    hsc2hs-location: armv7-linux-androideabi-hsc2hs
    ld-location: armv7-linux-androideabi-ld

This ends up as

["act-as-setup","--build-type=Simple","--","configure","--verbose=3","--builddir=dist","--ghc","--prefix=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f","--bindir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/bin","--libdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/lib","--libsubdir=","--dynlibdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/lib","--libexecdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/libexec","--libexecsubdir=","--datadir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/share","--datasubdir=","--docdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/share/doc","--htmldir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/share/doc/html","--haddockdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/share/doc/html","--sysconfdir=/Users/angerman/.cabal/store/ghc-8.3.20171205/zlb-0.6.1.2-fc5fb31f/etc","--enable-library-vanilla","--disable-library-profiling","--disable-shared","--disable-static","--disable-executable-dynamic","--disable-profiling","--profiling-detail=default","--library-profiling-detail=default","--enable-optimization","--disable-debug-info","--disable-library-for-ghci","--disable-split-sections","--disable-split-objs","--disable-executable-stripping","--disable-library-stripping","--package-db=clear","--package-db=global","--package-db=/Users/angerman/.cabal/store/ghc-8.3.20171205/package.db","--flags=-non-blocking-ffi","--cid=zlb-0.6.1.2-fc5fb31f","--dependency=base=base-4.11.0.0","--dependency=bytestring=bytestring-0.10.8.2","--disable-coverage","--exact-configuration","--with-ghc=/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin/armv7-linux-androideabi-ghc","--with-ghc-pkg=/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin/armv7-linux-androideabi-ghc-pkg","--ghc-option=-hide-all-packages","--ghc-option=-fllvmng","--ghc-option=-fllvmng","lib:zlib"]

I do understand that we can't push down arbitrary flags into dependencies. If they take part in the hash, this would mean that we might end up trying to rebuild packages that ship with ghc, but are not re-installable.

While the package stanza may work if you want to selectively set some value for a specific package, even if program-locations and program-options worked inside of package stanzas, I would end up needing to add them for each and every dependency. Should any dependency in the project change, I would need to update the project.cabal file again, and it would just keep on growing with lots of repetition. I don't see this as a solution that would provide a user experience I would appreciate.

The other option I see is to push --with-PROG and --PROG-options down into the dependencies, and if we hit packages that are shipped with GHC, we just accept them and do not try to rebuild them. If the user tried to mess too hard with his install here, it his own fault things break.

We could extract the CC and LD values from GHC info.

cabal clearly knows them from the ElaboratedSharedConfig

ElaboratedSharedConfig {pkgConfigPlatform = Platform Arm (OtherOS "linux-android"), pkgConfigCompiler = Compiler {compilerId = CompilerId GHC (mkVersion [8,3,20171205]), compilerAbiTag = NoAbiTag, compilerCompat = [], compilerLanguages = [(Haskell98,"-XHaskell98"),(Haskell2010,"-XHaskell2010")], compilerExtensions = [(UnknownExtension "Haskell98","-XHaskell98"),(UnknownExtension "Haskell2010","-XHaskell2010"),(EnableExtension Unsafe,"-XUnsafe"),(EnableExtension Trustworthy,"-XTrustworthy"),(EnableExtension Safe,"-XSafe"),(EnableExtension AllowAmbiguousTypes,"-XAllowAmbiguousTypes"),(DisableExtension AllowAmbiguousTypes,"-XNoAllowAmbiguousTypes"),(UnknownExtension "AlternativeLayoutRule","-XAlternativeLayoutRule"),(UnknownExtension "NoAlternativeLayoutRule","-XNoAlternativeLayoutRule"),(UnknownExtension "AlternativeLayoutRuleTransitional","-XAlternativeLayoutRuleTransitional"),(UnknownExtension "NoAlternativeLayoutRuleTransitional","-XNoAlternativeLayoutRuleTransitional"),(EnableExtension Arrows,"-XArrows"),(DisableExtension Arrows,"-XNoArrows"),(EnableExtension AutoDeriveTypeable,"-XAutoDeriveTypeable"),(DisableExtension AutoDeriveTypeable,"-XNoAutoDeriveTypeable"),(EnableExtension BangPatterns,"-XBangPatterns"),(DisableExtension BangPatterns,"-XNoBangPatterns"),(EnableExtension BinaryLiterals,"-XBinaryLiterals"),(DisableExtension BinaryLiterals,"-XNoBinaryLiterals"),(EnableExtension CApiFFI,"-XCApiFFI"),(DisableExtension CApiFFI,"-XNoCApiFFI"),(EnableExtension CPP,"-XCPP"),(DisableExtension CPP,"-XNoCPP"),(EnableExtension ConstrainedClassMethods,"-XConstrainedClassMethods"),(DisableExtension ConstrainedClassMethods,"-XNoConstrainedClassMethods"),(EnableExtension ConstraintKinds,"-XConstraintKinds"),(DisableExtension ConstraintKinds,"-XNoConstraintKinds"),(EnableExtension DataKinds,"-XDataKinds"),(DisableExtension DataKinds,"-XNoDataKinds"),(EnableExtension DatatypeContexts,"-XDatatypeContexts"),(DisableExtension DatatypeContexts,"-XNoDatatypeContexts"),(EnableExtension DefaultSignatures,"-XDefaultSignatures"),(DisableExtension DefaultSignatures,"-XNoDefaultSignatures"),(EnableExtension DeriveAnyClass,"-XDeriveAnyClass"),(DisableExtension DeriveAnyClass,"-XNoDeriveAnyClass"),(EnableExtension DeriveDataTypeable,"-XDeriveDataTypeable"),(DisableExtension DeriveDataTypeable,"-XNoDeriveDataTypeable"),(EnableExtension DeriveFoldable,"-XDeriveFoldable"),(DisableExtension DeriveFoldable,"-XNoDeriveFoldable"),(EnableExtension DeriveFunctor,"-XDeriveFunctor"),(DisableExtension DeriveFunctor,"-XNoDeriveFunctor"),(EnableExtension DeriveGeneric,"-XDeriveGeneric"),(DisableExtension DeriveGeneric,"-XNoDeriveGeneric"),(EnableExtension DeriveLift,"-XDeriveLift"),(DisableExtension DeriveLift,"-XNoDeriveLift"),(EnableExtension DeriveTraversable,"-XDeriveTraversable"),(DisableExtension DeriveTraversable,"-XNoDeriveTraversable"),(EnableExtension DerivingStrategies,"-XDerivingStrategies"),(DisableExtension DerivingStrategies,"-XNoDerivingStrategies"),(EnableExtension DisambiguateRecordFields,"-XDisambiguateRecordFields"),(DisableExtension DisambiguateRecordFields,"-XNoDisambiguateRecordFields"),(EnableExtension DoAndIfThenElse,"-XDoAndIfThenElse"),(DisableExtension DoAndIfThenElse,"-XNoDoAndIfThenElse"),(EnableExtension DoRec,"-XDoRec"),(DisableExtension DoRec,"-XNoDoRec"),(EnableExtension DuplicateRecordFields,"-XDuplicateRecordFields"),(DisableExtension DuplicateRecordFields,"-XNoDuplicateRecordFields"),(EnableExtension EmptyCase,"-XEmptyCase"),(DisableExtension EmptyCase,"-XNoEmptyCase"),(EnableExtension EmptyDataDecls,"-XEmptyDataDecls"),(DisableExtension EmptyDataDecls,"-XNoEmptyDataDecls"),(UnknownExtension "EmptyDataDeriving","-XEmptyDataDeriving"),(UnknownExtension "NoEmptyDataDeriving","-XNoEmptyDataDeriving"),(EnableExtension ExistentialQuantification,"-XExistentialQuantification"),(DisableExtension ExistentialQuantification,"-XNoExistentialQuantification"),(EnableExtension ExplicitForAll,"-XExplicitForAll"),(DisableExtension ExplicitForAll,"-XNoExplicitForAll"),(EnableExtension ExplicitNamespaces,"-XExplicitNamespaces"),(DisableExtension ExplicitNamespaces,"-XNoExplicitNamespaces"),(EnableExtension ExtendedDefaultRules,"-XExtendedDefaultRules"),(DisableExtension ExtendedDefaultRules,"-XNoExtendedDefaultRules"),(EnableExtension FlexibleContexts,"-XFlexibleContexts"),(DisableExtension FlexibleContexts,"-XNoFlexibleContexts"),(EnableExtension FlexibleInstances,"-XFlexibleInstances"),(DisableExtension FlexibleInstances,"-XNoFlexibleInstances"),(EnableExtension ForeignFunctionInterface,"-XForeignFunctionInterface"),(DisableExtension ForeignFunctionInterface,"-XNoForeignFunctionInterface"),(EnableExtension FunctionalDependencies,"-XFunctionalDependencies"),(DisableExtension FunctionalDependencies,"-XNoFunctionalDependencies"),(EnableExtension GADTSyntax,"-XGADTSyntax"),(DisableExtension GADTSyntax,"-XNoGADTSyntax"),(EnableExtension GADTs,"-XGADTs"),(DisableExtension GADTs,"-XNoGADTs"),(EnableExtension GHCForeignImportPrim,"-XGHCForeignImportPrim"),(DisableExtension GHCForeignImportPrim,"-XNoGHCForeignImportPrim"),(EnableExtension GeneralizedNewtypeDeriving,"-XGeneralizedNewtypeDeriving"),(DisableExtension GeneralizedNewtypeDeriving,"-XNoGeneralizedNewtypeDeriving"),(EnableExtension ImplicitParams,"-XImplicitParams"),(DisableExtension ImplicitParams,"-XNoImplicitParams"),(EnableExtension ImplicitPrelude,"-XImplicitPrelude"),(DisableExtension ImplicitPrelude,"-XNoImplicitPrelude"),(EnableExtension ImpredicativeTypes,"-XImpredicativeTypes"),(DisableExtension ImpredicativeTypes,"-XNoImpredicativeTypes"),(EnableExtension IncoherentInstances,"-XIncoherentInstances"),(DisableExtension IncoherentInstances,"-XNoIncoherentInstances"),(EnableExtension TypeFamilyDependencies,"-XTypeFamilyDependencies"),(DisableExtension TypeFamilyDependencies,"-XNoTypeFamilyDependencies"),(EnableExtension InstanceSigs,"-XInstanceSigs"),(DisableExtension InstanceSigs,"-XNoInstanceSigs"),(EnableExtension ApplicativeDo,"-XApplicativeDo"),(DisableExtension ApplicativeDo,"-XNoApplicativeDo"),(EnableExtension InterruptibleFFI,"-XInterruptibleFFI"),(DisableExtension InterruptibleFFI,"-XNoInterruptibleFFI"),(DisableExtension JavaScriptFFI,"-XNoJavaScriptFFI"),(EnableExtension KindSignatures,"-XKindSignatures"),(DisableExtension KindSignatures,"-XNoKindSignatures"),(EnableExtension LambdaCase,"-XLambdaCase"),(DisableExtension LambdaCase,"-XNoLambdaCase"),(EnableExtension LiberalTypeSynonyms,"-XLiberalTypeSynonyms"),(DisableExtension LiberalTypeSynonyms,"-XNoLiberalTypeSynonyms"),(EnableExtension MagicHash,"-XMagicHash"),(DisableExtension MagicHash,"-XNoMagicHash"),(EnableExtension MonadComprehensions,"-XMonadComprehensions"),(DisableExtension MonadComprehensions,"-XNoMonadComprehensions"),(EnableExtension MonadFailDesugaring,"-XMonadFailDesugaring"),(DisableExtension MonadFailDesugaring,"-XNoMonadFailDesugaring"),(EnableExtension MonoLocalBinds,"-XMonoLocalBinds"),(DisableExtension MonoLocalBinds,"-XNoMonoLocalBinds"),(EnableExtension MonoPatBinds,"-XMonoPatBinds"),(DisableExtension MonoPatBinds,"-XNoMonoPatBinds"),(EnableExtension MonomorphismRestriction,"-XMonomorphismRestriction"),(DisableExtension MonomorphismRestriction,"-XNoMonomorphismRestriction"),(EnableExtension MultiParamTypeClasses,"-XMultiParamTypeClasses"),(DisableExtension MultiParamTypeClasses,"-XNoMultiParamTypeClasses"),(EnableExtension MultiWayIf,"-XMultiWayIf"),(DisableExtension MultiWayIf,"-XNoMultiWayIf"),(EnableExtension NPlusKPatterns,"-XNPlusKPatterns"),(DisableExtension NPlusKPatterns,"-XNoNPlusKPatterns"),(EnableExtension NamedFieldPuns,"-XNamedFieldPuns"),(DisableExtension NamedFieldPuns,"-XNoNamedFieldPuns"),(EnableExtension NamedWildCards,"-XNamedWildCards"),(DisableExtension NamedWildCards,"-XNoNamedWildCards"),(EnableExtension NegativeLiterals,"-XNegativeLiterals"),(DisableExtension NegativeLiterals,"-XNoNegativeLiterals"),(EnableExtension HexFloatLiterals,"-XHexFloatLiterals"),(DisableExtension HexFloatLiterals,"-XNoHexFloatLiterals"),(EnableExtension NondecreasingIndentation,"-XNondecreasingIndentation"),(DisableExtension NondecreasingIndentation,"-XNoNondecreasingIndentation"),(EnableExtension NullaryTypeClasses,"-XNullaryTypeClasses"),(DisableExtension NullaryTypeClasses,"-XNoNullaryTypeClasses"),(EnableExtension NumDecimals,"-XNumDecimals"),(DisableExtension NumDecimals,"-XNoNumDecimals"),(EnableExtension OverlappingInstances,"-XOverlappingInstances"),(DisableExtension OverlappingInstances,"-XNoOverlappingInstances"),(EnableExtension OverloadedLabels,"-XOverloadedLabels"),(DisableExtension OverloadedLabels,"-XNoOverloadedLabels"),(EnableExtension OverloadedLists,"-XOverloadedLists"),(DisableExtension OverloadedLists,"-XNoOverloadedLists"),(EnableExtension OverloadedStrings,"-XOverloadedStrings"),(DisableExtension OverloadedStrings,"-XNoOverloadedStrings"),(EnableExtension PackageImports,"-XPackageImports"),(DisableExtension PackageImports,"-XNoPackageImports"),(EnableExtension ParallelArrays,"-XParallelArrays"),(DisableExtension ParallelArrays,"-XNoParallelArrays"),(EnableExtension ParallelListComp,"-XParallelListComp"),(DisableExtension ParallelListComp,"-XNoParallelListComp"),(EnableExtension PartialTypeSignatures,"-XPartialTypeSignatures"),(DisableExtension PartialTypeSignatures,"-XNoPartialTypeSignatures"),(EnableExtension PatternGuards,"-XPatternGuards"),(DisableExtension PatternGuards,"-XNoPatternGuards"),(EnableExtension PatternSignatures,"-XPatternSignatures"),(DisableExtension PatternSignatures,"-XNoPatternSignatures"),(EnableExtension PatternSynonyms,"-XPatternSynonyms"),(DisableExtension PatternSynonyms,"-XNoPatternSynonyms"),(EnableExtension PolyKinds,"-XPolyKinds"),(DisableExtension PolyKinds,"-XNoPolyKinds"),(EnableExtension PolymorphicComponents,"-XPolymorphicComponents"),(DisableExtension PolymorphicComponents,"-XNoPolymorphicComponents"),(EnableExtension PostfixOperators,"-XPostfixOperators"),(DisableExtension PostfixOperators,"-XNoPostfixOperators"),(EnableExtension QuasiQuotes,"-XQuasiQuotes"),(DisableExtension QuasiQuotes,"-XNoQuasiQuotes"),(EnableExtension Rank2Types,"-XRank2Types"),(DisableExtension Rank2Types,"-XNoRank2Types"),(EnableExtension RankNTypes,"-XRankNTypes"),(DisableExtension RankNTypes,"-XNoRankNTypes"),(EnableExtension RebindableSyntax,"-XRebindableSyntax"),(DisableExtension RebindableSyntax,"-XNoRebindableSyntax"),(EnableExtension RecordPuns,"-XRecordPuns"),(DisableExtension RecordPuns,"-XNoRecordPuns"),(EnableExtension RecordWildCards,"-XRecordWildCards"),(DisableExtension RecordWildCards,"-XNoRecordWildCards"),(EnableExtension RecursiveDo,"-XRecursiveDo"),(DisableExtension RecursiveDo,"-XNoRecursiveDo"),(UnknownExtension "RelaxedLayout","-XRelaxedLayout"),(UnknownExtension "NoRelaxedLayout","-XNoRelaxedLayout"),(EnableExtension RelaxedPolyRec,"-XRelaxedPolyRec"),(DisableExtension RelaxedPolyRec,"-XNoRelaxedPolyRec"),(EnableExtension RoleAnnotations,"-XRoleAnnotations"),(DisableExtension RoleAnnotations,"-XNoRoleAnnotations"),(EnableExtension ScopedTypeVariables,"-XScopedTypeVariables"),(DisableExtension ScopedTypeVariables,"-XNoScopedTypeVariables"),(EnableExtension StandaloneDeriving,"-XStandaloneDeriving"),(DisableExtension StandaloneDeriving,"-XNoStandaloneDeriving"),(EnableExtension StaticPointers,"-XStaticPointers"),(DisableExtension StaticPointers,"-XNoStaticPointers"),(EnableExtension Strict,"-XStrict"),(DisableExtension Strict,"-XNoStrict"),(EnableExtension StrictData,"-XStrictData"),(DisableExtension StrictData,"-XNoStrictData"),(EnableExtension TemplateHaskell,"-XTemplateHaskell"),(DisableExtension TemplateHaskell,"-XNoTemplateHaskell"),(EnableExtension TemplateHaskellQuotes,"-XTemplateHaskellQuotes"),(DisableExtension TemplateHaskellQuotes,"-XNoTemplateHaskellQuotes"),(EnableExtension TraditionalRecordSyntax,"-XTraditionalRecordSyntax"),(DisableExtension TraditionalRecordSyntax,"-XNoTraditionalRecordSyntax"),(EnableExtension TransformListComp,"-XTransformListComp"),(DisableExtension TransformListComp,"-XNoTransformListComp"),(EnableExtension TupleSections,"-XTupleSections"),(DisableExtension TupleSections,"-XNoTupleSections"),(EnableExtension TypeApplications,"-XTypeApplications"),(DisableExtension TypeApplications,"-XNoTypeApplications"),(EnableExtension TypeInType,"-XTypeInType"),(DisableExtension TypeInType,"-XNoTypeInType"),(EnableExtension TypeFamilies,"-XTypeFamilies"),(DisableExtension TypeFamilies,"-XNoTypeFamilies"),(EnableExtension TypeOperators,"-XTypeOperators"),(DisableExtension TypeOperators,"-XNoTypeOperators"),(EnableExtension TypeSynonymInstances,"-XTypeSynonymInstances"),(DisableExtension TypeSynonymInstances,"-XNoTypeSynonymInstances"),(EnableExtension UnboxedTuples,"-XUnboxedTuples"),(DisableExtension UnboxedTuples,"-XNoUnboxedTuples"),(EnableExtension UnboxedSums,"-XUnboxedSums"),(DisableExtension UnboxedSums,"-XNoUnboxedSums"),(EnableExtension UndecidableInstances,"-XUndecidableInstances"),(DisableExtension UndecidableInstances,"-XNoUndecidableInstances"),(EnableExtension UndecidableSuperClasses,"-XUndecidableSuperClasses"),(DisableExtension UndecidableSuperClasses,"-XNoUndecidableSuperClasses"),(EnableExtension UnicodeSyntax,"-XUnicodeSyntax"),(DisableExtension UnicodeSyntax,"-XNoUnicodeSyntax"),(EnableExtension UnliftedFFITypes,"-XUnliftedFFITypes"),(DisableExtension UnliftedFFITypes,"-XNoUnliftedFFITypes"),(EnableExtension ViewPatterns,"-XViewPatterns"),(DisableExtension ViewPatterns,"-XNoViewPatterns")], compilerProperties = fromList [("Booter version","8.3.20171205"),("Build platform","x86_64-apple-darwin"),("C compiler command","armv7-linux-androideabi-clang"),("C compiler flags"," -marm -fno-stack-protector"),("C compiler link flags","  -Wl,-z,noexecstack"),("C compiler supports -no-pie","NO"),("Debug on","False"),("Dynamic by default","NO"),("GCC extra via C opts"," -fwrapv -fno-builtin"),("GHC Dynamic","NO"),("GHC Profiled","NO"),("Global Package DB","/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/package.conf.d"),("Haskell CPP command","armv7-linux-androideabi-clang"),("Haskell CPP flags","-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"),("Have interpreter","NO"),("Have native code generator","NO"),("Host platform","x86_64-apple-darwin"),("LLVM clang command","armv7-linux-androideabi-clang"),("LLVM llc command","llc"),("LLVM opt command","opt"),("Leading underscore","NO"),("LibDir","/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib"),("Object splitting supported","NO"),("Project Git commit id","e26511a7d213d70fd9a4dc367dd776d5622f6c90"),("Project name","The Glorious Glasgow Haskell Compilation System"),("Project version","8.3.20171205"),("RTS expects libdw","NO"),("RTS ways","l debug thr thr_debug thr_l"),("Requires unified installed package IDs","YES"),("Stage","1"),("Support Backpack","YES"),("Support SMP","YES"),("Support dynamic-too","YES"),("Support parallel --make","YES"),("Support reexported-modules","YES"),("Support thinning and renaming package flags","YES"),("Tables next to code","YES"),("Target platform","arm-unknown-linux-android"),("Unregisterised","NO"),("Uses package keys","YES"),("Uses unit IDs","YES"),("ar command","armv7-linux-androideabi-ar"),("ar flags","q"),("ar supports at file","YES"),("cross compiling","YES"),("dllwrap command","/bin/false"),("ld command","armv7-linux-androideabi-ld"),("ld flags"," -z noexecstack"),("ld is GNU ld","YES"),("ld supports build-id","YES"),("ld supports compact unwind","YES"),("ld supports filelist","NO"),("libtool command","armv7-linux-androideabi-libtool"),("perl command","/usr/bin/perl"),("ranlib command","armv7-linux-androideabi-ranlib"),("target arch","ArchARM {armISA = ARMv7, armISAExt = [VFPv3,NEON], armABI = SOFTFP}"),("target has .ident directive","True"),("target has GNU nonexec stack","True"),("target has RTS linker","YES"),("target has subsections via symbols","False"),("target os","OSLinux"),("target word size","4"),("touch command","touch"),("windres command","/bin/false")]}, pkgConfigCompilerProgs = [("ghc",ConfiguredProgram {programId = "ghc", programVersion = Just (mkVersion [8,3,20171205]), programDefaultArgs = [], programOverrideArgs = ["-fllvmng","-fllvmng"], programOverrideEnv = [("PATH",Just "/usr/local/opt/llvm/bin:/Users/angerman/Projects/zw3rk/cabal/dist-newstyle/build/x86_64-osx/ghc-8.2.1/cabal-install-2.1.0.0/build/cabal:/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin:/Users/angerman/Projects/zw3rk/ghc/_aarch64-android/stage1/bin:/Users/angerman/Projects/zw3rk/toolchain-wrapper:/Users/angerman/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/Users/angerman/Projects/stoeger-it/phab/arcanist/bin:/Users/angerman/.cabal/bin")], programProperties = fromList [], programLocation = UserSpecified {locationPath = "/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin/armv7-linux-androideabi-ghc"}, programMonitorFiles = ["/usr/local/opt/llvm/bin/armv7-linux-androideabi-ghc","/Users/angerman/Projects/zw3rk/cabal/dist-newstyle/build/x86_64-osx/ghc-8.2.1/cabal-install-2.1.0.0/build/cabal/armv7-linux-androideabi-ghc"]}),("ghc-pkg",ConfiguredProgram {programId = "ghc-pkg", programVersion = Just (mkVersion [8,3,20171205]), programDefaultArgs = [], programOverrideArgs = [], programOverrideEnv = [("PATH",Just "/usr/local/opt/llvm/bin:/Users/angerman/Projects/zw3rk/cabal/dist-newstyle/build/x86_64-osx/ghc-8.2.1/cabal-install-2.1.0.0/build/cabal:/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin:/Users/angerman/Projects/zw3rk/ghc/_aarch64-android/stage1/bin:/Users/angerman/Projects/zw3rk/toolchain-wrapper:/Users/angerman/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/Users/angerman/Projects/stoeger-it/phab/arcanist/bin:/Users/angerman/.cabal/bin")], programProperties = fromList [], programLocation = UserSpecified {locationPath = "/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/bin/armv7-linux-androideabi-ghc-pkg"}, programMonitorFiles = ["/usr/local/opt/llvm/bin/armv7-linux-androideabi-ghc-pkg","/Users/angerman/Projects/zw3rk/cabal/dist-newstyle/build/x86_64-osx/ghc-8.2.1/cabal-install-2.1.0.0/build/cabal/armv7-linux-androideabi-ghc-pkg"]})]}

hsc2hs is going to be a bit more tricky, as it's not listed in GHC's commands. We could of course add it, but after all hsc2hs, as alex and happy are build tools that should not be coupled too tightly with GHC as far as I understood @hvr. And where does would this end? Adding each and every tool that ghc used during it's own build (and the respective flags) to GHC's info output?

Related issues: #2997, #4925, #4844, #4829

@angerman
Copy link
Collaborator Author

angerman commented Dec 8, 2017

Just to note the current possible work-around. Because flags are applied to all project local sources, you can work around this, by asking cabal to pull and unpack the package and then add it to the project.cabal file.

@angerman
Copy link
Collaborator Author

angerman commented Dec 8, 2017

Just going to leave this here, because I know I'd likely forget where it was. In ProjectPlanning.hs we have:

    -- Configuring other programs.
    --
    -- Having configred the compiler, now we configure all the remaining
    -- programs. This is to check we can find them, and to monitor them for
    -- changes.
    --
    -- TODO: [required eventually] we don't actually do this yet.
    --
    -- We rely on the fact that the previous phase added the program config for
    -- all local packages, but that all the programs configured so far are the
    -- compiler program or related util programs.
    --
    phaseConfigurePrograms :: ProjectConfig
                           -> (Compiler, Platform, ProgramDb)
                           -> Rebuild ()
    phaseConfigurePrograms projectConfig (_, _, compilerprogdb) = do
        -- Users are allowed to specify program locations independently for
        -- each package (e.g. to use a particular version of a pre-processor
        -- for some packages). However they cannot do this for the compiler
        -- itself as that's just not going to work. So we check for this.
        liftIO $ checkBadPerPackageCompilerPaths
          (configuredPrograms compilerprogdb)
          (getMapMappend (projectConfigSpecificPackage projectConfig))

        --TODO: [required eventually] find/configure other programs that the
        -- user specifies.

        --TODO: [required eventually] find/configure all build-tools
        -- but note that some of them may be built as part of the plan.

This is called in rebuildInstallPlan

          compilerEtc   <- phaseConfigureCompiler projectConfig
          _             <- phaseConfigurePrograms projectConfig compilerEtc

and this is where I believe we loose the information about --with-PROG and --PROG-option(s).


I believe someone with a deeper knowledge of the plan elaboration, could probably point how to solve this properly.

@ezyang
Copy link
Contributor

ezyang commented Dec 30, 2017

#4972 should help with this.

@angerman
Copy link
Collaborator Author

angerman commented Jan 9, 2018

@ezyang I should give this a try. Will report back.

@angerman
Copy link
Collaborator Author

Alright, so I can put the following into my project.cabal

program-options
  ghc-options: -fllvmng -fast-llvm -fPIC
  hsc2hs-options: --cross-compile

program-locations
  gcc-location: armv7-linux-androideabi-clang
  ghc-location: armv7-linux-androideabi-ghc
  ghc-pkg-location: armv7-linux-androideabi-ghc-pkg
  hsc2hs-location: armv7-linux-androideabi-hsc2hs
  ld-location: armv7-linux-androideabi-ld

all-packages
  configure-options: "--host=armv7-linux-androideabi"
  ghc-options: -fllvmng -fast-llvm -fPIC
  hsc2hs-options: --cross-compile

While this does help a little, as it passes --cross-compile down, it still doesn't respect the program locations I gave:

/usr/local/bin/hsc2hs '--cc=/Users/angerman/Projects/zw3rk/toolchain-wrapper/armv7-linux-androideabi-clang' '--ld=/Users/angerman/Projects/zw3rk/toolchain-wrapper/armv7-linux-androideabi-clang' '--
cflag=-marm' '--cflag=-fno-stack-protector' '--cflag=-Wl,-z,noexecstack' '--lflag=-marm' '--lflag=-fno-stack-protector' '--lflag=-Wl,-z,noexecstack' '--cflag=-D__GLASGOW_HASKELL__=804' '--cflag=-Dd
arwin_BUILD_OS=1' '--cflag=-Dx86_64_BUILD_ARCH=1' '--cflag=-Darm_HOST_ARCH=1' '--cflag=-Idist/build/autogen' '--cflag=-Idist/build/global-autogen' '--cflag=-include' '--cflag=dist/build/autogen/cab
al_macros.h' '--lflag=-lz' '--cflag=-I/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/bytestring-0.10.8.2/include' '--cflag=-I/Users/angerma
n/Projects/zw3rk/prebuilt/libiconv/arm-linux-androideabi/include' '--cflag=-I/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/base-4.11.0.0/i
nclude' '--cflag=-I/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/rts-1.0/include' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_armv7-and
roid/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/bytestring-0.10.8.2' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/
deepseq-1.4.3.0' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/array-0.5.2.0' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_ar
mv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/base-4.11.0.0' '--lflag=-L/Users/angerman/Projects/zw3rk/prebuilt/libiconv/arm-linux-androideabi/lib' '--lflag=-liconv' '--lflag=-
L/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/integer-simple-0.1.1.1' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1
/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/ghc-prim-0.5.2.0' '--lflag=-L/Users/angerman/Projects/zw3rk/ghc/_armv7-android/stage1/lib/../lib/arm-linux-android-ghc-8.4.0.20180109/rts-1.0' '--lf
lag=-lm' '--lflag=-ldl' -o dist/build/Codec/Compression/Zlib/Stream.hs Codec/Compression/Zlib/Stream.hsc --cross-compile

I'm fairly sure we want to push the program locations and program options unconditional into the dependencies as well if they are provided via the program-locations and program-options.

@angerman
Copy link
Collaborator Author

Another issue now is clearly, that I have a configure-options value for all-packages, and that value is tied to a very specific host; I'd rather be able to provide that as a command line option, instead of rewriting the cabal.project file for each change to the compiler.

Ideally though this would just be --host, and cabal would use that to find tools with that prefix, and add --host=$host to configure on it's own. Maybe just codify that in the cabal.project.local file?

angerman added a commit to zw3rk/cabal that referenced this issue Jan 12, 2018
This should help with haskell#4939. `--with-PROG` flags should be applied to every
package.  If we change hsc2hs via `--with-hsc2hs=` or any other program and
similarly `--hsc2hs-options` should also be provided to that program.  Same
holds for `--PROG-options`.  Because we do no inherit the properties from
AllPackages for LocalPackages, we need to have the set of programs and options
in both.
angerman added a commit to zw3rk/cabal that referenced this issue Jan 19, 2018
This should help with haskell#4939. `--with-PROG` flags should be applied to every
package.  If we change hsc2hs via `--with-hsc2hs=` or any other program and
similarly `--hsc2hs-options` should also be provided to that program.  Same
holds for `--PROG-options`.  Because we do no inherit the properties from
AllPackages for LocalPackages, we need to have the set of programs and options
in both.
@angerman
Copy link
Collaborator Author

This was fixed with #5018

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

No branches or pull requests

2 participants