Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Decking
GHC
Commits
b9c6fd72
Commit
b9c6fd72
authored
Oct 08, 2013
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use dynamic linking only if the GHC package is compiled with -dynamic (#8376)
parent
996206b1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
19 deletions
+48
-19
compiler/ghc.mk
compiler/ghc.mk
+0
-6
compiler/ghci/Linker.lhs
compiler/ghci/Linker.lhs
+7
-7
compiler/main/DynFlags.hs
compiler/main/DynFlags.hs
+19
-3
includes/Rts.h
includes/Rts.h
+10
-0
includes/rts/prof/CCS.h
includes/rts/prof/CCS.h
+0
-3
rts/RtsUtils.c
rts/RtsUtils.c
+11
-0
rts/ghc.mk
rts/ghc.mk
+1
-0
No files found.
compiler/ghc.mk
View file @
b9c6fd72
...
...
@@ -110,12 +110,6 @@ ifeq "$(UseLibFFIForAdjustors)" "YES"
@
echo
'cLibFFI = True'
>>
$@
else
@
echo
'cLibFFI = False'
>>
$@
endif
@
echo
'cDYNAMIC_GHC_PROGRAMS :: Bool'
>>
$@
ifeq
"$(DYNAMIC_GHC_PROGRAMS)" "YES"
@
echo
'cDYNAMIC_GHC_PROGRAMS = True'
>>
$@
else
@
echo
'cDYNAMIC_GHC_PROGRAMS = False'
>>
$@
endif
# Note that GhcThreaded just reflects the Makefile variable setting.
# In particular, the stage1 compiler is never actually compiled with
...
...
compiler/ghci/Linker.lhs
View file @
b9c6fd72
...
...
@@ -413,14 +413,14 @@ preloadLib dflags lib_paths framework_paths lib_spec
preload_static _paths name
= do b <- doesFileExist name
if not b then return False
else do if
cDYNAMIC_GHC_PROGRAMS
else do if
dynamicGhc
then dynLoadObjs dflags [name]
else loadObj name
return True
preload_static_archive _paths name
= do b <- doesFileExist name
if not b then return False
else do if
cDYNAMIC_GHC_PROGRAMS
else do if
dynamicGhc
then panic "Loading archives not supported"
else loadArchive name
return True
...
...
@@ -496,7 +496,7 @@ checkNonStdWay dflags srcspan =
-- whereas we have __stginit_base_Prelude_.
else if objectSuf dflags == normalObjectSuffix && not (null haskellWays)
then failNonStd dflags srcspan
else return $ Just $ if
cDYNAMIC_GHC_PROGRAMS
else return $ Just $ if
dynamicGhc
then "dyn_o"
else "o"
where haskellWays = filter (not . wayRTSOnly) (ways dflags)
...
...
@@ -509,7 +509,7 @@ failNonStd dflags srcspan = dieWith dflags srcspan $
ptext (sLit "Dynamic linking required, but this is a non-standard build (eg. prof).") $$
ptext (sLit "You need to build the program twice: once the") <+> ghciWay <+> ptext (sLit "way, and then") $$
ptext (sLit "in the desired way using -osuf to set the object file suffix.")
where ghciWay = if
cDYNAMIC_GHC_PROGRAMS
where ghciWay = if
dynamicGhc
then ptext (sLit "dynamic")
else ptext (sLit "normal")
...
...
@@ -783,7 +783,7 @@ dynLinkObjs dflags pls objs = do
unlinkeds = concatMap linkableUnlinked new_objs
wanted_objs = map nameOfObject unlinkeds
if
cDYNAMIC_GHC_PROGRAMS
if
dynamicGhc
then do dynLoadObjs dflags wanted_objs
return (pls1, Succeeded)
else do mapM_ loadObj wanted_objs
...
...
@@ -970,7 +970,7 @@ unload_wkr _ linkables pls
| linkableInSet lnk keep_linkables = return True
-- We don't do any cleanup when linking objects with the dynamic linker.
-- Doing so introduces extra complexity for not much benefit.
|
cDYNAMIC_GHC_PROGRAMS
= return False
|
dynamicGhc
= return False
| otherwise
= do mapM_ unloadObj [f | DotO f <- linkableUnlinked lnk]
-- The components of a BCO linkable may contain
...
...
@@ -1182,7 +1182,7 @@ locateLib dflags is_hs dirs lib
--
= findDll `orElse` findArchive `orElse` tryGcc `orElse` assumeDll
| not
cDYNAMIC_GHC_PROGRAMS
| not
dynamicGhc
-- When the GHC package was not compiled as dynamic library
-- (=DYNAMIC not set), we search for .o libraries or, if they
-- don't exist, .a libraries.
...
...
compiler/main/DynFlags.hs
View file @
b9c6fd72
...
...
@@ -117,6 +117,7 @@ module DynFlags (
-- Only in stage 2 can we be sure that the RTS
-- exposes the appropriate runtime boolean
rtsIsProfiled
,
dynamicGhc
,
#
endif
#
include
"
../
includes
/
dist
-
derivedconstants
/
header
/
GHCConstantsHaskellExports
.
hs
"
...
...
@@ -166,6 +167,7 @@ import FastString
import
Outputable
#
ifdef
GHCI
import
Foreign.C
(
CInt
(
..
)
)
import
System.IO.Unsafe
(
unsafeDupablePerformIO
)
#
endif
import
{-#
SOURCE
#-
}
ErrUtils
(
Severity
(
..
),
MsgDoc
,
mkLocMessage
)
...
...
@@ -1444,7 +1446,7 @@ defaultWays settings = if pc_DYNAMIC_BY_DEFAULT (sPlatformConstants settings)
else
[]
interpWays
::
[
Way
]
interpWays
=
if
cDYNAMIC_GHC_PROGRAMS
interpWays
=
if
dynamicGhc
then
[
WayDyn
]
else
[]
...
...
@@ -3069,7 +3071,21 @@ glasgowExtsFlags = [
foreign
import
ccall
unsafe
"rts_isProfiled"
rtsIsProfiledIO
::
IO
CInt
rtsIsProfiled
::
Bool
rtsIsProfiled
=
unsafePerformIO
rtsIsProfiledIO
/=
0
rtsIsProfiled
=
unsafeDupablePerformIO
rtsIsProfiledIO
/=
0
#
endif
#
ifdef
GHCI
-- Consult the RTS to find whether GHC itself has been built with
-- dynamic linking. This can't be statically known at compile-time,
-- because we build both the static and dynamic versions together with
-- -dynamic-too.
foreign
import
ccall
unsafe
"rts_isDynamic"
rtsIsDynamicIO
::
IO
CInt
dynamicGhc
::
Bool
dynamicGhc
=
unsafeDupablePerformIO
rtsIsDynamicIO
/=
0
#
else
dynamicGhc
::
Bool
dynamicGhc
=
False
#
endif
setWarnSafe
::
Bool
->
DynP
()
...
...
@@ -3535,7 +3551,7 @@ compilerInfo dflags
(
"Support parallel --make"
,
"YES"
),
(
"Dynamic by default"
,
if
dYNAMIC_BY_DEFAULT
dflags
then
"YES"
else
"NO"
),
(
"GHC Dynamic"
,
if
cDYNAMIC_GHC_PROGRAMS
(
"GHC Dynamic"
,
if
dynamicGhc
then
"YES"
else
"NO"
),
(
"Leading underscore"
,
cLeadingUnderscore
),
(
"Debug on"
,
show
debugIsOn
),
...
...
includes/Rts.h
View file @
b9c6fd72
...
...
@@ -258,6 +258,16 @@ void stg_exit(int n) GNU_ATTRIBUTE(__noreturn__);
int
stg_sig_install
(
int
,
int
,
void
*
);
#endif
/* -----------------------------------------------------------------------------
Ways
-------------------------------------------------------------------------- */
// Returns non-zero if the RTS is a profiling version
int
rts_isProfiled
(
void
);
// Returns non-zero if the RTS is a dynamically-linked version
int
rts_isDynamic
(
void
);
/* -----------------------------------------------------------------------------
RTS Exit codes
-------------------------------------------------------------------------- */
...
...
includes/rts/prof/CCS.h
View file @
b9c6fd72
...
...
@@ -14,9 +14,6 @@
#ifndef RTS_PROF_CCS_H
#define RTS_PROF_CCS_H
// Returns non-zero if the RTS is a profiling version
int
rts_isProfiled
(
void
);
/* -----------------------------------------------------------------------------
* Data Structures
* ---------------------------------------------------------------------------*/
...
...
rts/RtsUtils.c
View file @
b9c6fd72
...
...
@@ -304,6 +304,17 @@ int rts_isProfiled(void)
#endif
}
// Provides a way for Haskell programs to tell whether they're
// dynamically-linked or not.
int
rts_isDynamic
(
void
)
{
#ifdef DYNAMIC
return
1
;
#else
return
0
;
#endif
}
// Used for detecting a non-empty FPU stack on x86 (see #4914)
void
checkFPUStack
(
void
)
{
...
...
rts/ghc.mk
View file @
b9c6fd72
...
...
@@ -139,6 +139,7 @@ ifneq "$$(findstring dyn, $1)" ""
ifeq
"$$(HostOS_CPP)" "mingw32"
rts_dist_$1_CC_OPTS
+=
-DCOMPILING_WINDOWS_DLL
endif
rts_dist_$1_CC_OPTS
+=
-DDYNAMIC
endif
ifneq
"$$(findstring thr, $1)" ""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment