[Git][ghc/ghc][wip/14554-wasm-fix] Deleted 1 commit: ghc-toolchain: Move TgtHasLibm to per-Target file

Cheng Shao pushed to branch wip/14554-wasm-fix at Glasgow Haskell Compiler / GHC WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: dbf776cc by Rodrigo Mesquita at 2025-08-23T19:21:31+02:00 ghc-toolchain: Move TgtHasLibm to per-Target file TargetHasLibm is now part of the per-target configuration Towards #26227 - - - - - 11 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings/IO.hs - hadrian/bindist/Makefile - hadrian/cfg/default.host.target.in - hadrian/cfg/default.target.in - hadrian/cfg/system.config.in - hadrian/src/Rules/Generate.hs - m4/prep_target_file.m4 - utils/ghc-toolchain/exe/Main.hs - utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs - utils/ghc-toolchain/src/GHC/Toolchain/Target.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3499,6 +3499,7 @@ compilerInfo dflags ("target word size", query $ show . wordSize2Bytes . tgtWordSize), ("target word big endian", queryBool $ (\case BigEndian -> True; LittleEndian -> False) . tgtEndianness), ("target has GNU nonexec stack", queryBool tgtSupportsGnuNonexecStack), + ("target has libm", queryBool tgtHasLibm), ("target has .ident directive", queryBool tgtSupportsIdentDirective), ("target has subsections via symbols", queryBool tgtSupportsSubsectionsViaSymbols), ("Unregisterised", queryBool tgtUnregisterised), ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -97,10 +97,6 @@ initSettings top_dir = do getTool :: (Target -> Program) -> (String, [String]) getTool key = (getToolPath key, getToolFlags key) - -- See Note [Settings file] for a little more about this file. We're - -- just partially applying those functions and throwing 'Left's; they're - -- written in a very portable style to keep ghc-boot light. - targetHasLibm <- getBooleanSetting "target has libm" let (cc_prog, cc_args0) = getTool (ccProgram . tgtCCompiler) (cxx_prog, cxx_args) = getTool (cxxProgram . tgtCxxCompiler) @@ -109,7 +105,7 @@ initSettings top_dir = do (js_cpp_prog, js_cpp_args) = getTool (maybe (Program "" []) jsCppProgram . tgtJsCPreprocessor) (cmmCpp_prog, cmmCpp_args) = getTool (cmmCppProgram . tgtCmmCPreprocessor) - platform = getTargetPlatform targetHasLibm target + platform = getTargetPlatform target unreg_cc_args = if platformUnregisterised platform then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] @@ -242,8 +238,8 @@ initSettings top_dir = do , sRawTarget = target } -getTargetPlatform :: Bool {-^ Does target have libm -} -> Target -> Platform -getTargetPlatform targetHasLibm Target{..} = Platform +getTargetPlatform :: Target -> Platform +getTargetPlatform Target{..} = Platform { platformArchOS = tgtArchOs , platformWordSize = case tgtWordSize of WS4 -> PW4 WS8 -> PW8 @@ -255,6 +251,6 @@ getTargetPlatform targetHasLibm Target{..} = Platform , platformIsCrossCompiling = not tgtLocallyExecutable , platformLeadingUnderscore = tgtSymbolsHaveLeadingUnderscore , platformTablesNextToCode = tgtTablesNextToCode - , platformHasLibm = targetHasLibm + , platformHasLibm = tgtHasLibm , platform_constants = Nothing -- will be filled later when loading (or building) the RTS unit } ===================================== hadrian/bindist/Makefile ===================================== @@ -85,8 +85,7 @@ WrapperBinsDir=${bindir} # N.B. this is duplicated from includes/ghc.mk. lib/settings : config.mk @rm -f $@ - @echo '[("target has libm", "$(TargetHasLibm)")' >> $@ - @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ + @echo '[("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("target RTS linker only supports shared libraries", "$(TargetRTSLinkerOnlySupportsSharedLibs)")' >> $@ @echo ',("Use interpreter", "$(GhcWithInterpreter)")' >> $@ @echo ',("Support SMP", "$(GhcWithSMP)")' >> $@ ===================================== hadrian/cfg/default.host.target.in ===================================== @@ -12,6 +12,7 @@ Target , tgtUnregisterised = False , tgtTablesNextToCode = True , tgtUseLibffiForAdjustors = True +, tgtHasLibm = True , tgtCCompiler = Cc {ccProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @CONF_CC_OPTS_STAGE0List@}} , tgtCxxCompiler = Cxx {cxxProgram = Program {prgPath = "@CC_STAGE0@", prgFlags = @CONF_CXX_OPTS_STAGE0List@}} , tgtCPreprocessor = Cpp {cppProgram = Program {prgPath = "@CPPCmd_STAGE0@", prgFlags = @CONF_CPP_OPTS_STAGE0List@}} ===================================== hadrian/cfg/default.target.in ===================================== @@ -12,6 +12,7 @@ Target , tgtUnregisterised = @UnregisterisedBool@ , tgtTablesNextToCode = @TablesNextToCodeBool@ , tgtUseLibffiForAdjustors = @UseLibffiForAdjustorsBool@ +, tgtHasLibm = @TargetHasLibmBool@ , tgtCCompiler = Cc {ccProgram = Program {prgPath = "@CC@", prgFlags = @CONF_CC_OPTS_STAGE2List@}} , tgtCxxCompiler = Cxx {cxxProgram = Program {prgPath = "@CXX@", prgFlags = @CONF_CXX_OPTS_STAGE2List@}} , tgtCPreprocessor = Cpp {cppProgram = Program {prgPath = "@CPPCmd@", prgFlags = @CONF_CPP_OPTS_STAGE2List@}} ===================================== hadrian/cfg/system.config.in ===================================== @@ -81,8 +81,6 @@ project-git-commit-id = @ProjectGitCommitId@ # See Note [tooldir: How GHC finds mingw on Windows] settings-use-distro-mingw = @EnableDistroToolchain@ -target-has-libm = @TargetHasLibm@ - # Include and library directories: #================================= ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -427,7 +427,7 @@ bindistRules = do , interpolateSetting "ProjectVersion" ProjectVersion , interpolateVar "EnableDistroToolchain" $ lookupSystemConfig "settings-use-distro-mingw" , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode - , interpolateVar "TargetHasLibm" $ lookupSystemConfig "target-has-libm" + , interpolateVar "TargetHasLibm" $ yesNo <$> getTarget tgtHasLibm , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian , interpolateVar "TargetWordSize" $ getTarget wordSize @@ -484,7 +484,6 @@ generateSettings settingsFile = do settings <- traverse sequence $ [ ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) - , ("target has libm", expr $ lookupSystemConfig "target-has-libm") , ("target RTS linker only supports shared libraries", expr $ yesNo <$> targetRTSLinkerOnlySupportsSharedLibs) , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter (predStage stage)) , ("Support SMP", expr $ yesNo <$> targetSupportsSMP) ===================================== m4/prep_target_file.m4 ===================================== @@ -157,6 +157,7 @@ AC_DEFUN([PREP_TARGET_FILE],[ PREP_BOOLEAN([Unregisterised]) PREP_BOOLEAN([TablesNextToCode]) PREP_BOOLEAN([UseLibffiForAdjustors]) + PREP_BOOLEAN([TargetHasLibm]) PREP_BOOLEAN([ArIsGNUAr]) PREP_BOOLEAN([ArNeedsRanLib]) PREP_NOT_BOOLEAN([CrossCompiling]) ===================================== utils/ghc-toolchain/exe/Main.hs ===================================== @@ -486,6 +486,7 @@ mkTarget opts = do tgtSupportsSubsectionsViaSymbols <- checkSubsectionsViaSymbols archOs cc tgtSupportsIdentDirective <- checkIdentDirective cc tgtSupportsGnuNonexecStack <- checkGnuNonexecStack archOs cc + tgtHasLibm <- checkTargetHasLibm cc -- code generator configuration tgtUnregisterised <- determineUnregisterised archOs (optUnregisterised opts) @@ -526,6 +527,7 @@ mkTarget opts = do , tgtUnregisterised , tgtTablesNextToCode , tgtUseLibffiForAdjustors = tgtUseLibffi + , tgtHasLibm , tgtSymbolsHaveLeadingUnderscore , tgtSupportsSubsectionsViaSymbols , tgtSupportsIdentDirective ===================================== utils/ghc-toolchain/src/GHC/Toolchain/PlatformDetails.hs ===================================== @@ -5,6 +5,7 @@ module GHC.Toolchain.PlatformDetails , checkSubsectionsViaSymbols , checkIdentDirective , checkGnuNonexecStack + , checkTargetHasLibm ) where import Data.List (isInfixOf) @@ -112,8 +113,6 @@ checkEndianness__BYTE_ORDER__ cc = checking "endianness (__BYTE_ORDER__)" $ do , "#endif" ] - - checkLeadingUnderscore :: Cc -> Nm -> M Bool checkLeadingUnderscore cc nm = checking ctxt $ withTempDir $ \dir -> do let test_o = dir > "test.o" @@ -156,6 +155,21 @@ checkGnuNonexecStack archOs = , asmStmt ".section .text" ] +checkTargetHasLibm :: Cc -> M Bool +checkTargetHasLibm cc0 = testCompile "whether target has libm" prog cc + where + cc = cc0 & _ccProgram % _prgFlags %++ "-lm" + prog = unlines + [ "char atan (void);" + , "int" + , "main (void)" + , "{" + , "return atan ();" + , " ;" + , " return 0;" + , "}" + ] + asmStmt :: String -> String asmStmt s = "__asm__(\"" ++ foldMap escape s ++ "\");" where ===================================== utils/ghc-toolchain/src/GHC/Toolchain/Target.hs ===================================== @@ -57,6 +57,10 @@ data Target = Target , tgtUseLibffiForAdjustors :: Bool -- ^ We need to know whether or not to include libffi headers, and generate additional code for it + -- Target support + , tgtHasLibm :: Bool + -- ^ Does this target have a libm library that should always be linked against? + -- C toolchain , tgtCCompiler :: Cc , tgtCxxCompiler :: Cxx @@ -121,6 +125,7 @@ instance Show Target where , ", tgtUnregisterised = " ++ show tgtUnregisterised , ", tgtTablesNextToCode = " ++ show tgtTablesNextToCode , ", tgtUseLibffiForAdjustors = " ++ show tgtUseLibffiForAdjustors + , ", tgtHasLibm = " ++ show tgtHasLibm , ", tgtCCompiler = " ++ show tgtCCompiler , ", tgtCxxCompiler = " ++ show tgtCxxCompiler , ", tgtCPreprocessor = " ++ show tgtCPreprocessor View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dbf776ccce0de1fd1755f240eb8c0f17... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dbf776ccce0de1fd1755f240eb8c0f17... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Cheng Shao (@TerrorJack)