From 6636b670233522f01d002c9b97827d00289dbf5c Mon Sep 17 00:00:00 2001 From: Sylvain Henry <sylvain@haskus.fr> Date: Thu, 2 Feb 2023 16:01:56 +0100 Subject: [PATCH] JS: replace "js" architecture with "javascript" Despite Cabal supporting any architecture name, `cabal --check` only supports a few built-in ones. Sadly `cabal --check` is used by Hackage hence using any non built-in name in a package (e.g. `arch(js)`) is rejected and the package is prevented from being uploaded on Hackage. Luckily built-in support for the `javascript` architecture was added for GHCJS a while ago. In order to allow newer `base` to be uploaded on Hackage we make the switch from `js` to `javascript` architecture. Fixes #22740. Co-authored-by: Ben Gamari <ben@smart-cactus.org> --- .gitlab/gen_ci.hs | 2 +- .gitlab/jobs.yaml | 20 ++++++++--------- compiler/GHC.hs | 6 ++--- config.sub | 2 +- configure.ac | 2 +- hadrian/bindist/config.mk.in | 2 +- hadrian/src/Oracles/Flag.hs | 4 ++-- hadrian/src/Oracles/Setting.hs | 2 +- libraries/base/Control/Concurrent.hs | 2 +- libraries/base/GHC/Conc/IO.hs | 22 +++++++++---------- libraries/base/GHC/Conc/Windows.hs | 2 +- libraries/base/GHC/Event.hs | 2 +- libraries/base/GHC/Event/Thread.hs | 2 +- libraries/base/GHC/Event/TimerManager.hs | 2 +- libraries/base/GHC/IO/Encoding.hs | 2 +- .../base/GHC/IO/Encoding/CodePage/API.hs | 2 +- libraries/base/GHC/IO/FD.hs | 14 ++++++------ libraries/base/GHC/JS/Prim.hs | 6 ++--- libraries/base/GHC/JS/Prim/Internal/Build.hs | 2 +- libraries/base/GHC/Stack/CCS.hsc | 2 +- libraries/base/GHC/TopHandler.hs | 8 +++---- libraries/base/GHC/Windows.hs | 2 +- libraries/base/System/CPUTime.hsc | 2 +- libraries/base/System/Environment.hs | 2 +- .../System/Environment/ExecutablePath.hsc | 4 ++-- libraries/base/System/Posix/Internals.hs | 10 ++++----- libraries/base/System/Timeout.hs | 4 ++-- libraries/base/base.cabal | 8 +++---- libraries/ghc-boot/GHC/Platform/ArchOS.hs | 2 +- libraries/ghci/GHCi/CreateBCO.hs | 2 +- libraries/ghci/GHCi/FFI.hsc | 10 ++++----- m4/fptools_set_haskell_platform_vars.m4 | 2 +- m4/ghc_convert_cpu.m4 | 4 ++-- m4/ghc_unregisterised.m4 | 2 +- rts/include/stg/MachRegsForHost.h | 2 +- rts/rts.cabal.in | 3 ++- testsuite/config/ghc | 4 ++-- testsuite/driver/testlib.py | 6 ++--- testsuite/tests/concurrent/should_run/all.T | 2 +- testsuite/tests/numeric/should_run/all.T | 2 +- testsuite/tests/rts/all.T | 2 +- 41 files changed, 92 insertions(+), 91 deletions(-) diff --git a/.gitlab/gen_ci.hs b/.gitlab/gen_ci.hs index fa3d1f419237..c5adc90662cf 100755 --- a/.gitlab/gen_ci.hs +++ b/.gitlab/gen_ci.hs @@ -882,7 +882,7 @@ job_groups = , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "javascript-unknown-ghcjs" (Emulator "js-emulator") (Just "emconfigure") ) { bignumBackend = Native } diff --git a/.gitlab/jobs.yaml b/.gitlab/jobs.yaml index a2994fbcfb14..6db398f22bb9 100644 --- a/.gitlab/jobs.yaml +++ b/.gitlab/jobs.yaml @@ -1449,7 +1449,7 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate": { + "nightly-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1459,7 +1459,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml" ], "reports": { @@ -1501,13 +1501,13 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", + "CROSS_TARGET": "javascript-unknown-ghcjs", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, @@ -3993,7 +3993,7 @@ "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate": { + "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -4003,7 +4003,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate.tar.xz", "junit.xml" ], "reports": { @@ -4045,13 +4045,13 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate", "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_EMULATOR": "js-emulator", - "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate" + "CROSS_TARGET": "javascript-unknown-ghcjs", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_javascript-unknown-ghcjs-validate" } }, "x86_64-linux-fedora33-release": { diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 2c4857477a0e..748a54fdeff5 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -357,7 +357,7 @@ import GHC.Utils.Monad import GHC.Utils.Misc import GHC.Utils.Outputable import GHC.Utils.Panic -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) import GHC.Utils.Panic.Plain #endif import GHC.Utils.Logger @@ -560,7 +560,7 @@ withCleanupSession ghc = ghc `MC.finally` cleanup initGhcMonad :: GhcMonad m => Maybe FilePath -> m () initGhcMonad mb_top_dir = setSession =<< liftIO ( do -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) -- The call to c_keepCAFsForGHCi must not be optimized away. Even in non-debug builds. -- So we can't use assertM here. -- See Note [keepCAFsForGHCi] in keepCAFsForGHCi.c for details about why. @@ -1962,7 +1962,7 @@ mkApiErr :: DynFlags -> SDoc -> GhcApiError mkApiErr dflags msg = GhcApiError (showSDoc dflags msg) -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) foreign import ccall unsafe "keepCAFsForGHCi" c_keepCAFsForGHCi :: IO Bool #endif diff --git a/config.sub b/config.sub index 9977d334bda8..efb0320b999f 100755 --- a/config.sub +++ b/config.sub @@ -1190,7 +1190,7 @@ case $cpu-$vendor in | arc | arceb | arc32 | arc64 \ | arm | arm[lb]e | arme[lb] | armv* \ | avr | avr32 \ - | asmjs | js \ + | asmjs | javascript \ | ba \ | be32 | be64 \ | bfin | bpf | bs2000 \ diff --git a/configure.ac b/configure.ac index 6d04d6f20704..99a91e42d689 100644 --- a/configure.ac +++ b/configure.ac @@ -333,7 +333,7 @@ AC_SUBST(TablesNextToCode) dnl ** Does target have runtime linker support? dnl -------------------------------------------------------------- case "$target" in - powerpc64-*|powerpc64le-*|powerpc-ibm-aix*|s390x-ibm-linux|riscv64-*|wasm*|js-*|loongarch64-*) + powerpc64-*|powerpc64le-*|powerpc-ibm-aix*|s390x-ibm-linux|riscv64-*|wasm*|javascript-*|loongarch64-*) TargetHasRTSLinker=NO ;; *) diff --git a/hadrian/bindist/config.mk.in b/hadrian/bindist/config.mk.in index ee8366a26f70..cad2ccc6e002 100644 --- a/hadrian/bindist/config.mk.in +++ b/hadrian/bindist/config.mk.in @@ -128,7 +128,7 @@ GhcUnregisterised = @Unregisterised@ ifeq "$(TargetArch_CPP)" "arm" # We don't support load/store barriers pre-ARMv7. See #10433. ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES) -else ifeq "$(TargetArch_CPP)" "js" +else ifeq "$(TargetArch_CPP)" "javascript" ArchSupportsSMP=NO else ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64))) diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs index d3baec493294..3f7a2c455156 100644 --- a/hadrian/src/Oracles/Flag.hs +++ b/hadrian/src/Oracles/Flag.hs @@ -100,14 +100,14 @@ platformSupportsSharedLibs = do wasm <- anyTargetArch [ "wasm32" ] ppc_linux <- anyTargetPlatform [ "powerpc-unknown-linux" ] solaris <- anyTargetPlatform [ "i386-unknown-solaris2" ] - javascript <- anyTargetArch [ "js" ] + javascript <- anyTargetArch [ "javascript" ] solarisBroken <- flag SolarisBrokenShld return $ not (windows || wasm || javascript || ppc_linux || solaris && solarisBroken) -- | Does the target support threaded RTS? targetSupportsThreadedRts :: Action Bool targetSupportsThreadedRts = do - bad_arch <- anyTargetArch [ "wasm32", "js" ] + bad_arch <- anyTargetArch [ "wasm32", "javascript" ] return $ not bad_arch -- | Does the target support the -N RTS flag? diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index e064d7a5c1fb..462d289cd007 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -258,7 +258,7 @@ isWinTarget :: Action Bool isWinTarget = anyTargetOs ["mingw32"] isJsTarget :: Action Bool -isJsTarget = anyTargetArch ["js"] +isJsTarget = anyTargetArch ["javascript"] isOsxTarget :: Action Bool isOsxTarget = anyTargetOs ["darwin"] diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index 87ddc9584a52..50166d27f7a8 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -106,7 +106,7 @@ module Control.Concurrent ( ) where -- JavaScript platform doesn't support bound threads -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) #define SUPPORT_BOUND_THREADS #endif diff --git a/libraries/base/GHC/Conc/IO.hs b/libraries/base/GHC/Conc/IO.hs index 869847e77a10..4f7795e3693b 100644 --- a/libraries/base/GHC/Conc/IO.hs +++ b/libraries/base/GHC/Conc/IO.hs @@ -65,12 +65,12 @@ import GHC.IO.SubSystem import GHC.Conc.Windows (asyncRead, asyncWrite, asyncDoProc, asyncReadBA, asyncWriteBA, ConsoleEvent(..), win32ConsoleHandler, toWin32ConsoleEvent) -#elif !defined(js_HOST_ARCH) +#elif !defined(javascript_HOST_ARCH) import qualified GHC.Event.Thread as Event #endif ensureIOManagerIsRunning :: IO () -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) ensureIOManagerIsRunning = pure () #elif !defined(mingw32_HOST_OS) ensureIOManagerIsRunning = Event.ensureIOManagerIsRunning @@ -91,7 +91,7 @@ interruptIOManager = Windows.interruptIOManager #endif ioManagerCapabilitiesChanged :: IO () -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) ioManagerCapabilitiesChanged = Event.ioManagerCapabilitiesChanged #else ioManagerCapabilitiesChanged = return () @@ -105,7 +105,7 @@ ioManagerCapabilitiesChanged = return () -- that has been used with 'threadWaitRead', use 'closeFdWith'. threadWaitRead :: Fd -> IO () threadWaitRead fd -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | threaded = Event.threadWaitRead fd #endif | otherwise = IO $ \s -> @@ -121,7 +121,7 @@ threadWaitRead fd -- that has been used with 'threadWaitWrite', use 'closeFdWith'. threadWaitWrite :: Fd -> IO () threadWaitWrite fd -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | threaded = Event.threadWaitWrite fd #endif | otherwise = IO $ \s -> @@ -135,7 +135,7 @@ threadWaitWrite fd -- in the file descriptor. threadWaitReadSTM :: Fd -> IO (Sync.STM (), IO ()) threadWaitReadSTM fd -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | threaded = Event.threadWaitReadSTM fd #endif | otherwise = do @@ -154,7 +154,7 @@ threadWaitReadSTM fd -- in the file descriptor. threadWaitWriteSTM :: Fd -> IO (Sync.STM (), IO ()) threadWaitWriteSTM fd -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | threaded = Event.threadWaitWriteSTM fd #endif | otherwise = do @@ -179,7 +179,7 @@ closeFdWith :: (Fd -> IO ()) -- ^ Low-level action that performs the real close. -> Fd -- ^ File descriptor to close. -> IO () closeFdWith close fd -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | threaded = Event.closeFdWith close fd #endif | otherwise = close fd @@ -199,7 +199,7 @@ threadDelay time #if defined(mingw32_HOST_OS) | isWindowsNativeIO = Windows.threadDelay time | threaded = Windows.threadDelay time -#elif !defined(js_HOST_ARCH) +#elif !defined(javascript_HOST_ARCH) | threaded = Event.threadDelay time #endif | otherwise = IO $ \s -> @@ -219,11 +219,11 @@ registerDelay _usecs #if defined(mingw32_HOST_OS) | isWindowsNativeIO = Windows.registerDelay _usecs | threaded = Windows.registerDelay _usecs -#elif !defined(js_HOST_ARCH) +#elif !defined(javascript_HOST_ARCH) | threaded = Event.registerDelay _usecs #endif | otherwise = errorWithoutStackTrace "registerDelay: requires -threaded" -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool #endif diff --git a/libraries/base/GHC/Conc/Windows.hs b/libraries/base/GHC/Conc/Windows.hs index e9733806e7c6..b22307e1f2b2 100644 --- a/libraries/base/GHC/Conc/Windows.hs +++ b/libraries/base/GHC/Conc/Windows.hs @@ -19,7 +19,7 @@ -- #not-home module GHC.Conc.Windows -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) () where #else ( ensureIOManagerIsRunning diff --git a/libraries/base/GHC/Event.hs b/libraries/base/GHC/Event.hs index a9acda5516b1..5a98a9aeda0d 100644 --- a/libraries/base/GHC/Event.hs +++ b/libraries/base/GHC/Event.hs @@ -11,7 +11,7 @@ -- ---------------------------------------------------------------------------- module GHC.Event -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) ( ) where #else ( -- * Types diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs index f76e9147da9d..1018edc25317 100644 --- a/libraries/base/GHC/Event/Thread.hs +++ b/libraries/base/GHC/Event/Thread.hs @@ -5,7 +5,7 @@ #include <ghcplatform.h> module GHC.Event.Thread -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) ( ) where #else ( getSystemEventManager diff --git a/libraries/base/GHC/Event/TimerManager.hs b/libraries/base/GHC/Event/TimerManager.hs index bb26741d582f..b334924a9dee 100644 --- a/libraries/base/GHC/Event/TimerManager.hs +++ b/libraries/base/GHC/Event/TimerManager.hs @@ -7,7 +7,7 @@ -- TODO: use the new Windows IO manager module GHC.Event.TimerManager -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) () where #else ( -- * Types diff --git a/libraries/base/GHC/IO/Encoding.hs b/libraries/base/GHC/IO/Encoding.hs index ea738c56a431..4759356f4cb0 100644 --- a/libraries/base/GHC/IO/Encoding.hs +++ b/libraries/base/GHC/IO/Encoding.hs @@ -180,7 +180,7 @@ initLocaleEncoding, initFileSystemEncoding, initForeignEncoding :: TextEncoding -- N.B. initLocaleEncoding is exported for use in System.IO.localeEncoding. -- NOINLINE ensures that this result is shared. -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) initLocaleEncoding = utf8 initFileSystemEncoding = utf8 initForeignEncoding = utf8 diff --git a/libraries/base/GHC/IO/Encoding/CodePage/API.hs b/libraries/base/GHC/IO/Encoding/CodePage/API.hs index ef6bebd0028c..6136156cdbc7 100644 --- a/libraries/base/GHC/IO/Encoding/CodePage/API.hs +++ b/libraries/base/GHC/IO/Encoding/CodePage/API.hs @@ -32,7 +32,7 @@ import GHC.ForeignPtr (castForeignPtr) import System.Posix.Internals -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) mkCodePageEncoding :: String mkCodePageEncoding = "" #else diff --git a/libraries/base/GHC/IO/FD.hs b/libraries/base/GHC/IO/FD.hs index 2886658a5c26..2d4b92fa4f85 100644 --- a/libraries/base/GHC/IO/FD.hs +++ b/libraries/base/GHC/IO/FD.hs @@ -570,7 +570,7 @@ indicates that there's no data, we call threadWaitRead. readRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int readRawBufferPtr loc !fd !buf !off !len -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) = fmap fromIntegral . uninterruptibleMask_ $ throwErrnoIfMinus1 loc (c_read (fdFD fd) (buf `plusPtr` off) len) #else @@ -592,7 +592,7 @@ readRawBufferPtr loc !fd !buf !off !len -- return: -1 indicates EOF, >=0 is bytes read readRawBufferPtrNoBlock :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int readRawBufferPtrNoBlock loc !fd !buf !off !len -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) = uninterruptibleMask_ $ do r <- throwErrnoIfMinus1 loc (c_read (fdFD fd) (buf `plusPtr` off) len) case r of @@ -617,7 +617,7 @@ readRawBufferPtrNoBlock loc !fd !buf !off !len writeRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt writeRawBufferPtr loc !fd !buf !off !len -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) = fmap fromIntegral . uninterruptibleMask_ $ throwErrnoIfMinus1 loc (c_write (fdFD fd) (buf `plusPtr` off) len) #else @@ -637,7 +637,7 @@ writeRawBufferPtr loc !fd !buf !off !len writeRawBufferPtrNoBlock :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt writeRawBufferPtrNoBlock loc !fd !buf !off !len -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) = uninterruptibleMask_ $ do r <- throwErrnoIfMinus1 loc (c_write (fdFD fd) (buf `plusPtr` off) len) case r of @@ -658,7 +658,7 @@ writeRawBufferPtrNoBlock loc !fd !buf !off !len safe_write = do_write (c_safe_write (fdFD fd) (buf `plusPtr` off) len) #endif -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) isNonBlocking :: FD -> Bool isNonBlocking fd = fdIsNonBlocking fd /= 0 @@ -754,14 +754,14 @@ foreign import WINDOWS_CCONV safe "send" #endif -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool #endif -- ----------------------------------------------------------------------------- -- utils -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) throwErrnoIfMinus1RetryOnBlock :: String -> IO CSsize -> IO CSsize -> IO CSsize throwErrnoIfMinus1RetryOnBlock loc f on_block = do diff --git a/libraries/base/GHC/JS/Prim.hs b/libraries/base/GHC/JS/Prim.hs index 4a9505cbdf0b..955cadf3288e 100644 --- a/libraries/base/GHC/JS/Prim.hs +++ b/libraries/base/GHC/JS/Prim.hs @@ -10,7 +10,7 @@ module GHC.JS.Prim ( JSVal(..), JSVal# , JSException(..) , WouldBlockException(..) -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) , toIO , resolve , resolveIO @@ -54,7 +54,7 @@ import GHC.IO argument or result. -} -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) data JSVal = JSVal ByteArray# type JSVal# = ByteArray# #else @@ -75,7 +75,7 @@ instance Ex.Exception JSException instance Show JSException where show (JSException _ xs) = "JavaScript exception: " ++ xs -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) {-# NOINLINE toIO #-} toIO :: Exts.Any -> IO Exts.Any diff --git a/libraries/base/GHC/JS/Prim/Internal/Build.hs b/libraries/base/GHC/JS/Prim/Internal/Build.hs index 78203cd78734..18a5c7644101 100644 --- a/libraries/base/GHC/JS/Prim/Internal/Build.hs +++ b/libraries/base/GHC/JS/Prim/Internal/Build.hs @@ -1,7 +1,7 @@ -- helpers for constructing JS objects that can be efficiently inlined as literals -- no Template Haskell available yet, generated by utils/genBuildObject.hs {-# LANGUAGE CPP #-} -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) module GHC.JS.Prim.Internal.Build () where #else {-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI, GHCForeignImportPrim #-} diff --git a/libraries/base/GHC/Stack/CCS.hsc b/libraries/base/GHC/Stack/CCS.hsc index b6d3f83b94f1..274202efd643 100644 --- a/libraries/base/GHC/Stack/CCS.hsc +++ b/libraries/base/GHC/Stack/CCS.hsc @@ -76,7 +76,7 @@ clearCCS :: IO a -> IO a clearCCS (IO m) = IO $ \s -> clearCCS## m s -- | Get the 'CostCentre' at the head of a 'CostCentreStack'. -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) ccsCC :: Ptr CostCentreStack -> IO (Ptr CostCentre) ccsCC p = peekByteOff p 4 diff --git a/libraries/base/GHC/TopHandler.hs b/libraries/base/GHC/TopHandler.hs index 153b5170d7a3..04045dad0523 100644 --- a/libraries/base/GHC/TopHandler.hs +++ b/libraries/base/GHC/TopHandler.hs @@ -47,7 +47,7 @@ import GHC.Weak #if defined(mingw32_HOST_OS) import GHC.ConsoleHandler -#elif defined(js_HOST_ARCH) +#elif defined(javascript_HOST_ARCH) #else import Data.Dynamic (toDyn) #endif @@ -95,7 +95,7 @@ runMainIO main = topHandler install_interrupt_handler :: IO () -> IO () -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) install_interrupt_handler _ = return () #elif defined(mingw32_HOST_OS) install_interrupt_handler handler = do @@ -269,7 +269,7 @@ unreachable :: IO a unreachable = failIO "If you can read this, shutdownHaskellAndExit did not exit." exitHelper :: CInt -> Int -> IO a -#if defined(mingw32_HOST_OS) || defined(js_HOST_ARCH) +#if defined(mingw32_HOST_OS) || defined(javascript_HOST_ARCH) exitHelper exitKind r = shutdownHaskellAndExit (fromIntegral r) exitKind >> unreachable #else @@ -297,7 +297,7 @@ foreign import ccall "shutdownHaskellAndSignal" exitInterrupted :: IO a exitInterrupted = -#if defined(mingw32_HOST_OS) || defined(js_HOST_ARCH) +#if defined(mingw32_HOST_OS) || defined(javascript_HOST_ARCH) safeExit 252 #elif !defined(HAVE_SIGNAL_H) safeExit 1 diff --git a/libraries/base/GHC/Windows.hs b/libraries/base/GHC/Windows.hs index 85faa25e43a7..f007d9045383 100644 --- a/libraries/base/GHC/Windows.hs +++ b/libraries/base/GHC/Windows.hs @@ -21,7 +21,7 @@ ----------------------------------------------------------------------------- module GHC.Windows ( -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) ) where #else diff --git a/libraries/base/System/CPUTime.hsc b/libraries/base/System/CPUTime.hsc index 19d21e213520..c98c5ddaf639 100644 --- a/libraries/base/System/CPUTime.hsc +++ b/libraries/base/System/CPUTime.hsc @@ -34,7 +34,7 @@ import System.IO.Unsafe (unsafePerformIO) #if defined(mingw32_HOST_OS) import qualified System.CPUTime.Windows as I -#elif defined(js_HOST_ARCH) +#elif defined(javascript_HOST_ARCH) import qualified System.CPUTime.Javascript as I #elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 diff --git a/libraries/base/System/Environment.hs b/libraries/base/System/Environment.hs index c5e5d6d039c3..771b49019624 100644 --- a/libraries/base/System/Environment.hs +++ b/libraries/base/System/Environment.hs @@ -19,7 +19,7 @@ module System.Environment ( getArgs, getProgName, -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) executablePath, #endif getExecutablePath, diff --git a/libraries/base/System/Environment/ExecutablePath.hsc b/libraries/base/System/Environment/ExecutablePath.hsc index ede63d5e6d4c..cb9fad7a7e7d 100644 --- a/libraries/base/System/Environment/ExecutablePath.hsc +++ b/libraries/base/System/Environment/ExecutablePath.hsc @@ -18,12 +18,12 @@ module System.Environment.ExecutablePath ( getExecutablePath -##if !defined(js_HOST_ARCH) +##if !defined(javascript_HOST_ARCH) , executablePath ##endif ) where -##if defined(js_HOST_ARCH) +##if defined(javascript_HOST_ARCH) getExecutablePath :: IO FilePath getExecutablePath = return "a.jsexe" diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs index 4a82bbae1c41..89fa80672f75 100644 --- a/libraries/base/System/Posix/Internals.hs +++ b/libraries/base/System/Posix/Internals.hs @@ -429,7 +429,7 @@ c_safe_open filepath oflags mode = hostIsThreaded :: Bool hostIsThreaded = rtsIsThreaded_ /= 0 -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) foreign import ccall unsafe "HsBase.h __hscore_open" c_open :: CFilePath -> CInt -> CMode -> IO CInt @@ -454,7 +454,7 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat" lstat :: CFilePath -> Ptr CStat -> IO CInt #endif -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) foreign import javascript unsafe "(() => { return rts_isThreaded; })" rtsIsThreaded_ :: Int foreign import javascript interruptible "(($1_1, $2_2, $2, $c) => { return h$base_access($1_1,$2_2,$2,$c); })" @@ -743,7 +743,7 @@ foreign import ccall unsafe "HsBase.h getpid" #endif #endif -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) foreign import ccall unsafe "HsBase.h __hscore_stat" c_stat :: CFilePath -> Ptr CStat -> IO CInt @@ -751,7 +751,7 @@ foreign import ccall unsafe "HsBase.h __hscore_ftruncate" c_ftruncate :: CInt -> COff -> IO CInt #endif -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) foreign import capi unsafe "HsBase.h fcntl" c_fcntl_read :: CInt -> CInt -> IO CInt @@ -822,7 +822,7 @@ c_waitpid _ _ _ = ioError (ioeSetLocation unsupportedOperation "waitpid") #endif -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) -- POSIX flags only: foreign import ccall unsafe "HsBase.h __hscore_o_rdonly" o_RDONLY :: CInt foreign import ccall unsafe "HsBase.h __hscore_o_wronly" o_WRONLY :: CInt diff --git a/libraries/base/System/Timeout.hs b/libraries/base/System/Timeout.hs index bf215c747a44..60908066d46f 100644 --- a/libraries/base/System/Timeout.hs +++ b/libraries/base/System/Timeout.hs @@ -17,7 +17,7 @@ -- TODO: Inspect is still suitable. module System.Timeout ( Timeout, timeout ) where -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) import Control.Monad import GHC.Event (getSystemTimerManager, registerTimeout, unregisterTimeout) @@ -99,7 +99,7 @@ timeout :: Int -> IO a -> IO (Maybe a) timeout n f | n < 0 = fmap Just f | n == 0 = return Nothing -#if !defined(mingw32_HOST_OS) && !defined(js_HOST_ARCH) +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH) | rtsSupportsBoundThreads = do -- In the threaded RTS, we use the Timer Manager to delay the -- (fairly expensive) 'forkIO' call until the timeout has expired. diff --git a/libraries/base/base.cabal b/libraries/base/base.cabal index 5e7fdc17c69f..5436c10c14ac 100644 --- a/libraries/base/base.cabal +++ b/libraries/base/base.cabal @@ -362,7 +362,7 @@ Library System.Environment.ExecutablePath System.CPUTime.Utils - if !arch(js) + if !arch(javascript) c-sources: cbits/DarwinUtils.c cbits/PrelIOUtils.c @@ -378,7 +378,7 @@ Library cbits/CastFloatWord.cmm cbits/StackCloningDecoding.cmm - if arch(js) + if arch(javascript) js-sources: -- "platform" must be linked first because it defines global constants -- (e.g. h$isNode) @@ -460,7 +460,7 @@ Library System.CPUTime.Posix.RUsage System.CPUTime.Unsupported - if arch(js) + if arch(javascript) other-modules: System.CPUTime.Javascript @@ -470,7 +470,7 @@ Library if os(freebsd) cc-options: -DLIBICONV_PLUG - if arch(js) + if arch(javascript) exposed-modules: GHC.JS.Prim GHC.JS.Prim.Internal diff --git a/libraries/ghc-boot/GHC/Platform/ArchOS.hs b/libraries/ghc-boot/GHC/Platform/ArchOS.hs index 3a2774db7d7a..26a319ba13ed 100644 --- a/libraries/ghc-boot/GHC/Platform/ArchOS.hs +++ b/libraries/ghc-boot/GHC/Platform/ArchOS.hs @@ -136,7 +136,7 @@ stringEncodeArch = \case ArchMipsel -> "mipsel" ArchRISCV64 -> "riscv64" ArchLoongArch64 -> "loongarch64" - ArchJavaScript -> "js" + ArchJavaScript -> "javascript" ArchWasm32 -> "wasm32" -- | See Note [Platform Syntax]. diff --git a/libraries/ghci/GHCi/CreateBCO.hs b/libraries/ghci/GHCi/CreateBCO.hs index 72364b6a7e57..7891fec6a724 100644 --- a/libraries/ghci/GHCi/CreateBCO.hs +++ b/libraries/ghci/GHCi/CreateBCO.hs @@ -133,7 +133,7 @@ writePtrsArrayPtr (I# i) (Ptr a#) (PtrsArr arr) = IO $ \s -> -- without making a thunk turns out to be surprisingly tricky. {-# NOINLINE writeArrayAddr# #-} writeArrayAddr# :: MutableArray# s a -> Int# -> Addr# -> State# s -> State# s -#if defined(js_HOST_ARCH) +#if defined(javascript_HOST_ARCH) -- Addr# isn't coercible with Any with the JS backend. writeArrayAddr# = error "writeArrayAddr#: currently unsupported with the JS backend" #else diff --git a/libraries/ghci/GHCi/FFI.hsc b/libraries/ghci/GHCi/FFI.hsc index ab6c4bb17f94..a24810fc8f98 100644 --- a/libraries/ghci/GHCi/FFI.hsc +++ b/libraries/ghci/GHCi/FFI.hsc @@ -21,7 +21,7 @@ they are every used. -} -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) #include <ffi.h> #endif @@ -35,7 +35,7 @@ module GHCi.FFI ) where import Prelude -- See note [Why do we import Prelude here?] -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) import Control.Exception import Foreign.C #endif @@ -70,7 +70,7 @@ prepForeignCall -> FFIType -- result type -> IO (Ptr C_ffi_cif) -- token for making calls (must be freed by caller) -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) prepForeignCall cconv arg_types result_type = do let n_args = length arg_types arg_arr <- mallocArray n_args @@ -93,7 +93,7 @@ prepForeignCall _ _ _ = freeForeignCallInfo :: Ptr C_ffi_cif -> IO () -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) freeForeignCallInfo p = do free ((#ptr ffi_cif, arg_types) p) free p @@ -104,7 +104,7 @@ freeForeignCallInfo _ = data C_ffi_cif -#if !defined(js_HOST_ARCH) +#if !defined(javascript_HOST_ARCH) data C_ffi_type strError :: C_ffi_status -> String diff --git a/m4/fptools_set_haskell_platform_vars.m4 b/m4/fptools_set_haskell_platform_vars.m4 index 02b5b4e53c4a..2afb21e2474d 100644 --- a/m4/fptools_set_haskell_platform_vars.m4 +++ b/m4/fptools_set_haskell_platform_vars.m4 @@ -51,7 +51,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS], hppa|hppa1_1|ia64|m68k|nios2|riscv32|loongarch32|rs6000|s390|sh4|vax) test -z "[$]2" || eval "[$]2=ArchUnknown" ;; - js) + javascript) test -z "[$]2" || eval "[$]2=ArchJavaScript" ;; *) diff --git a/m4/ghc_convert_cpu.m4 b/m4/ghc_convert_cpu.m4 index b3f1789bbc1f..880daee61e6f 100644 --- a/m4/ghc_convert_cpu.m4 +++ b/m4/ghc_convert_cpu.m4 @@ -83,8 +83,8 @@ case "$1" in wasm32) $2="wasm32" ;; - js) - $2="js" + javascript) + $2="javascript" ;; *) echo "Unknown CPU $1" diff --git a/m4/ghc_unregisterised.m4 b/m4/ghc_unregisterised.m4 index 38b445067de1..826714d8ad44 100644 --- a/m4/ghc_unregisterised.m4 +++ b/m4/ghc_unregisterised.m4 @@ -5,7 +5,7 @@ AC_DEFUN([GHC_UNREGISTERISED], [ AC_MSG_CHECKING(whether target supports a registerised ABI) case "$TargetArch" in - i386|x86_64|powerpc|powerpc64|powerpc64le|s390x|arm|aarch64|riscv64|wasm32|js|loongarch64) + i386|x86_64|powerpc|powerpc64|powerpc64le|s390x|arm|aarch64|riscv64|wasm32|javascript|loongarch64) UnregisterisedDefault=NO AC_MSG_RESULT([yes]) ;; diff --git a/rts/include/stg/MachRegsForHost.h b/rts/include/stg/MachRegsForHost.h index 6452df415817..f401122e5ff1 100644 --- a/rts/include/stg/MachRegsForHost.h +++ b/rts/include/stg/MachRegsForHost.h @@ -14,7 +14,7 @@ #pragma once -#if defined(UnregisterisedCompiler) || defined(js_HOST_ARCH) +#if defined(UnregisterisedCompiler) || defined(javascript_HOST_ARCH) #if !defined(NO_REGS) #define NO_REGS #endif diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in index 00d720d4ff51..276f7e1b006d 100644 --- a/rts/rts.cabal.in +++ b/rts/rts.cabal.in @@ -81,7 +81,8 @@ library exposed: True exposed-modules: - if os(ghcjs) + + if arch(javascript) include-dirs: include -- dummy file to force the build of a .a lib diff --git a/testsuite/config/ghc b/testsuite/config/ghc index 1d4ae806951a..1821d5a5725b 100644 --- a/testsuite/config/ghc +++ b/testsuite/config/ghc @@ -70,12 +70,12 @@ if windows: config.other_ways += winio_ways # LLVM -if not config.unregisterised and not config.arch == "js" and config.have_llvm: +if not config.unregisterised and not config.arch == "javascript" and config.have_llvm: config.compile_ways.append('optllvm') config.run_ways.append('optllvm') # HPC -if not config.arch == "js": +if not config.arch == "javascript": config.compile_ways.append('hpc') config.run_ways.append('hpc') diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index bc83038d2b5d..96ff802c0d48 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -139,12 +139,12 @@ def skip( name, opts ): # disable test on JS arch def js_skip( name, opts ): - if arch("js"): + if arch("javascript"): skip(name,opts) # expect broken for the JS backend def js_broken( bug: IssueNumber ): - if arch("js"): + if arch("javascript"): return expect_broken(bug); else: return normal; @@ -2364,7 +2364,7 @@ def normalise_errmsg(s: str) -> str: # The inplace ghc's are called ghc-stage[123] to avoid filename # collisions, so we need to normalise that to just "ghc" s = re.sub('ghc-stage[123]', 'ghc', s) - # Remove platform prefix (e.g. js-unknown-ghcjs) for cross-compiled tools + # Remove platform prefix (e.g. javascript-unknown-ghcjs) for cross-compiled tools # (ghc, ghc-pkg, unlit, etc.) s = re.sub('\\w+-\\w+-\\w+-ghc', 'ghc', s) s = re.sub('\\w+-\\w+-\\w+-unlit', 'unlit', s) diff --git a/testsuite/tests/concurrent/should_run/all.T b/testsuite/tests/concurrent/should_run/all.T index 047f70e6d8ed..7a4208ff674d 100644 --- a/testsuite/tests/concurrent/should_run/all.T +++ b/testsuite/tests/concurrent/should_run/all.T @@ -130,7 +130,7 @@ test('conc012', test('conc013', normal, compile_and_run, ['']) test('conc014', normal, compile_and_run, ['']) test('conc015', - [ when(arch("js"), fragile(22261)) # delays are flaky with the JS backend when the system is overloaded + [ when(arch("javascript"), fragile(22261)) # delays are flaky with the JS backend when the system is overloaded ], compile_and_run, ['']) test('conc015a', normal, compile_and_run, ['']) test('conc016', [omit_ways(concurrent_ways) # see comment in conc016.hs diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T index e4d558ea1397..a9d5ef7b1268 100644 --- a/testsuite/tests/numeric/should_run/all.T +++ b/testsuite/tests/numeric/should_run/all.T @@ -63,7 +63,7 @@ test('T9407', normal, compile_and_run, ['']) test('T9810', normal, compile_and_run, ['']) test('T10011', normal, compile_and_run, ['']) test('T10962', omit_ways(['ghci']), compile_and_run, ['-O2']) -test('T11702', [unless(arch("js"),extra_ways(['optasm']))], compile_and_run, ['']) +test('T11702', [unless(arch("javascript"),extra_ways(['optasm']))], compile_and_run, ['']) test('T12136', normal, compile_and_run, ['']) test('T15301', normal, compile_and_run, ['-O2']) test('T497', normal, compile_and_run, ['-O']) diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index f3349e02327d..7effbe6b01cb 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -42,7 +42,7 @@ test('derefnull', when(platform('aarch64-apple-darwin'), [ignore_stderr, exit_code(139)]), when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), when(opsys('mingw32'), [fragile(18548)]), - when(platform('js-unknown-ghcjs'), [ignore_stderr, exit_code(1)]), + when(arch('javascript'), [ignore_stderr, exit_code(1)]), # ThreadSanitizer changes the output when(have_thread_sanitizer(), skip), # since these test are supposed to crash the -- GitLab