summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/main/DynFlags.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 071c16ca80..918b1ae022 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -1123,6 +1123,13 @@ wayGeneralFlags _ (WayCustom {}) = []
wayGeneralFlags _ WayThreaded = []
wayGeneralFlags _ WayDebug = []
wayGeneralFlags _ WayDyn = [Opt_PIC]
+ -- We could get away without adding -fPIC when compiling the
+ -- modules of a program that is to be linked with -dynamic; the
+ -- program itself does not need to be position-independet, only
+ -- the libraries need to be. HOWEVER, GHCi links objects into a
+ -- .so before loading the .so using the system linker. Since only
+ -- PIC objects can be linked into a .so, we have to compile even
+ -- modules of the main program with -fPIC when using -dynamic.
wayGeneralFlags _ WayProf = [Opt_SccProfilingOn]
wayGeneralFlags _ WayEventLog = []
wayGeneralFlags _ WayPar = [Opt_Parallel]