summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci
diff options
context:
space:
mode:
authornineonine <mail4chemik@gmail.com>2020-10-16 00:04:40 -0700
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-20 00:49:07 -0400
commit58a1ca3886b00630937d7f5073b2d7961f8e80ca (patch)
tree5b6d69fe644b6d8891432d5d4f0be1e165367cea /testsuite/tests/ghci
parent6c7a5c0ca07085f31a3e2f8286bb57a0f35961cb (diff)
downloadhaskell-58a1ca3886b00630937d7f5073b2d7961f8e80ca.tar.gz
Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042)
The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly.
Diffstat (limited to 'testsuite/tests/ghci')
-rw-r--r--testsuite/tests/ghci/scripts/T8042.script11
-rw-r--r--testsuite/tests/ghci/scripts/T8042.stdout9
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
3 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/scripts/T8042.script b/testsuite/tests/ghci/scripts/T8042.script
new file mode 100644
index 0000000000..748db8a9d8
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T8042.script
@@ -0,0 +1,11 @@
+:set -v1
+System.IO.writeFile "T8042B.hs" "{-# OPTIONS_GHC -fobject-code #-} module T8042B where { type I = Int; }"
+System.IO.writeFile "T8042C.hs" "module T8042C where { type B = Bool; }"
+System.IO.writeFile "T8042A.hs" "module T8042A where { import T8042B; import T8042C }"
+-- no `*` prefix so should compile object-code for B only
+:load T8042A
+System.IO.writeFile "T8042A.hs" "{-# OPTIONS_GHC -fobject-code #-} module T8042A where { import T8042B; import T8042C }"
+-- should compile object-code for A now
+:reload
+-- with `*` prefix should compile byte-code for A
+:load *T8042A
diff --git a/testsuite/tests/ghci/scripts/T8042.stdout b/testsuite/tests/ghci/scripts/T8042.stdout
new file mode 100644
index 0000000000..fe2720d35d
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T8042.stdout
@@ -0,0 +1,9 @@
+[1 of 3] Compiling T8042B ( T8042B.hs, T8042B.o )
+[2 of 3] Compiling T8042C ( T8042C.hs, interpreted )
+[3 of 3] Compiling T8042A ( T8042A.hs, interpreted )
+Ok, three modules loaded.
+[3 of 3] Compiling T8042A ( T8042A.hs, T8042A.o )
+Ok, three modules loaded.
+[2 of 3] Compiling T8042C ( T8042C.hs, interpreted )
+[3 of 3] Compiling T8042A ( T8042A.hs, interpreted )
+Ok, three modules loaded.
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index e3a84eb764..dde0e90539 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -174,6 +174,7 @@ test('T7872', normal, ghci_script, ['T7872.script'])
test('T7873', normal, ghci_script, ['T7873.script'])
test('T7939', normal, ghci_script, ['T7939.script'])
test('T7894', normal, ghci_script, ['T7894.script'])
+test('T8042', normal, ghci_script, ['T8042.script'])
test('T8116', normal, ghci_script, ['T8116.script'])
test('T8113', normal, ghci_script, ['T8113.script'])
test('T8172', when(opsys('mingw32'), normalise_drive_letter),