Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5fc9442a by Peter Trommler at 2026-02-01T04:21:44-05:00 hadrian: Fix dependency generation for assembler Assembler files allow # for comments unless in column 1. A modern cpp for C treats those a preprocessor directives. We tell gcc that a .S file is assembler with cpp and not C. Fixes #26819 - - - - - 4 changed files: - hadrian/src/Builder.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Settings/Builders/Cc.hs - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -49,7 +49,7 @@ import GHC.Toolchain.Program -- * Compile or preprocess a source file. -- * Extract source dependencies by passing @-MM@ command line argument. data CcMode = CompileC | FindCDependencies DependencyType deriving (Eq, Generic, Show) -data DependencyType = CDep | CxxDep deriving (Eq, Generic, Show) +data DependencyType = CDep | CxxDep | AsmDep deriving (Eq, Generic, Show) instance Binary CcMode instance Hashable CcMode ===================================== hadrian/src/Rules/Compile.hs ===================================== @@ -282,8 +282,11 @@ needDependencies lang context@Context {..} src depFile = do discover -- Continue the discovery process -- We need to pass different flags to cc depending on whether the - -- file to compile is a .c or a .cpp file - depType = if lang == Cxx then CxxDep else CDep + -- file to compile is a .c or a .cpp or a .S file + depType = case lang of + Cxx -> CxxDep + Asm -> AsmDep + _ -> CDep parseFile :: FilePath -> Action [String] parseFile file = do ===================================== hadrian/src/Settings/Builders/Cc.hs ===================================== @@ -18,6 +18,7 @@ ccBuilderArgs = do , arg "-o", arg =<< getOutput ] , builder (Cc (FindCDependencies CDep)) ? findCDepExpr CDep , builder (Cc (FindCDependencies CxxDep)) ? findCDepExpr CxxDep + , builder (Cc (FindCDependencies AsmDep)) ? findCDepExpr AsmDep ] where findCDepExpr depType = do @@ -26,10 +27,10 @@ ccBuilderArgs = do , arg "-MM", arg "-MG" , arg "-MF", arg output , arg "-MT", arg $ dropExtension output -<.> "o" - , case depType of CDep -> mempty; CxxDep -> arg "-std=c++11" + , case depType of CDep -> mempty; CxxDep -> arg "-std=c++11"; AsmDep -> mempty , cIncludeArgs - , arg "-x", arg (case depType of CDep -> "c"; CxxDep -> "c++") - , case depType of CDep -> mempty; CxxDep -> getContextData cxxOpts + , arg "-x", arg (case depType of CDep -> "c"; CxxDep -> "c++"; AsmDep -> "assembler-with-cpp") + , case depType of CDep -> mempty; CxxDep -> getContextData cxxOpts; AsmDep -> mempty -- Pass 'ghcversion.h' to give sources access to the -- `MIN_VERSION_GLASGOW_HASKELL` macro. , notStage0 ? arg "-include" <> arg "rts/include/ghcversion.h" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -428,6 +428,7 @@ rtsPackageArgs = package rts ? do ] , builder (Cc (FindCDependencies CDep)) ? cArgs , builder (Cc (FindCDependencies CxxDep)) ? cArgs + , builder (Cc (FindCDependencies AsmDep)) ? cArgs , builder (Ghc CompileCWithGhc) ? map ("-optc" ++) <$> cArgs , builder (Ghc CompileCppWithGhc) ? map ("-optcxx" ++) <$> cArgs , builder Ghc ? ghcArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fc9442a0aec2208cbda1b24f46339a3... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fc9442a0aec2208cbda1b24f46339a3... You're receiving this email because of your account on gitlab.haskell.org.