Created
October 6, 2025 19:57
-
-
Save noughtmare/9f93557c046b97ecfbc858f63c6856ff to your computer and use it in GitHub Desktop.
A fake ghc script to inspect what options cabal passes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Use getopt to parse long options | |
OPTIONS=$(getopt -o '' --long numeric-version -o '' --long supported-languages -o '' --long info -o '' --long print-global-package-db -o '' --long print-libdir -- "$@" 2>/dev/null) | |
if [ $? -ne 0 ]; then | |
echo HERE: fakeghc $@ | |
exit 0 | |
fi | |
# Reorder the positional parameters according to getopt's output | |
eval set -- "$OPTIONS" | |
# Flag to track if --numeric-version was passed | |
NUMERIC_VERSION=false | |
SUPPORTED_LANGUAGES=false | |
INFO=false | |
# Process options | |
while true; do | |
case "$1" in | |
--numeric-version) | |
NUMERIC_VERSION=true | |
shift | |
;; | |
--supported-languages) | |
SUPPORTED_LANGUAGES=true | |
shift | |
;; | |
--info) | |
INFO=true | |
shift | |
;; | |
--print-global-package-db) | |
PRINT_GLOBAL_PACKAGE_DB=true | |
shift | |
;; | |
--print-libdir) | |
PRINT_LIBDIR=true | |
shift | |
;; | |
--) | |
shift | |
break | |
;; | |
*) | |
echo "Unexpected option: $1" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
languages=$(cat << EOF | |
Haskell98 | |
Haskell2010 | |
GHC2021 | |
Unsafe | |
Trustworthy | |
Safe | |
AllowAmbiguousTypes | |
NoAllowAmbiguousTypes | |
AlternativeLayoutRule | |
NoAlternativeLayoutRule | |
AlternativeLayoutRuleTransitional | |
NoAlternativeLayoutRuleTransitional | |
Arrows | |
NoArrows | |
AutoDeriveTypeable | |
NoAutoDeriveTypeable | |
BangPatterns | |
NoBangPatterns | |
BinaryLiterals | |
NoBinaryLiterals | |
CApiFFI | |
NoCApiFFI | |
CPP | |
NoCPP | |
CUSKs | |
NoCUSKs | |
ConstrainedClassMethods | |
NoConstrainedClassMethods | |
ConstraintKinds | |
NoConstraintKinds | |
DataKinds | |
NoDataKinds | |
DatatypeContexts | |
NoDatatypeContexts | |
DefaultSignatures | |
NoDefaultSignatures | |
DeriveAnyClass | |
NoDeriveAnyClass | |
DeriveDataTypeable | |
NoDeriveDataTypeable | |
DeriveFoldable | |
NoDeriveFoldable | |
DeriveFunctor | |
NoDeriveFunctor | |
DeriveGeneric | |
NoDeriveGeneric | |
DeriveLift | |
NoDeriveLift | |
DeriveTraversable | |
NoDeriveTraversable | |
DerivingStrategies | |
NoDerivingStrategies | |
DerivingVia | |
NoDerivingVia | |
DisambiguateRecordFields | |
NoDisambiguateRecordFields | |
DoAndIfThenElse | |
NoDoAndIfThenElse | |
BlockArguments | |
NoBlockArguments | |
DoRec | |
NoDoRec | |
DuplicateRecordFields | |
NoDuplicateRecordFields | |
FieldSelectors | |
NoFieldSelectors | |
EmptyCase | |
NoEmptyCase | |
EmptyDataDecls | |
NoEmptyDataDecls | |
EmptyDataDeriving | |
NoEmptyDataDeriving | |
ExistentialQuantification | |
NoExistentialQuantification | |
ExplicitForAll | |
NoExplicitForAll | |
ExplicitNamespaces | |
NoExplicitNamespaces | |
ExtendedDefaultRules | |
NoExtendedDefaultRules | |
ExtendedLiterals | |
NoExtendedLiterals | |
FlexibleContexts | |
NoFlexibleContexts | |
FlexibleInstances | |
NoFlexibleInstances | |
ForeignFunctionInterface | |
NoForeignFunctionInterface | |
FunctionalDependencies | |
NoFunctionalDependencies | |
GADTSyntax | |
NoGADTSyntax | |
GADTs | |
NoGADTs | |
GHCForeignImportPrim | |
NoGHCForeignImportPrim | |
GeneralizedNewtypeDeriving | |
NoGeneralizedNewtypeDeriving | |
GeneralisedNewtypeDeriving | |
NoGeneralisedNewtypeDeriving | |
ImplicitParams | |
NoImplicitParams | |
ImplicitPrelude | |
NoImplicitPrelude | |
ImportQualifiedPost | |
NoImportQualifiedPost | |
ImpredicativeTypes | |
NoImpredicativeTypes | |
IncoherentInstances | |
NoIncoherentInstances | |
TypeFamilyDependencies | |
NoTypeFamilyDependencies | |
InstanceSigs | |
NoInstanceSigs | |
ApplicativeDo | |
NoApplicativeDo | |
InterruptibleFFI | |
NoInterruptibleFFI | |
NoJavaScriptFFI | |
KindSignatures | |
NoKindSignatures | |
LambdaCase | |
NoLambdaCase | |
LexicalNegation | |
NoLexicalNegation | |
LiberalTypeSynonyms | |
NoLiberalTypeSynonyms | |
LinearTypes | |
NoLinearTypes | |
MagicHash | |
NoMagicHash | |
MonadComprehensions | |
NoMonadComprehensions | |
MonoLocalBinds | |
NoMonoLocalBinds | |
DeepSubsumption | |
NoDeepSubsumption | |
MonomorphismRestriction | |
NoMonomorphismRestriction | |
MultiParamTypeClasses | |
NoMultiParamTypeClasses | |
MultiWayIf | |
NoMultiWayIf | |
NumericUnderscores | |
NoNumericUnderscores | |
NPlusKPatterns | |
NoNPlusKPatterns | |
NamedFieldPuns | |
NoNamedFieldPuns | |
NamedWildCards | |
NoNamedWildCards | |
NegativeLiterals | |
NoNegativeLiterals | |
HexFloatLiterals | |
NoHexFloatLiterals | |
NondecreasingIndentation | |
NoNondecreasingIndentation | |
NullaryTypeClasses | |
NoNullaryTypeClasses | |
NumDecimals | |
NoNumDecimals | |
OverlappingInstances | |
NoOverlappingInstances | |
OverloadedLabels | |
NoOverloadedLabels | |
OverloadedLists | |
NoOverloadedLists | |
OverloadedStrings | |
NoOverloadedStrings | |
PackageImports | |
NoPackageImports | |
ParallelArrays | |
NoParallelArrays | |
ParallelListComp | |
NoParallelListComp | |
PartialTypeSignatures | |
NoPartialTypeSignatures | |
PatternGuards | |
NoPatternGuards | |
PatternSignatures | |
NoPatternSignatures | |
PatternSynonyms | |
NoPatternSynonyms | |
PolyKinds | |
NoPolyKinds | |
PolymorphicComponents | |
NoPolymorphicComponents | |
QuantifiedConstraints | |
NoQuantifiedConstraints | |
PostfixOperators | |
NoPostfixOperators | |
QuasiQuotes | |
NoQuasiQuotes | |
QualifiedDo | |
NoQualifiedDo | |
Rank2Types | |
NoRank2Types | |
RankNTypes | |
NoRankNTypes | |
RebindableSyntax | |
NoRebindableSyntax | |
OverloadedRecordDot | |
NoOverloadedRecordDot | |
OverloadedRecordUpdate | |
NoOverloadedRecordUpdate | |
RecordPuns | |
NoRecordPuns | |
RecordWildCards | |
NoRecordWildCards | |
RecursiveDo | |
NoRecursiveDo | |
RelaxedLayout | |
NoRelaxedLayout | |
RelaxedPolyRec | |
NoRelaxedPolyRec | |
RoleAnnotations | |
NoRoleAnnotations | |
ScopedTypeVariables | |
NoScopedTypeVariables | |
StandaloneDeriving | |
NoStandaloneDeriving | |
StarIsType | |
NoStarIsType | |
StaticPointers | |
NoStaticPointers | |
Strict | |
NoStrict | |
StrictData | |
NoStrictData | |
TemplateHaskell | |
NoTemplateHaskell | |
TemplateHaskellQuotes | |
NoTemplateHaskellQuotes | |
StandaloneKindSignatures | |
NoStandaloneKindSignatures | |
TraditionalRecordSyntax | |
NoTraditionalRecordSyntax | |
TransformListComp | |
NoTransformListComp | |
TupleSections | |
NoTupleSections | |
TypeAbstractions | |
NoTypeAbstractions | |
TypeApplications | |
NoTypeApplications | |
TypeData | |
NoTypeData | |
TypeInType | |
NoTypeInType | |
TypeFamilies | |
NoTypeFamilies | |
TypeOperators | |
NoTypeOperators | |
TypeSynonymInstances | |
NoTypeSynonymInstances | |
UnboxedTuples | |
NoUnboxedTuples | |
UnboxedSums | |
NoUnboxedSums | |
UndecidableInstances | |
NoUndecidableInstances | |
UndecidableSuperClasses | |
NoUndecidableSuperClasses | |
UnicodeSyntax | |
NoUnicodeSyntax | |
UnliftedDatatypes | |
NoUnliftedDatatypes | |
UnliftedFFITypes | |
NoUnliftedFFITypes | |
UnliftedNewtypes | |
NoUnliftedNewtypes | |
ViewPatterns | |
NoViewPatterns | |
EOF | |
) | |
info=$(cat << EOF | |
[("Project name","The Glorious Glasgow Haskell Compilation System") | |
,("C compiler command","/nix/store/95k9rsn1zsw1yvir8mj824ldhf90i4qw-gcc-wrapper-14.3.0/bin/cc") | |
,("C compiler flags","") | |
,("C compiler link flags","-fuse-ld=gold ") | |
,("C compiler supports -no-pie","YES") | |
,("C++ compiler command","/nix/store/95k9rsn1zsw1yvir8mj824ldhf90i4qw-gcc-wrapper-14.3.0/bin/c++") | |
,("C++ compiler flags","") | |
,("Haskell CPP command","/nix/store/95k9rsn1zsw1yvir8mj824ldhf90i4qw-gcc-wrapper-14.3.0/bin/cc") | |
,("Haskell CPP flags","-E -undef -traditional") | |
,("LLVM clang command","clang") | |
,("LLVM llc command","llc") | |
,("LLVM opt command","opt") | |
,("LLVM target","x86_64-unknown-linux") | |
,("Leading underscore","NO") | |
,("Merge objects command","/nix/store/l19cddv64i52rhcwahif8sgyrd3mhiqb-binutils-wrapper-2.44/bin/ld.gold") | |
,("Merge objects flags","-r") | |
,("RTS expects libdw","YES") | |
,("RTS ways","debug thr thr_debug thr_p dyn debug_dyn thr_dyn thr_debug_dyn thr_debug_p debug_p") | |
,("Support SMP","YES") | |
,("Tables next to code","YES") | |
,("Unregisterised","NO") | |
,("Use LibFFI","NO") | |
,("Use inplace MinGW toolchain","NO") | |
,("Use interpreter","YES") | |
,("ar command","/nix/store/l19cddv64i52rhcwahif8sgyrd3mhiqb-binutils-wrapper-2.44/bin/ar") | |
,("ar flags","q") | |
,("ar supports -L","NO") | |
,("ar supports at file","YES") | |
,("cross compiling","NO") | |
,("dllwrap command","/bin/false") | |
,("install_name_tool command","install_name_tool") | |
,("ld command","/nix/store/l19cddv64i52rhcwahif8sgyrd3mhiqb-binutils-wrapper-2.44/bin/ld.gold") | |
,("ld flags","") | |
,("ld is GNU ld","YES") | |
,("ld supports compact unwind","YES") | |
,("ld supports filelist","NO") | |
,("ld supports response files","YES") | |
,("ld supports single module","NO") | |
,("otool command","otool") | |
,("ranlib command","/nix/store/l19cddv64i52rhcwahif8sgyrd3mhiqb-binutils-wrapper-2.44/bin/ranlib") | |
,("target arch","ArchX86_64") | |
,("target has .ident directive","YES") | |
,("target has GNU nonexec stack","YES") | |
,("target has libm","YES") | |
,("target has subsections via symbols","NO") | |
,("target os","OSLinux") | |
,("target platform string","x86_64-unknown-linux") | |
,("target word big endian","NO") | |
,("target word size","8") | |
,("touch command","touch") | |
,("unlit command","/nix/store/w6awqpzhn1pmfzql7ba5ar8pvs0yq5s2-ghc-9.8.4/lib/ghc-9.8.4/lib/bin/unlit") | |
,("windres command","/bin/false") | |
,("Project version","9.8.4") | |
,("Project Git commit id","a3401159f2846605abb517e71af463df47398e72") | |
,("Project Version Int","908") | |
,("Project Patch Level","4") | |
,("Project Patch Level1","4") | |
,("Project Patch Level2","0") | |
,("Project Unit Id","ghc-9.8.4-a150") | |
,("Booter version","9.6.3") | |
,("Stage","2") | |
,("Build platform","x86_64-unknown-linux") | |
,("Host platform","x86_64-unknown-linux") | |
,("Target platform","x86_64-unknown-linux") | |
,("Have interpreter","YES") | |
,("Object splitting supported","NO") | |
,("Have native code generator","YES") | |
,("target has RTS linker","YES") | |
,("Target default backend","native code generator") | |
,("Support dynamic-too","YES") | |
,("Support parallel --make","YES") | |
,("Support reexported-modules","YES") | |
,("Support thinning and renaming package flags","YES") | |
,("Support Backpack","YES") | |
,("Requires unified installed package IDs","YES") | |
,("Uses package keys","YES") | |
,("Uses unit IDs","YES") | |
,("GHC Dynamic","YES") | |
,("GHC Profiled","NO") | |
,("Debug on","NO") | |
,("LibDir","/nix/store/w6awqpzhn1pmfzql7ba5ar8pvs0yq5s2-ghc-9.8.4/lib/ghc-9.8.4/lib") | |
,("Global Package DB","/nix/store/w6awqpzhn1pmfzql7ba5ar8pvs0yq5s2-ghc-9.8.4/lib/ghc-9.8.4/lib/package.conf.d") | |
] | |
EOF | |
) | |
if [ "$NUMERIC_VERSION" = true ]; then | |
echo "9.8.4" | |
elif [ "$SUPPORTED_LANGUAGES" = true ]; then | |
echo "$languages" | |
elif [ "$INFO" = true ]; then | |
echo "$info" | |
elif [ "$PRINT_GLOBAL_PACKAGE_DB" = true ]; then | |
echo "/nix/store/w6awqpzhn1pmfzql7ba5ar8pvs0yq5s2-ghc-9.8.4/lib/ghc-9.8.4/lib/package.conf.d" | |
elif [ "$PRINT_LIBDIR" = true ]; then | |
echo "/nix/store/w6awqpzhn1pmfzql7ba5ar8pvs0yq5s2-ghc-9.8.4/lib/ghc-9.8.4/lib" | |
else | |
echo HERE: fakeghc $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment