diff options
author | Simon Marlow <simonmar@microsoft.com> | 2008-04-02 05:14:12 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2008-04-02 05:14:12 +0000 |
commit | c245355e6f2c7b7c95e9af910c4d420e13af9413 (patch) | |
tree | e8309f467b8bea2501e9f7de7af86fbfc22e0a67 /rts | |
parent | ab5c770bed51f08d56a0d61086988053b21aa461 (diff) | |
download | haskell-c245355e6f2c7b7c95e9af910c4d420e13af9413.tar.gz |
Do not #include external header files when compiling via C
This has several advantages:
- -fvia-C is consistent with -fasm with respect to FFI declarations:
both bind to the ABI, not the API.
- foreign calls can now be inlined freely across module boundaries, since
a header file is not required when compiling the call.
- bootstrapping via C will be more reliable, because this difference
in behavour between the two backends has been removed.
There is one disadvantage:
- we get no checking by the C compiler that the FFI declaration
is correct.
So now, the c-includes field in a .cabal file is always ignored by
GHC, as are header files specified in an FFI declaration. This was
previously the case only for -fasm compilations, now it is also the
case for -fvia-C too.
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Exception.cmm | 2 | ||||
-rw-r--r-- | rts/HCIncludes.h | 24 | ||||
-rw-r--r-- | rts/Linker.c | 2 | ||||
-rw-r--r-- | rts/Makefile | 10 | ||||
-rw-r--r-- | rts/PrimOps.cmm | 2 | ||||
-rw-r--r-- | rts/StgCRun.c | 2 | ||||
-rw-r--r-- | rts/StgMiscClosures.cmm | 10 | ||||
-rw-r--r-- | rts/StgRun.h | 2 | ||||
-rw-r--r-- | rts/Typeable.c | 2 |
9 files changed, 12 insertions, 44 deletions
diff --git a/rts/Exception.cmm b/rts/Exception.cmm index c2f0dde675..daa8e4fd7f 100644 --- a/rts/Exception.cmm +++ b/rts/Exception.cmm @@ -13,9 +13,7 @@ #include "Cmm.h" #include "RaiseAsync.h" -#ifdef __PIC__ import ghczmprim_GHCziBool_True_closure; -#endif /* ----------------------------------------------------------------------------- Exception Primitives diff --git a/rts/HCIncludes.h b/rts/HCIncludes.h deleted file mode 100644 index 38ca34aac7..0000000000 --- a/rts/HCIncludes.h +++ /dev/null @@ -1,24 +0,0 @@ -/* includes for compiling .cmm files via-C */ -#include "Stg.h" -#include "Rts.h" -#include "RtsFlags.h" -#include "RtsUtils.h" -#include "StgRun.h" -#include "Storage.h" -#include "Schedule.h" -#include "Printer.h" -#include "Sanity.h" -#include "STM.h" -#include "SchedAPI.h" -#include "Timer.h" -#include "ProfHeap.h" -#include "LdvProfile.h" -#include "Profiling.h" -#include "OSThreads.h" -#include "Apply.h" -#include "SMP.h" -#include "RaiseAsync.h" -#include "ThreadLabels.h" -#include "Threads.h" -#include "Prelude.h" -#include "Stable.h" diff --git a/rts/Linker.c b/rts/Linker.c index e2391842a2..59143b9b0e 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -482,7 +482,7 @@ typedef struct _RtsSymbolVal { #define RTS_SYMBOLS \ Maybe_Stable_Names \ - Sym(StgReturn) \ + SymX(StgReturn) \ SymX(stg_enter_info) \ SymX(stg_gc_void_info) \ SymX(__stg_gc_enter_1) \ diff --git a/rts/Makefile b/rts/Makefile index 2a20279382..6fb168824a 100644 --- a/rts/Makefile +++ b/rts/Makefile @@ -152,6 +152,8 @@ SRC_CC_OPTS += $(STANDARD_OPTS) SRC_CC_OPTS += $(GhcRtsCcOpts) SRC_HC_OPTS += $(GhcRtsHcOpts) $(STANDARD_OPTS) -package-name rts +SRC_HC_OPTS += -fvia-C + ifneq "$(GhcWithSMP)" "YES" SRC_CC_OPTS += -DNOSMP SRC_HC_OPTS += -optc-DNOSMP @@ -366,13 +368,7 @@ endif # Compiling the cmm files # ToDo: should we really include Rts.h here? Required for GNU_ATTRIBUTE(). -SRC_HC_OPTS += -I. -\#include HCIncludes.h - -ifeq "$(Windows)" "YES" -PrimOps_HC_OPTS += -\#include '<windows.h>' -\#include win32/AsyncIO.h -else -PrimOps_HC_OPTS += -\#include posix/Itimer.h -endif +SRC_HC_OPTS += -I. # Otherwise the stack-smash handler gets triggered. ifeq "$(TargetOS_CPP)" "openbsd" diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 06628b96f8..99d6475455 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -46,10 +46,10 @@ import __gmpz_xor; import __gmpz_ior; import __gmpz_com; #endif -import base_GHCziIOBase_NestedAtomically_closure; import pthread_mutex_lock; import pthread_mutex_unlock; #endif +import base_GHCziIOBase_NestedAtomically_closure; import EnterCriticalSection; import LeaveCriticalSection; diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 376e824055..a211da3577 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -66,6 +66,8 @@ register double fake_f9 __asm__("$f9"); /* include Stg.h first because we want real machine regs in here: we * have to get the value of R1 back from Stg land to C land intact. */ +// yeuch +#define IN_STGCRUN 1 #include "Stg.h" #include "Rts.h" #include "StgRun.h" diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm index 0a4dbdc561..270c600f7c 100644 --- a/rts/StgMiscClosures.cmm +++ b/rts/StgMiscClosures.cmm @@ -12,11 +12,9 @@ #include "Cmm.h" -#ifdef __PIC__ import pthread_mutex_lock; import base_GHCziBase_Czh_static_info; import base_GHCziBase_Izh_static_info; -#endif import EnterCriticalSection; import LeaveCriticalSection; @@ -608,11 +606,11 @@ CLOSURE(stg_dummy_ret_closure,stg_dummy_ret); * */ #warning Is this correct? _imp is a pointer! -#define Char_hash_static_info _imp__base_GHCziBase_Czh_static -#define Int_hash_static_info _imp__base_GHCziBase_Izh_static +#define Char_hash_static_info _imp__base_GHCziBase_Czh_static_info +#define Int_hash_static_info _imp__base_GHCziBase_Izh_static_info #else -#define Char_hash_static_info base_GHCziBase_Czh_static -#define Int_hash_static_info base_GHCziBase_Izh_static +#define Char_hash_static_info base_GHCziBase_Czh_static_info +#define Int_hash_static_info base_GHCziBase_Izh_static_info #endif diff --git a/rts/StgRun.h b/rts/StgRun.h index da376b4971..12d1475d13 100644 --- a/rts/StgRun.h +++ b/rts/StgRun.h @@ -11,6 +11,4 @@ extern StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg); -RTS_FUN(StgReturn); - #endif /* STGRUN_H */ diff --git a/rts/Typeable.c b/rts/Typeable.c index 66e135ca1f..88151b7d47 100644 --- a/rts/Typeable.c +++ b/rts/Typeable.c @@ -6,8 +6,8 @@ * * ---------------------------------------------------------------------------*/ -#include "RtsTypeable.h" #include "Rts.h" +#include "RtsTypeable.h" static StgPtr typeableStore = 0; #ifdef THREADED_RTS |