<commit_before>module Settings.Packages.Rts (
    rtsPackageArgs, rtsConfIn, rtsConf, rtsLibffiLibraryName
    ) where

import Base
import Expression
import GHC (rts)
import Oracles.Config.Flag
import Oracles.Config.Setting
import Predicates (builder, builderGcc, builderGhc, package, file)
import Settings
import Settings.Builders.Common

rtsConfIn :: FilePath
rtsConfIn = pkgPath rts -/- "package.conf.in"

rtsConf :: FilePath
rtsConf = targetPath Stage1 rts -/- "package.conf.inplace"

rtsLibffiLibraryName :: Action FilePath
rtsLibffiLibraryName = do
    windows <- windowsHost
    return $ if windows then "Cffi-6" else "Cffi"

rtsPackageArgs :: Args
rtsPackageArgs = package rts ? do
    let yesNo = lift . fmap (\x -> if x then "YES" else "NO")
    projectVersion <- getSetting ProjectVersion
    hostPlatform   <- getSetting HostPlatform
    hostArch       <- getSetting HostArch
    hostOs         <- getSetting HostOs
    hostVendor     <- getSetting HostVendor
    buildPlatform  <- getSetting BuildPlatform
    buildArch      <- getSetting BuildArch
    buildOs        <- getSetting BuildOs
    buildVendor    <- getSetting BuildVendor
    targetPlatform <- getSetting TargetPlatform
    targetArch     <- getSetting TargetArch
    targetOs       <- getSetting TargetOs
    targetVendor   <- getSetting TargetVendor
    ghcUnreg       <- yesNo $ flag GhcUnregisterised
    ghcEnableTNC   <- yesNo ghcEnableTablesNextToCode
    way            <- getWay
    path           <- getTargetPath
    top            <- getTopDirectory
    libffiName     <- lift $ rtsLibffiLibraryName
    mconcat
        [ builderGcc ? mconcat
          [ arg "-Irts"
          , arg $ "-I" ++ path -/- "build"
          , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\""

          , (file "//RtsMessages.*" ||^ file "//Trace.*") ?
            arg ("-DProjectVersion=" ++ quote projectVersion)<commit_msg>Compile rts with -O2<commit_after>module Settings.Packages.Rts (
    rtsPackageArgs, rtsConfIn, rtsConf, rtsLibffiLibraryName
    ) where

import Base
import Expression
import GHC (rts)
import Oracles.Config.Flag
import Oracles.Config.Setting
import Predicates (builder, builderGcc, builderGhc, package, file)
import Settings
import Settings.Builders.Common

rtsConfIn :: FilePath
rtsConfIn = pkgPath rts -/- "package.conf.in"

rtsConf :: FilePath
rtsConf = targetPath Stage1 rts -/- "package.conf.inplace"

rtsLibffiLibraryName :: Action FilePath
rtsLibffiLibraryName = do
    windows <- windowsHost
    return $ if windows then "Cffi-6" else "Cffi"

rtsPackageArgs :: Args
rtsPackageArgs = package rts ? do
    let yesNo = lift . fmap (\x -> if x then "YES" else "NO")
    projectVersion <- getSetting ProjectVersion
    hostPlatform   <- getSetting HostPlatform
    hostArch       <- getSetting HostArch
    hostOs         <- getSetting HostOs
    hostVendor     <- getSetting HostVendor
    buildPlatform  <- getSetting BuildPlatform
    buildArch      <- getSetting BuildArch
    buildOs        <- getSetting BuildOs
    buildVendor    <- getSetting BuildVendor
    targetPlatform <- getSetting TargetPlatform
    targetArch     <- getSetting TargetArch
    targetOs       <- getSetting TargetOs
    targetVendor   <- getSetting TargetVendor
    ghcUnreg       <- yesNo $ flag GhcUnregisterised
    ghcEnableTNC   <- yesNo ghcEnableTablesNextToCode
    way            <- getWay
    path           <- getTargetPath
    top            <- getTopDirectory
    libffiName     <- lift $ rtsLibffiLibraryName
    mconcat
        [ builderGcc ? mconcat
          [ arg "-Irts"
          , arg $ "-I" ++ path -/- "build"
          , arg $ "-DRtsWay=\"rts_" ++ show way ++ "\""
          -- rts **must** be compiled with optimizations. The INLINE_HEADER macro,
          -- requires that functions are inlined to work as expected.  Inlining
          -- only happens for optimized builds. Otherwise we can assume that
          -- there is a non-inlined variant to use instead. But rts does not
          -- provide non-inlined alternatives and hence needs the function to
          -- be inlined. See also Issue #90
          , arg $ "-O2"

          , (file "//RtsMessages.*" ||^ file "//Trace.*") ?
            arg ("-DProjectVersion=" ++ quote projectVersion)
{'fraction_non_alphanumeric': 0.08784738577484691, 'fraction_numerical': 0.0018841262364578427, 'mean_word_length': 2.545075125208681, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2107341', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1221, 'n_words': 358}