[Git][ghc/ghc][wip/T26819] hadrian: Fix dependency generation for assembler
Peter Trommler pushed to branch wip/T26819 at Glasgow Haskell Compiler / GHC Commits: abb60b63 by Peter Trommler at 2026-01-24T16:23:14+01: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 ggc that a .S file is assembler with cpp and not C. Fixes #26819 - - - - - 3 changed files: - hadrian/src/Builder.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Settings/Builders/Cc.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" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abb60b635ba77882a11e343ac7422899... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abb60b635ba77882a11e343ac7422899... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Peter Trommler (@trommler)