diff options
author | Divam <dfordivam@gmail.com> | 2021-05-11 20:25:00 +0900 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-20 18:09:13 -0400 |
commit | 649d63db1dc543b7cbba22e14375ff2766edd664 (patch) | |
tree | d6ff279b4f17b41e347cd59a554d3ba458f2192f | |
parent | aac87bd388547e28aca1c19e7436ff5fa9245f04 (diff) | |
download | haskell-649d63db1dc543b7cbba22e14375ff2766edd664.tar.gz |
Add tests for code generation options specified via OPTIONS_GHC in multi module compilation
13 files changed, 99 insertions, 0 deletions
diff --git a/testsuite/tests/driver/options_ghc/Load_Mod_top.script b/testsuite/tests/driver/options_ghc/Load_Mod_top.script new file mode 100644 index 0000000000..343bc33c32 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Load_Mod_top.script @@ -0,0 +1,2 @@ +:load Mod_top +:show modules
\ No newline at end of file diff --git a/testsuite/tests/driver/options_ghc/Mod_fasm.hs b/testsuite/tests/driver/options_ghc/Mod_fasm.hs new file mode 100644 index 0000000000..484182ff3c --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_fasm.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -fasm #-} + +module Mod_fasm where + +a :: Int +a = 4 diff --git a/testsuite/tests/driver/options_ghc/Mod_fasm_fllvm.hs b/testsuite/tests/driver/options_ghc/Mod_fasm_fllvm.hs new file mode 100644 index 0000000000..2a0bd361c5 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_fasm_fllvm.hs @@ -0,0 +1,4 @@ +module Mod_fasm_fllvm where + +import Mod_fasm +import Mod_fllvm diff --git a/testsuite/tests/driver/options_ghc/Mod_fbyte_code.hs b/testsuite/tests/driver/options_ghc/Mod_fbyte_code.hs new file mode 100644 index 0000000000..e086d5d5e2 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_fbyte_code.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -fbyte-code #-} + +module Mod_fbyte_code where + +c :: Int +c = 6 diff --git a/testsuite/tests/driver/options_ghc/Mod_fllvm.hs b/testsuite/tests/driver/options_ghc/Mod_fllvm.hs new file mode 100644 index 0000000000..a94b793520 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_fllvm.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -fllvm #-} + +module Mod_fllvm where + +b :: Int +b = 5 diff --git a/testsuite/tests/driver/options_ghc/Mod_fobject_code.hs b/testsuite/tests/driver/options_ghc/Mod_fobject_code.hs new file mode 100644 index 0000000000..f63e6f4bf2 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_fobject_code.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -fobject-code #-} + +module Mod_fobject_code where + +d :: Int +d = 7 diff --git a/testsuite/tests/driver/options_ghc/Mod_top.hs b/testsuite/tests/driver/options_ghc/Mod_top.hs new file mode 100644 index 0000000000..10bc33d909 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/Mod_top.hs @@ -0,0 +1,6 @@ +module Mod_top where + +import Mod_fasm +import Mod_fllvm +import Mod_fbyte_code +import Mod_fobject_code diff --git a/testsuite/tests/driver/options_ghc/all.T b/testsuite/tests/driver/options_ghc/all.T new file mode 100644 index 0000000000..73202f85cc --- /dev/null +++ b/testsuite/tests/driver/options_ghc/all.T @@ -0,0 +1,44 @@ +# Tests for various scenarios in multi module compilation when code generation +# options (-fasm, -fllvm, -fobject-code, -fbyte-code) are used via OPTIONS_GHC +# pragma +# (Only one of the llvm way is sufficient to test these) + +# Basic working of overriding 'backend' via OPTIONS_GHC +test('options_ghc_fasm_fllvm', + [ when(fast(), skip), + only_ways(['llvm', 'ghci']), + extra_files(['Mod_fasm.hs', 'Mod_fllvm.hs', 'Mod_fasm_fllvm.hs'])], + multimod_compile, + ['Mod_fasm_fllvm', '']) + +# Test that llvm is indeed getting used +test('options_ghc_fasm_fllvm_2', + [ when(fast(), skip), + only_ways(['llvm']), + extra_files(['Mod_fasm.hs', 'Mod_fllvm.hs', 'Mod_fasm_fllvm.hs'])], + multimod_compile_fail, + ['Mod_fasm_fllvm', '-optlc -SOMETHING_INVALID']) + +# This should compile, as llvm should not be used with -fasm override +test('options_ghc_fasm', + [ when(fast(), skip), + only_ways(['llvm']), + extra_files(['Mod_fasm.hs'])], + multimod_compile, + ['Mod_fasm', '-optlc -SOMETHING_INVALID']) + +# Should cause object-code creation +test('options_ghc_fobject-code', + [ when(fast(), skip), + only_ways(['ghci']), + extra_files(['Mod_fasm.hs', 'Mod_fllvm.hs', 'Mod_fbyte_code.hs', 'Mod_fobject_code.hs', 'Mod_top.hs', 'Load_Mod_top.script'])], + ghci_script, + ['Load_Mod_top.script']) + +# Should override the -fbyte-code in normal compile +test('options_ghc_fbyte-code', + [ when(fast(), skip), + only_ways(['llvm']), + extra_files(['Mod_fasm.hs', 'Mod_fllvm.hs', 'Mod_fbyte_code.hs', 'Mod_fobject_code.hs', 'Mod_top.hs'])], + multimod_compile, + ['Mod_top', ''])
\ No newline at end of file diff --git a/testsuite/tests/driver/options_ghc/options_ghc_fasm.stderr b/testsuite/tests/driver/options_ghc/options_ghc_fasm.stderr new file mode 100644 index 0000000000..643bc8436e --- /dev/null +++ b/testsuite/tests/driver/options_ghc/options_ghc_fasm.stderr @@ -0,0 +1 @@ +[1 of 1] Compiling Mod_fasm ( Mod_fasm.hs, Mod_fasm.o ) diff --git a/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm.stderr b/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm.stderr new file mode 100644 index 0000000000..297098446b --- /dev/null +++ b/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm.stderr @@ -0,0 +1,3 @@ +[1 of 3] Compiling Mod_fasm ( Mod_fasm.hs, Mod_fasm.o ) +[2 of 3] Compiling Mod_fllvm ( Mod_fllvm.hs, Mod_fllvm.o ) +[3 of 3] Compiling Mod_fasm_fllvm ( Mod_fasm_fllvm.hs, Mod_fasm_fllvm.o ) diff --git a/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm_2.stderr b/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm_2.stderr new file mode 100644 index 0000000000..0565569138 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/options_ghc_fasm_fllvm_2.stderr @@ -0,0 +1,5 @@ +[1 of 3] Compiling Mod_fasm ( Mod_fasm.hs, Mod_fasm.o ) +[2 of 3] Compiling Mod_fllvm ( Mod_fllvm.hs, Mod_fllvm.o ) +llc: Unknown command line argument '-SOMETHING_INVALID'. Try: 'llc --help' +llc: Did you mean '-I'? +`llc' failed in phase `LLVM Compiler'. (Exit code: 1) diff --git a/testsuite/tests/driver/options_ghc/options_ghc_fbyte-code.stderr b/testsuite/tests/driver/options_ghc/options_ghc_fbyte-code.stderr new file mode 100644 index 0000000000..c3703c8421 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/options_ghc_fbyte-code.stderr @@ -0,0 +1,5 @@ +[1 of 5] Compiling Mod_fasm ( Mod_fasm.hs, Mod_fasm.o ) +[2 of 5] Compiling Mod_fbyte_code ( Mod_fbyte_code.hs, Mod_fbyte_code.o ) +[3 of 5] Compiling Mod_fllvm ( Mod_fllvm.hs, Mod_fllvm.o ) +[4 of 5] Compiling Mod_fobject_code ( Mod_fobject_code.hs, Mod_fobject_code.o ) +[5 of 5] Compiling Mod_top ( Mod_top.hs, Mod_top.o ) diff --git a/testsuite/tests/driver/options_ghc/options_ghc_fobject-code.stdout b/testsuite/tests/driver/options_ghc/options_ghc_fobject-code.stdout new file mode 100644 index 0000000000..9296212d06 --- /dev/null +++ b/testsuite/tests/driver/options_ghc/options_ghc_fobject-code.stdout @@ -0,0 +1,5 @@ +Mod_fasm ( Mod_fasm.hs, interpreted ) +Mod_fbyte_code ( Mod_fbyte_code.hs, interpreted ) +Mod_fllvm ( Mod_fllvm.hs, interpreted ) +Mod_fobject_code ( Mod_fobject_code.hs, Mod_fobject_code.o ) +Mod_top ( Mod_top.hs, interpreted ) |