diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-10-01 10:36:59 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-06 10:57:24 -0400 |
commit | 9af29e7fa81a8696a2d829a0ecbebcbc8be5badd (patch) | |
tree | 35b7bc67fd42dfc298befe77912899e62c90d5ec | |
parent | 7fc986e1201bf1dc8f84fef9051be1d9429064b3 (diff) | |
download | haskell-9af29e7fa81a8696a2d829a0ecbebcbc8be5badd.tar.gz |
Disable -dynamic-too if -dynamic is also passed
Before if you passed both options then you would generate two identical
hi/dyn_hi and o/dyn_o files, both in the dynamic way. It's better to
warn this is happening rather than duplicating the work and causing
potential confusion.
-dynamic-too should only be used with -static.
Fixes #20436
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 6 | ||||
-rw-r--r-- | docs/users_guide/phases.rst | 2 | ||||
-rw-r--r-- | testsuite/tests/driver/T20436/A.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/driver/T20436/Makefile | 23 | ||||
-rw-r--r-- | testsuite/tests/driver/T20436/T20436.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/driver/T20436/all.T | 1 |
6 files changed, 36 insertions, 0 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index f69f2da243..12f0e8be33 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -4609,6 +4609,12 @@ makeDynFlagsConsistent dflags = let dflags' = gopt_unset dflags Opt_BuildDynamicToo warn = "-dynamic-too is not supported on Windows" in loop dflags' warn + -- Disable -dynamic-too if we are are compiling with -dynamic already, otherwise + -- you get two dynamic object files (.o and .dyn_o). (#20436) + | ways dflags `hasWay` WayDyn && gopt Opt_BuildDynamicToo dflags + = let dflags' = gopt_unset dflags Opt_BuildDynamicToo + warn = "-dynamic-too is ignored when using -dynamic" + in loop dflags' warn -- Via-C backend only supports unregisterised ABI. Switch to a backend -- supporting it if possible. diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst index 6833ce36d7..0c334f037f 100644 --- a/docs/users_guide/phases.rst +++ b/docs/users_guide/phases.rst @@ -707,6 +707,8 @@ Options affecting code generation and ``-dynhisuf`` are the counterparts of ``-o``, ``-osuf``, and ``-hisuf`` respectively, but applying to the dynamic compilation. + ``-dynamic-too`` is ignored if :ghc-flag:`-dynamic` is also specified. + .. ghc-flag:: -split-objs :shortdesc: Split generated object files into smaller files :type: dynamic diff --git a/testsuite/tests/driver/T20436/A.hs b/testsuite/tests/driver/T20436/A.hs new file mode 100644 index 0000000000..d843c00b78 --- /dev/null +++ b/testsuite/tests/driver/T20436/A.hs @@ -0,0 +1 @@ +module A where diff --git a/testsuite/tests/driver/T20436/Makefile b/testsuite/tests/driver/T20436/Makefile new file mode 100644 index 0000000000..de28eab08d --- /dev/null +++ b/testsuite/tests/driver/T20436/Makefile @@ -0,0 +1,23 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Test for passing -dynamic and -dynamic-too together + +checkExists = [ -f $1 ] || echo $1 missing +checkNotExists = [ ! -f $1 ] || echo $1 not missing + +clean: + rm -f *.o + rm -f *.hi + rm -f *.dyn_o + rm -f *.dyn_hi + +T20436: clean + '$(TEST_HC)' $(TEST_HC_OPTS) -dynamic -dynamic-too -v0 A.hs + $(call checkExists,A.hi) + $(call checkExists,A.o) + $(call checkNotExists,A.dyn_hi) + $(call checkNotExists,A.dyn_o) + + diff --git a/testsuite/tests/driver/T20436/T20436.stderr b/testsuite/tests/driver/T20436/T20436.stderr new file mode 100644 index 0000000000..1fda220263 --- /dev/null +++ b/testsuite/tests/driver/T20436/T20436.stderr @@ -0,0 +1,3 @@ + +when making flags consistent: warning: + -dynamic-too is ignored when using -dynamic diff --git a/testsuite/tests/driver/T20436/all.T b/testsuite/tests/driver/T20436/all.T new file mode 100644 index 0000000000..3a2aa6a46a --- /dev/null +++ b/testsuite/tests/driver/T20436/all.T @@ -0,0 +1 @@ +test('T20436', [extra_files(['A.hs']), when(opsys('mingw32'), skip)], makefile_test, []) |