Skip to content

Commit 6545059

Browse files
author
GHC GitLab CI
committed
feat: JavaScript/GHCJS backend support
- Fix RTS for JavaScript target - Implement stage2 JavaScript build - Add stage3 support - Fix JavaScript-specific issues
1 parent e624fa6 commit 6545059

File tree

12 files changed

+31
-21
lines changed

12 files changed

+31
-21
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ STAGE2_UTIL_TARGETS := \
137137
$(STAGE_UTIL_TARGETS) \
138138
ghc-iserv:ghc-iserv \
139139
rts:nonthreaded-debug \
140+
rts:nonthreaded-nodebug \
140141
hp2ps:hp2ps \
141142
hpc-bin:hpc \
142143
runghc:runghc \

compiler/GHC/Iface/Errors/Ppr.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import GHC.Utils.Outputable
4242
import GHC.Utils.Panic
4343

4444
import GHC.Iface.Errors.Types
45+
import qualified Data.List as List
4546

4647
defaultIfaceMessageOpts :: IfaceMessageOpts
4748
defaultIfaceMessageOpts = IfaceMessageOpts { ifaceShowTriedFiles = False
@@ -174,14 +175,12 @@ cantFindErrorX pkg_hidden_hint may_show_locations mod_or_interface (CantFindInst
174175
looks_like_srcpkgid =
175176
-- Unsafely coerce a unit id (i.e. an installed package component
176177
-- identifier) into a PackageId and see if it means anything.
177-
case cands of
178-
(pkg:pkgs) ->
179-
parens (text "This unit ID looks like the source package ID;" $$
180-
text "the real unit ID is" <+> quotes (ftext (unitIdFS (unitId pkg))) $$
181-
(if null pkgs then empty
182-
else text "and" <+> int (length pkgs) <+> text "other candidate" <> plural pkgs))
178+
case List.sortOn unitPackageNameString cands of
183179
-- Todo: also check if it looks like a package name!
184180
[] -> empty
181+
pkgs ->
182+
parens (text "This unit-id looks like a source package name-version;" <+>
183+
text "candidates real unit-ids are:" $$ vcat (map (quotes . ftext . unitIdFS . unitId) pkgs))
185184

186185
in hsep [ text "no unit id matching" <+> quotes (ppr pkg)
187186
, text "was found"] $$ looks_like_srcpkgid

compiler/GHC/Linker/Dynamic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
8686
-- WASM_DYLINK_NEEDED, otherwise dyld can't load it.
8787
--
8888
--
89-
let pkgs_without_rts = filter ((/= rtsUnitId) . unitId) pkgs_with_rts
89+
let pkgs_without_rts = filter ((/= PackageName (fsLit "rts")) . unitPackageName) pkgs_with_rts
9090
pkgs
9191
| ArchWasm32 <- arch = pkgs_with_rts
9292
| OSMinGW32 <- os = pkgs_with_rts

compiler/GHC/Linker/Static.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ linkStaticLib logger dflags unit_env o_files dep_units = do
293293
| gopt Opt_LinkRts dflags
294294
= pkg_cfgs_init
295295
| otherwise
296-
= filter ((/= rtsUnitId) . unitId) pkg_cfgs_init
296+
= filter ((/= PackageName (fsLit "rts")) . unitPackageName) pkg_cfgs_init
297297

298298
archives <- concatMapM (collectArchives namever ways_) pkg_cfgs
299299

testsuite/tests/driver/T21097b/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ include $(TOP)/mk/test.mk
44

55
T21097b:
66
'$(GHC_PKG)' recache --package-db pkgdb
7-
'$(TEST_HC)' -no-global-package-db -no-user-package-db -package-db pkgdb -v0 Test.hs -ddump-mod-map
7+
'$(TEST_HC)' -no-global-package-db -no-user-package-db -package-db pkgdb -v0 Test.hs -no-rts -ddump-mod-map

testsuite/tests/rts/linker/T20494-obj.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#include <stdio.h>
2+
#include <unistd.h>
23

34
#define CONSTRUCTOR(prio) __attribute__((constructor(prio)))
45
#define DESTRUCTOR(prio) __attribute__((destructor(prio)))
5-
#define PRINT(str) printf(str); fflush(stdout)
6+
// don't use "stdout" variable here as it is not properly defined when loading
7+
// this object in a statically linked GHC.
8+
#define PRINT(str) dprintf(1,str); fsync(1)
69

710
CONSTRUCTOR(1000) void constr_a(void) { PRINT("constr a\n"); }
811
CONSTRUCTOR(2000) void constr_b(void) { PRINT("constr b\n"); }

testsuite/tests/rts/linker/all.T

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ test('T7072',
157157
],
158158
makefile_test, ['T7072'])
159159

160-
test('T20494', [req_rts_linker, when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
161-
makefile_test, ['T20494'])
160+
test('T20494', [req_rts_linker], makefile_test, ['T20494'])
162161

163162
test('T20918',
164163
[extra_files(['T20918_v.cc']),

testsuite/tests/th/T10279.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module T10279 where
22
import Language.Haskell.TH
33
import Language.Haskell.TH.Syntax
4+
import T10279h
45

56
-- NB: rts-1.0.2 is used here because it doesn't change.
67
-- You do need to pick the right version number, otherwise the
78
-- error message doesn't recognize it as a source package ID,
89
-- (This is OK, since it will look obviously wrong when they
910
-- try to find the package in their package database.)
10-
blah = $(conE (Name (mkOccName "Foo") (NameG VarName (mkPkgName "rts-1.0.3") (mkModName "A"))))
11+
blah = $(conE (Name (mkOccName "Foo") (NameG VarName (mkPkgName ("ghc-internal-" <> pkg_version)) (mkModName "A"))))

testsuite/tests/th/T10279.stderr

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
2-
T10279.hs:10:9: error: [GHC-51294]
1+
T10279.hs:11:9: error: [GHC-51294]
32
• Failed to load interface for ‘A’.
4-
no unit id matching ‘rts-1.0.3’ was found
5-
(This unit ID looks like the source package ID;
6-
the real unit ID is ‘rts’
7-
and 1 other candidate)
3+
no unit id matching ‘ghc-internal-9.1300.0’ was found
4+
(This unit-id looks like a source package name-version; candidates real unit-ids are:
5+
‘ghc-internal’)
86
• In the untyped splice:
97
$(conE
108
(Name
119
(mkOccName "Foo")
12-
(NameG VarName (mkPkgName "rts-1.0.3") (mkModName "A"))))
10+
(NameG
11+
VarName (mkPkgName ("ghc-internal-" <> pkg_version))
12+
(mkModName "A"))))
13+

testsuite/tests/th/T10279h.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{-# LANGUAGE CPP #-}
2+
module T10279h where
3+
4+
pkg_version = VERSION_ghc_internal

0 commit comments

Comments
 (0)