Skip to content
Snippets Groups Projects
Commit a71edf5f authored by dmp's avatar dmp Committed by Ian Lynagh
Browse files

Hide STG register declarations for LLVM C compilers

This commit swaps the import order of Rts.h and Stg.h in
StgCRun.c for non-SPARC architectures. Swapping the import
order prevents the declaration of the global registers thus
allowing the GHC runtime to be compiled by LLVM-based C
compilers.

LLVM-base C compilers cannot use the global register
declarations (for R1, R2, etc.) because they use
GCC-specific extensions. The declarations are not needed in
StgCRun.c except for the SPARC architecture. The other
architectures use hand-written assembly that accesses the
appropriate register directly.
parent bced2640
No related branches found
No related tags found
No related merge requests found
...@@ -29,12 +29,24 @@ ...@@ -29,12 +29,24 @@
#include "PosixSource.h" #include "PosixSource.h"
#include "ghcconfig.h" #include "ghcconfig.h"
#ifdef sparc_HOST_ARCH
/* include Stg.h first because we want real machine regs in here: we /* 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. * have to get the value of R1 back from Stg land to C land intact.
*/ */
#define IN_STGCRUN 1 #define IN_STGCRUN 1
#include "Stg.h" #include "Stg.h"
#include "Rts.h" #include "Rts.h"
#else
/* The other architectures do not require the actual register macro definitions
* here because they use hand written assembly to implement the StgRun
* function. Including Stg.h first will define the R1 values using GCC specific
* techniques, which we don't want for LLVM based C compilers. Since we don't
* actually need the real machine register definitions here, we include the
* headers in the opposite order to allow LLVM-based C compilers to work.
*/
#include "Rts.h"
#include "Stg.h"
#endif
#include "StgRun.h" #include "StgRun.h"
#include "Capability.h" #include "Capability.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment