summaryrefslogtreecommitdiff
path: root/includes/Stg.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix unregisterised buildwip/gc/nonmoving-concurrentBen Gamari2019-10-221-17/+0
| | | | | | This required some fiddling around with the location of forward declarations since the C sources generated by GHC's C backend only includes Stg.h.
* Nonmoving: Ensure write barrier vanishes in non-threaded RTSBen Gamari2019-10-211-0/+18
|
* Simplify Configure in a few waysJohn Ericson2019-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - No need to distinguish between gcc-llvm and clang. First of all, gcc-llvm is quite old and surely unmaintained by now. Second of all, none of the code actually care about that distinction! Now, it does make sense to consider C multiple frontends for LLVMs in the form of clang vs clang-cl (same clang, yes, but tweaked interface). But this is better handled in terms of "gccish vs mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't think it is useful saving the existing code for that. - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in mk/config.h the normal way, rather than hacking it post-hoc. No point keeping these special cases around for now reason. - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`. - Abstract check + flag override for unregisterised and tables next to code. Oh, and as part of the above I also renamed/combined some variables where it felt appropriate. - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other Camal case ones. It was never about gcc-llvm, or Apple's renamed clang, to be clear. - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the other all-caps snake case ones. llvm_CC_FLAVOR was just silly indirection *and* an odd name to boot.
* Deduplicate `HaskellMachRegs.h` and `RtsMachRegs.h` headersJohn Ericson2019-09-171-1/+1
| | | | | | | Until 0472f0f6a92395d478e9644c0dbd12948518099f there was a meaningful host vs target distinction (though it wasn't used right, in genapply). After that, they did not differ in meaningful ways, so it's best to just only keep one.
* Update Wiki URLs to point to GitLabTakenobu Tani2019-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-2/+2
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* rts: Disable fallthrough attribute when compiling with ClangBen Gamari2018-12-111-1/+5
| | | | | | Apparently clang doesn't enable implicitly fallthrough warnings by default http://llvm.org/viewvc/llvm-project?revision=167655&view=revision when compiling C and the attribute cause warnings of their own (#16019).
* rts: Add FALLTHROUGH macroBen Gamari2018-11-021-0/+7
| | | | | | | | | | | | | | | | | | | Instead of using the GCC `/* fallthrough */` syntax we now use the `__attribute__((fallthrough))`, which Phyx says should be more portable than the former. Also adds a missing fallthrough annotation in the MachO linker, fixing #14613. Reviewers: erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #14613 Differential Revision: https://phabricator.haskell.org/D5292
* includes: Allow headers to be built with C++11 compilersBen Gamari2018-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Fixes #14784. Note that C++11 is quite conservative; we could likely accept C++03 as well. Test Plan: ``` $ cat >hi.c <<EOF #include <Rts.h> EOF $ g++ -std=c++11 hi.c ``` Reviewers: simonmar, hvr Subscribers: rwbarton, carter GHC Trac Issues: #14784 Differential Revision: https://phabricator.haskell.org/D5244
* Disable GNUC_ATTR_HOT when compiling with DEBUGBen Gamari2018-07-271-1/+1
| | | | | | | | | | | | Test Plan: Validate Reviewers: simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D5000
* Fix Windows stack allocations.Tamar Christina2018-01-261-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows we use the function `win32AllocStack` to do stack allocations in 4k blocks and insert a stack check afterwards to ensure the allocation returned a valid block. The problem is this function does something that by C semantics is pointless. The stack allocated value can never escape the function, and the stack isn't used so the compiler just optimizes away the entire function body. After considering a bunch of other possibilities I think the simplest fix is to just disable optimizations for the function. Alternatively inline assembly is an option but the stack check function doesn't have a very portable name as it relies on e.g. `libgcc`. Thanks to Sergey Vinokurov for helping diagnose and test. Test Plan: ./validate Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14669 Differential Revision: https://phabricator.haskell.org/D4343
* includes/Stg.h: '#if sparch_HOST_ARCH' -> '#if defined(sparch_HOST_ARCH)'Sergei Trofimovich2017-05-141-1/+1
| | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Prefer #if defined to #ifdefBen Gamari2017-04-281-3/+3
| | | | Our new CPP linter enforces this.
* Enable new warning for fragile/incorrect CPP #if usageErik de Castro Lopo2017-04-281-3/+3
| | | | | | | | | | | | | | | | The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
* compiler/cmm/PprC.hs: constify labels in .rodataSergei Trofimovich2017-04-241-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider one-line module module B (v) where v = "hello" in -fvia-C mode it generates code like static char gibberish_str[] = "hello"; It resides in data section (precious resource on ia64!). The patch switches genrator to emit: static const char gibberish_str[] = "hello"; Other types if symbols that gained 'const' qualifier are: - info tables (from haskell and CMM) - static reference tables (from haskell and CMM) Cleanups along the way: - fixed info tables defined in .cmm to reside in .rodata - split out closure declaration into 'IC_' / 'EC_' - added label declaration (based on label type) right before each label definition (based on section type) so that C compiler could check if declaration and definition matches at definition site. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ran testsuite on unregisterised x86_64 compiler Reviewers: simonmar, ezyang, austin, bgamari, erikd Reviewed By: bgamari, erikd Subscribers: rwbarton, thomie GHC Trac Issues: #8996 Differential Revision: https://phabricator.haskell.org/D3481
* cpp: Use #pragma once instead of #ifndef guardsBen Gamari2017-04-231-4/+1
| | | | | | | | | | | | | | This both says what we mean and silences a bunch of spurious CPP linting warnings. This pragma is supported by all CPP implementations which we support. Reviewers: austin, erikd, simonmar, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3482
* UNREG: remove dead code around -split-objsSergei Trofimovich2017-04-161-14/+0
| | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Revert "Enable new warning for fragile/incorrect CPP #if usage"Ben Gamari2017-04-051-3/+3
| | | | | | | | This is causing too much platform dependent breakage at the moment. We will need a more rigorous testing strategy before this can be merged again. This reverts commit 7e340c2bbf4a56959bd1e95cdd1cfdb2b7e537c2.
* Enable new warning for fragile/incorrect CPP #if usageErik de Castro Lopo2017-04-051-3/+3
| | | | | | | | | | | | | | | | The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
* UNREG: add a forward declaration for local literalsSergei Trofimovich2017-01-291-0/+1
| | | | | | | | | | | | | When toplevel literals don't have a way to be exported from module GHC infers their labels as static. Example from GHC.Arr: static char rdVA_bytes[] = " out of range "; When this label is used in module internally we also need to provide it's forward declaration. Signed-off-by: Sergei Trofimovich <siarheit@google.com>
* UNREG: fix "_bytes" string literal forward declarationSergei Trofimovich2017-01-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Typical UNREG build failure looks like that: ghc-unreg/includes/Stg.h:226:46: error: note: in definition of macro 'EI_' #define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) ^ | 226 | #define EI_(X) extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8)) | ^ /tmp/ghc10489_0/ghc_3.hc:1754:6: error: note: previous definition of 'ghczmprim_GHCziTypes_zdtcTyCon2_bytes' was here char ghczmprim_GHCziTypes_zdtcTyCon2_bytes[] = "TyCon"; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 1754 | char ghczmprim_GHCziTypes_zdtcTyCon2_bytes[] = "TyCon"; | ^ As we see here "_bytes" string literals are defined as 'char []' array, not 'StgWord []'. The change special-cases "_bytes" string literals to have correct declaration type. Signed-off-by: Sergei Trofimovich <siarheit@google.com>
* Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 modeHerbert Valerio Riedel2016-03-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first phase of addressing #11757 which aims to make C99 support a base-line requirement for GHC and clean up the code-base to use C99 facilities when sensible. This patch exploits the logic/heuristic used by `AC_PROG_CC_C99` to determine the flags needed in case the C compiler isn't able to compile C99 code in its current mode. We can't use `AC_PROG_CC_C99` directly though because GHC's build-system expects CC to contain a filename without any flags, while `AC_PROG_CC_C99` would e.g. result in `CC="gcc -std=gnu99"`. Morever, we support different `CC`s for stage0/1/2, so we need a version of `AC_PROG_CC_C99` for which we can specify the `CC`/`CFLAGS` variables to operate on. This is what `FP_SET_CFLAGS_C99` does. Note that Clang has been defaulting to C99+ for a long time, while GCC 5 defaults to C99+ as well. So this has mostly an affect on older GCCs versions prior to 5.0 and possibly compilers other than GCC/Clang (which are not officially supported for building GHC anyway). Reviewers: kgardas, erikd, bgamari, austin Reviewed By: erikd Differential Revision: https://phabricator.haskell.org/D2045
* Remove now pointless INLINE_ME macroHerbert Valerio Riedel2016-03-271-1/+0
| | | | | | | | | At some point there may have been a reason for the `INLINE_ME` macro, but not anymore... Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D2041
* RTS: Fix & refactor "portable inline" macrosHerbert Valerio Riedel2016-03-261-37/+39
| | | | | | | | | | | | | | | | | | | | | | | Turns out the current macros for gnu90-style inline semantics stopped working with GCC 5 (and possibly also with Apple's GCC) which switched on `__GNUC_STDC_INLINE__` by default falling back to using the suboptimal `static inline` mode. However, C99 supports an equivalent (as far as our use-case is concerned) `extern inline` mode. See also http://www.greenend.org.uk/rjk/tech/inline.html for a write-up of gnu90 vs C99 semantics. This patch also removes the MSVC case as VS2015 is supposed to finally catch up to C99 (and C11), so we don't need any special care for MSVC anymore. Reviewed By: erikd, austin Differential Revision: https://phabricator.haskell.org/D2039
* Split external symbol prototypes (EF_) (Trac #11395)Sergei Trofimovich2016-03-081-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before the patch both Cmm and C symbols were declared with 'EF_' macro: #define EF_(f) extern StgFunPtr f() but for Cmm symbols we know exact prototypes. The patch splits there prototypes in to: #define EFF_(f) void f() /* See Note [External function prototypes] */ #define EF_(f) StgFunPtr f(void) Cmm functions are 'EF_' (External Functions), C functions are 'EFF_' (External Foreign Functions). While at it changed external C function prototype to return 'void' to workaround ghc bug on m68k. Described in detail in Trac #11395. This makes simple tests work on m68k-linux target! Thanks to Michael Karcher for awesome analysis happening in Trac #11395. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: ran "hello world" on m68k successfully Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1975 GHC Trac Issues: #11395
* On AIX we need -D_BSD defined in <Stg.h>Herbert Valerio Riedel2015-12-041-0/+5
| | | | | As otherwise <math.h> includes <stdlib.h> which breaks compilation of .hc files
* includes/Stg.h: define _DEFAULT_SOURCE for glibc-2.20Sergei Trofimovich2014-11-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | _BSD_SOURCE we are using for 'gamma()' and friends was deprecated in glibc-2.20 in favour of '_DEFAULT_SOURCE'. gcc says: In file included from /usr/include/math.h:26:0: 0, from includes/Stg.h:69, from /tmp/ghc19488_0/ghc19488_2.hc:3: /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp] # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" ^ Patch fixes testsuite failures on UNREG (stderr are not cluttered by warnings anymore). Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* includes/Stg.h: remove unused 'wcStore' inlineSergei Trofimovich2014-09-011-18/+0
| | | | | | | | | | | | | | | | | | | | | Summary: Commit reverts never used addition in cbd29e0a23bb8e15033edae123d6c8fbe9740c97 I think it might make sense to take advantage of TSO/RMO/PSO models tome day. But it's highly architecture/model-dependent thus it better be implemented in per-arch Native CodeGen. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: build-tested on UNREG-amd64 Reviewers: simonmar, austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D186
* PprC: cleanup: don't emit 'FB_' / 'FE_' in via-CSergei Trofimovich2014-08-291-2/+0
| | | | | | | No need to emit (now empty) those special markers. Markers were needed only in registerised -fvia-C mode. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* [ci skip] includes: detabify/dewhitespace Stg.hAustin Seipp2014-08-201-1/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add comments to explain the change to EF_ (Trac #8965)Simon Peyton Jones2014-04-241-1/+29
|
* Be less untruthful about the prototypes of external functionsColin Watson2014-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GHC's generated C code uses dummy prototypes for foreign imports. At the moment these all claim to be (void), i.e. functions of zero arguments. On most platforms this doesn't matter very much: calls to these functions put the parameters in the usual places anyway, and (with the exception of varargs) things just work. However, the ELFv2 ABI on ppc64 optimises stack allocation (http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01149.html): a call to a function that has a prototype, is not varargs, and receives all parameters in registers rather than on the stack does not require the caller to allocate an argument save area. The incorrect prototypes cause GCC to believe that all functions declared this way can be called without an argument save area, but if the callee has sufficiently many arguments then it will expect that area to be present, and will thus corrupt the caller's stack. This happens in particular with calls to runInteractiveProcess in libraries/process/cbits/runProcess.c. The simplest fix appears to be to declare these external functions with an unspecified argument list rather than a void argument list. This is no worse for platforms that don't care either way, and allows a successful bootstrap of GHC 7.8 on little-endian Linux ppc64 (which uses the ELFv2 ABI). Fixes #8965 Signed-off-by: Colin Watson <cjwatson@debian.org> Signed-off-by: Austin Seipp <austin@well-typed.com>
* includes/Stg.h: add declarations for hs_popcnt and frindsSergei Trofimovich2014-02-171-0/+1
| | | | | | | | | | | | | | This fixes most of implicit function declarations emitted C codegen in UNREG mode. Found by adding the following to mk/build.mk: SRC_CC_OPTS += -Werror=implicit-function-declaration SRC_HC_OPTS += -optc-Werror=implicit-function-declaration Issue #8748 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-011-1/+1
|
* Remove most of TailCalls.hSimon Marlow2012-12-131-4/+3
| | | | it was only needed for registerised compilation.
* Start separating out the RTS and Haskell imports of MachRegs.hIan Lynagh2012-08-061-1/+1
| | | | No functional differences yet
* Fix ASSIGN_DBL on Win64Ian Lynagh2012-03-231-4/+4
| | | | | We were comparing ALIGNMENT_DOUBLE to ALIGNMENT_LONG, but really we cared about W_ values, and sizeof(long) /= sizeof(void *) on Win64
* Typo in commentIan Lynagh2012-03-111-1/+1
|
* Tabs -> SpacesDavid Terei2011-11-221-43/+43
|
* mergeSimon Marlow2011-11-221-1/+4
|\
| * Enable pthread_getspecific() tls for LLVM compilerDavid M Peixotto2011-10-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | LLVM does not support the __thread attribute for thread local storage and may generate incorrect code for global register variables. We want to allow building the runtime with LLVM-based compilers such as llvm-gcc and clang, particularly for MacOS. This patch changes the gct variable used by the garbage collector to use pthread_getspecific() for thread local storage when an llvm based compiler is used to build the runtime.
* | Put the target platform in the settings fileIan Lynagh2011-10-191-2/+0
|/
* ARMv5 compatibility for registerized runtime changes.Stephen Blackheath2011-08-101-0/+2
| | | | | | | When the bootstrap compiler does not include this patch, you must add this line to mk/build.mk, otherwise the ARM architecture cannot be detected due to a -undef option given to the C pre-processor. SRC_HC_OPTS = -pgmP 'gcc -E -traditional'
* define INFINITY and NAN if they don't exist (#2929)Simon Marlow2010-01-271-0/+21
|
* put back F_, just in case the via-C codegen uses itSimon Marlow2009-09-101-0/+1
|
* Tidy up file headers and copyrights; point to the wiki for docsSimon Marlow2009-08-251-9/+12
| | | | | | | I've updated the wiki page about the RTS headers http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes to reflect the new layout and explain some of the rationale. All the header files now point to this page.
* RTS tidyup sweep, first phaseSimon Marlow2009-08-021-32/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.
* Define _BSD_SOURCE in Stg.hIan Lynagh2009-06-091-0/+4
| | | | | This means that, on Linux, we get functions like gamma defined when we #include math.h
* Remove old GUM/GranSim codeSimon Marlow2009-06-021-2/+0
|
* GHC new build system megapatchIan Lynagh2009-04-261-1/+1
|