Adding extra C compiler arguments when building with hadrian?
Matthew Pickering
matthewtpickering at gmail.com
Mon Feb 10 17:20:42 UTC 2020
You need to modify the `libraryWays` as well I think. Other flavours
build both by default.
Matt
On Mon, Feb 10, 2020 at 5:14 PM Ömer Sinan Ağacan <omeragacan at gmail.com> wrote:
>
> Thanks. I'm currently editing the existing "quickest" flavor instead of adding
> my own flavor. So far the changes are
>
> diff --git a/hadrian/src/Settings/Flavours/Quickest.hs
> b/hadrian/src/Settings/Flavours/Quickest.hs
> index c0fd72764f..b0f490d35a 100644
> --- a/hadrian/src/Settings/Flavours/Quickest.hs
> +++ b/hadrian/src/Settings/Flavours/Quickest.hs
> @@ -4,15 +4,20 @@ import Expression
> import Flavour
> import {-# SOURCE #-} Settings.Default
> import Settings.Flavours.Common
> +import Packages (rts)
>
> -- Please update doc/flavours.md when changing this file.
> quickestFlavour :: Flavour
> quickestFlavour = defaultFlavour
> { name = "quickest"
> - , args = defaultBuilderArgs <> quickestArgs <>
> defaultPackageArgs
> + , args = defaultBuilderArgs <> quickestArgs <>
> defaultPackageArgs <> dbgArgs
> , libraryWays = pure [vanilla]
> - , rtsWays = pure [vanilla, threaded]
> - , dynamicGhcPrograms = return False }
> + , rtsWays = pure [vanilla, threaded, debug, threadedDebug,
> + dynamic, threadedDynamic, debugDynamic,
> threadedDebugDynamic]
> + , dynamicGhcPrograms = return False
> + , ghcDebugged = True
> + , ghcThreaded = False
> + }
>
> quickestArgs :: Args
> quickestArgs = sourceArgs SourceArgs
> @@ -23,3 +28,6 @@ quickestArgs = sourceArgs SourceArgs
> , hsLibrary = mempty
> , hsCompiler = stage0 ? arg "-O"
> , hsGhc = stage0 ? arg "-O" }
> +
> +dbgArgs :: Args
> +dbgArgs = builder Cc ? package rts ? arg "-O0" <> arg "-g3"
>
> This fails with
>
> Error when running Shake build system:
> at action, called at src/Rules.hs:71:19 in main:Rules
> at need, called at src/Rules.hs:93:5 in main:Rules
> * Depends on: _build/stage1/bin/runghc
> at need, called at src/Rules/Register.hs:73:5 in main:Rules.Register
> * Depends on:
> _build/stage1/lib/x86_64-linux-ghc-8.11.0.20200206/libHSrts-1.0-ghc8.11.0.20200206.so
> at error, called at
> src/Development/Shake/Internal/Rules/File.hs:179:58 in
> shake-0.18.3-593067565aafb558d09b4352b8abc327d8911a39a0e9abab2804b002b1ae536e:Development.Shake.Internal.Rules.File
> * Raised the exception:
> Error, rule finished running but did not produce file:
> _build/stage1/lib/x86_64-linux-ghc-8.11.0.20200206/libHSrts-1.0-ghc8.11.0.20200206.so
>
> If I set `dynamicGhcPrograms = return False` then it works, but it makes things
> harder for me so I'd like to dynamically link the RTS.
>
> I thought the `dynamic` way should be generating the requested .so file, no idea
> why it doesn't. Is this a bug in hadrian?
>
> Ömer
>
> Daniel Gröber <dxld at darkboxed.org>, 10 Şub 2020 Pzt, 16:17 tarihinde şunu yazdı:
> >
> > Hi,
> >
> > On Mon, Feb 10, 2020 at 03:57:27PM +0300, Ömer Sinan Ağacan wrote:
> > > In make build system I can add extra C compiler arguments to any flavor using
> > > something like
> > >
> > > BuildFlavour = ...
> > >
> > > ifneq "$(BuildFlavour)" ""
> > > include mk/flavours/$(BuildFlavour).mk
> > > endif
> > >
> > > GhcRtsHcOpts += -O0 -g3
> > >
> > > How do I do the same in hadrian when defining a flavor?
> >
> > I was experimenting with building ghc with -fsanitize=address and have
> > this in hadrin/UserSettings.hs still:
> >
> > userFlavour = defaultFlavour
> > { name = "user"
> > , args = mconcat
> > [ builder Cc ? arg "-fsanitize=address"
> > , builder (Ghc CompileCWithGhc) ? arg "-optc -fsanitize=address"
> > , builder (Ghc LinkHs) ? arg "-optl -fsanitize=address"
> > ]
> > }
> >
> > I'm not sure when (builder Cc) is used vs. (Ghc CompileCWithGhc) so I
> > just add flags to both ;)
> >
> > I think you can restrict these args to just the rts package with
> > something like `package rts ? ...` on each line, also `import Package`
> > to get the `rts` binder.
> >
> > --Daniel
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
More information about the ghc-devs
mailing list