From 2f571afe1c2aeb3f4dfca2012bc6b713144fd234 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Fri, 12 May 2023 11:50:43 +0200 Subject: Fix GHCJS OS platform (fix #23346) --- compiler/GHC/Platform.hs | 1 + libraries/ghc-boot/GHC/Platform/ArchOS.hs | 2 ++ m4/fptools_set_haskell_platform_vars.m4 | 2 +- testsuite/tests/javascript/T23346.hs | 18 ++++++++++++++++++ testsuite/tests/javascript/T23346.stdout | 1 + testsuite/tests/javascript/all.T | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/javascript/T23346.hs create mode 100644 testsuite/tests/javascript/T23346.stdout diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs index 6ea05b30a3..a5a609d252 100644 --- a/compiler/GHC/Platform.hs +++ b/compiler/GHC/Platform.hs @@ -208,6 +208,7 @@ osElfTarget OSQNXNTO = False osElfTarget OSAIX = False osElfTarget OSHurd = True osElfTarget OSWasi = False +osElfTarget OSGhcjs = False osElfTarget OSUnknown = False -- Defaulting to False is safe; it means don't rely on any -- ELF-specific functionality. It is important to have a default for diff --git a/libraries/ghc-boot/GHC/Platform/ArchOS.hs b/libraries/ghc-boot/GHC/Platform/ArchOS.hs index 26a319ba13..4aa42baa3b 100644 --- a/libraries/ghc-boot/GHC/Platform/ArchOS.hs +++ b/libraries/ghc-boot/GHC/Platform/ArchOS.hs @@ -98,6 +98,7 @@ data OS | OSAIX | OSHurd | OSWasi + | OSGhcjs deriving (Read, Show, Eq, Ord) @@ -157,3 +158,4 @@ stringEncodeOS = \case OSAIX -> "aix" OSHurd -> "hurd" OSWasi -> "wasi" + OSGhcjs -> "ghcjs" diff --git a/m4/fptools_set_haskell_platform_vars.m4 b/m4/fptools_set_haskell_platform_vars.m4 index 2afb21e247..9c0c5e052b 100644 --- a/m4/fptools_set_haskell_platform_vars.m4 +++ b/m4/fptools_set_haskell_platform_vars.m4 @@ -119,7 +119,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS], test -z "[$]2" || eval "[$]2=OSHurd" ;; ghcjs|js) - test -z "[$]2" || eval "[$]2=OSUnknown" + test -z "[$]2" || eval "[$]2=OSGhcjs" ;; *) echo "Unknown OS '[$]1'" diff --git a/testsuite/tests/javascript/T23346.hs b/testsuite/tests/javascript/T23346.hs new file mode 100644 index 0000000000..60fb2b8847 --- /dev/null +++ b/testsuite/tests/javascript/T23346.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE CPP #-} + +module Main where + +main :: IO () +main = print (correct_host && correct_arch) + +#ifdef ghcjs_HOST_OS +correct_host = True +#else +correct_host = False +#endif + +#ifdef javascript_HOST_ARCH +correct_arch = True +#else +correct_arch = False +#endif diff --git a/testsuite/tests/javascript/T23346.stdout b/testsuite/tests/javascript/T23346.stdout new file mode 100644 index 0000000000..0ca95142bb --- /dev/null +++ b/testsuite/tests/javascript/T23346.stdout @@ -0,0 +1 @@ +True diff --git a/testsuite/tests/javascript/all.T b/testsuite/tests/javascript/all.T index 3da7759da5..ff6b57a076 100644 --- a/testsuite/tests/javascript/all.T +++ b/testsuite/tests/javascript/all.T @@ -15,3 +15,5 @@ test('js-callback02', normal, compile_and_run, ['']) test('js-callback03', normal, compile_and_run, ['']) test('js-callback04', js_skip, compile_and_run, ['']) test('js-callback05', js_skip, compile_and_run, ['']) + +test('T23346', normal, compile_and_run, ['']) -- cgit v1.2.1