Skip to content

Commit

Permalink
Merge branch 'ci'
Browse files Browse the repository at this point in the history
Closes #95

* ci:
  [tests] Use tagged v1 of the github action script
  [tests] Print failing tests seperated by newlines
  [tests] Add a lint test to CI
  [rt/gc] Avoid a compiler warning
  [tests] Fixup incorrect path in github workflow
  [tests] Add a CI step to run the GC tests
  [tests] Use the new setup command for the CI actions
  [tests] Run GC stress tests seperatly
  [tests] Fix a typo in run_tests.sh
  [tests] Set buildtype in github-actions workflow
  [build] Provide examples for BUILD_TYPE with other build settings
  [build] Change the spelling of the values for BUILD_TYPE
  [build] Remove -Wno-error from some example build settings
  [build] Refactor how C and C++ build flags are set
  [build] Remove the MCFLAGS2 make variable
  [tests] Add a job to test building the docs
  [tests] Rename the github-actions workflow "test" to "ci"
  [tests] Test with both GCC and clang in CI
  [rt/gc] Add a constant definition to avoid a magic number
  [rt/gc] Document units of a "len" parameter
  [rt] Make Plasma compile warnings-clean for clang 7
  [rt] Fix errors when using clang
  [build] Add a build setting for the C++ compiler
  [build] Move build configuration into a new file
  [tests] Add a long output mode for CI
  [tests] Make run_tests.sh work without a working terminal or `tput`
  [tests] Setup CI
  • Loading branch information
PaulBone committed Feb 28, 2020
2 parents 1ac63a7 + 2a2e127 commit 85c2265
Show file tree
Hide file tree
Showing 21 changed files with 382 additions and 185 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI

on: [push, pull_request]

jobs:
test:
name: Test (${{ matrix.buildType }} ${{ matrix.c }})
runs-on: ubuntu-latest
strategy:
matrix:
c: [gcc, clang]
buildType: [dev, rel]
fail-fast: false

steps:
- name: checkout
uses: actions/checkout@v2
- name: setup
uses: PlasmaLang/ci/rotd@v1
with:
command: setup
c: ${{ matrix.c }}
buildType: ${{ matrix.buildType }}
- name: build
uses: PlasmaLang/ci/rotd@v1
with:
command: build
- name: test
uses: PlasmaLang/ci/rotd@v1
with:
command: test
- name: gctest
uses: PlasmaLang/ci/rotd@v1
if: matrix.buildType == 'dev'
with:
command: gctest

docs:
name: Build docs
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: checkout
uses: actions/checkout@v2
- name: docs
uses: PlasmaLang/ci/docs@v1

lint:
name: Lint (${{ matrix.buildType }})
runs-on: ubuntu-latest
strategy:
matrix:
buildType: [dev, rel]
fail-fast: false
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup
uses: PlasmaLang/ci/rotd@v1
with:
command: setup
c: clang
buildType: ${{ matrix.buildType }}
lint: lint
- name: build
uses: PlasmaLang/ci/rotd@v1
with:
command: build
- name: extra
uses: PlasmaLang/ci/rotd@v1
with:
command: extra

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.dep
.docs_warning
build.mk
118 changes: 13 additions & 105 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,106 +5,14 @@
# vim: noet sw=4 ts=4
#

# Basic configuration
# ===================
# ======================
#
# You can configure the build by adjusting these settings and optionally
# commenting in/out several options below.
# No configuration here
# See build.mk
include defaults.mk
-include build.mk
#

# How the Mercury compiler should be called. You may need to adjust this if
# it is not in your path.
MMC_MAKE=mmc --make -j$(JOBS)

# The number of parallel jobs the Mercury compiler should spawn.
JOBS=8

# How the C compiler should be called. gcc and clang should both work.
# Note that Mercury has its own configuration for its C backend, which is
# not, and must not be changed here.
CC=gcc

# gcc and probably clang support dependency tracking. If your compiler
# doesn't uncomment the 2nd line.
DEPDIR=.dep
DEPFLAGS=-MT $@ -MMD -MP -MF $(DEPDIR)/$(basename $*).Td

# How to call asciidoc (optional). A full path or any flags here won't work
# without other changes to the makefile.
ASCIIDOC=asciidoc

# How to call clang-format (optional)
CLANGFORMAT=clang-format

# How to call indent (optional)
INDENT=indent

# Detailed build options
# ----------------------
#
# The following settings are closely related and therefore we provide
# suggestions in groups, depending on what type of build you want.
#
# Note that there are also some build parameters in src/Mercury.options

# We start with a base configuration, these work on Linux but you may need
# to change them for other systems / compilers.
MCFLAGS=--use-grade-subdirs
C_CXX_FLAGS=-O1 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
C_CXX_WARN_FLAGS=-Wall -Wno-error=pointer-arith -Wno-pointer-arith
C_ONLY_FLAGS=-std=c99
CXX_ONLY_FLAGS=-std=c++11 -fno-rtti -fno-exceptions
BUILD_TYPE=release

# This is a suitable build for development. It has assertions enabled in
# the C code some of which are slow, so they shouldn't be used for
# performance measurement. Comment it out to use one of the optimised
# builds below.
#
# Note to maintainers: When Plasma is actually "used" we should change this
# default and provide a better way for developers to setup a "dev" build
# with assertions and other checks.

# Development build options
MCFLAGS2=--warn-dead-procs
C_CXX_WARN_FLAGS+=-Werror -DDEBUG -DPZ_DEV
BUILD_TYPE=dev

# You can uncomment _at most one_ of the following sets of options, or write
# your own.

# Enable C and Mercury debugging.
# MCFLAGS2=--grade asm_fast.gc.decldebug.stseg
# C_CXX_FLAGS=-O0 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -DDEBUG -g -DPZ_DEV

# Enable static linking
# MCFLAGS2=--mercury-linkage static
# C_CXX_FLAGS=-O2 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -Wno-error

# Enable optimisation,
# Remember to comment-out the development build options above.
# MCFLAGS2=-O4 --intermodule-optimisation
# C_CXX_FLAGS=-O3 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -Wno-error

# Enable both static linking and optimisation
# Remember to comment-out the development build options above.
# MCFLAGS2=-O4 --intermodule-optimisation \
# --mercury-linkage static
# C_CXX_FLAGS=-O3 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -Wno-error

# Enable Mercury profiling
# MCFLAGS2=--grade asm_fast.gc.profdeep.stseg

# Extra features
# --------------
#
# These can be uncommented to add extra features of interest to developers.

# Tracing of the type checking/inference solver.
# MCFLAGS+=--trace-flag typecheck_solve

# No configuration beyond here
# ============================
# ======================

# As the build system gets more complex I want to avoid autoconf. Perhaps
# instead create a config.h and makefile for each major OS+platform
Expand Down Expand Up @@ -186,25 +94,25 @@ else
DOCS_TARGETS=.docs_warning
endif

CFLAGS=$(DEPFLAGS) $(C_CXX_WARN_FLAGS) $(C_CXX_FLAGS) $(C_ONLY_FLAGS)
CXXFLAGS=$(DEPFLAGS) $(C_CXX_WARN_FLAGS) $(C_CXX_FLAGS) $(CXX_ONLY_FLAGS)
CFLAGS=$(DEPFLAGS) $(C_CXX_FLAGS) $(C_ONLY_FLAGS)
CXXFLAGS=$(DEPFLAGS) $(C_CXX_FLAGS) $(CXX_ONLY_FLAGS)
$(shell mkdir -p $(DEPDIR)/runtime >/dev/null)

.PHONY: all
all : tools runtime/plzrun docs
all : progs docs

.PHONY: tools
tools : rm_errs src/plzasm src/plzc
.PHONY: progs
progs : rm_errs src/plzasm src/plzc runtime/plzrun

.PHONY: rm_errs
rm_errs :
rm -f src/*.err

src/plzasm : $(MERCURY_SOURCES)
(cd src; $(MMC_MAKE) $(MCFLAGS) $(MCFLAGS2) plzasm)
(cd src; $(MMC_MAKE) $(MCFLAGS) plzasm)
(cd src; touch plzasm)
src/plzc : $(MERCURY_SOURCES)
(cd src; $(MMC_MAKE) $(MCFLAGS) $(MCFLAGS2) plzc)
(cd src; $(MMC_MAKE) $(MCFLAGS) plzc)
(cd src; touch plzc)

# Work around Mercury bug https://bugs.mercurylang.org/view.php?id=472
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ It is in early development.
It is free software, Copyright (C) 2015-2020 The Plasma Team, distributed
mostly under the MIT license, see [LICENSE](LICENSE) for details.

![CI](https://github.com/PlasmaLang/plasma/workflows/CI/badge.svg)

## Github and ICE

It came to light recently that Github have a contract with ICE, the
Expand Down Expand Up @@ -62,8 +64,8 @@ also provide some additional explaination.

### Usage

Make any changes you may need in the Makefile, everything configurable is
towards the top of this file.
Copy `template.mk` to `build.mk` and edit it to make any build configuration
changes you need.

Use ```make``` in the root directory to build the project.

Expand Down
57 changes: 57 additions & 0 deletions defaults.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# This is free and unencumbered software released into the public domain.
# See ../LICENSE.unlicense
#
# vim: noet sw=4 ts=4 ft=make
#

# The number of parallel jobs the Mercury compiler should spawn.
JOBS=8

# How the Mercury compiler should be called. You may need to adjust this if
# it is not in your path.
MMC_MAKE=mmc --make -j$(JOBS) --use-grade-subdirs

# How the C compiler should be called. gcc and clang should both work.
# Note that Mercury has its own configuration for its C backend, which is
# not, and must not be changed here.
CC=gcc
CXX=g++
C_CXX_FLAGS_BASE=-D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
C_ONLY_FLAGS=-std=c99
CXX_ONLY_FLAGS=-std=c++11 -fno-rtti -fno-exceptions

# gcc and probably clang support dependency tracking. If your compiler
# doesn't uncomment the 2nd line.
DEPDIR=.dep
DEPFLAGS=-MT $@ -MMD -MP -MF $(DEPDIR)/$(basename $*).Td

# How to call asciidoc (optional). A full path or any flags here won't work
# without other changes to the makefile.
ASCIIDOC=asciidoc

# How to call clang-format (optional)
CLANGFORMAT=clang-format

# How to call indent (optional)
INDENT=indent

# This base configuration works on Linux but you may need to change them for
# other systems / compilers.
C_CXX_FLAGS=$(C_CXX_FLAGS_BASE) -O1 -Wall
BUILD_TYPE=rel

# This is a suitable build for development. It has assertions enabled in
# the C code some of which are slow, so they shouldn't be used for
# performance measurement. Comment it out to use one of the optimised
# builds below.
#
# Note to maintainers: When Plasma is actually "used" we should change this
# default and provide a better way for developers to setup a "dev" build
# with assertions and other checks.

# Development build options
MCFLAGS=--warn-dead-procs
C_CXX_FLAGS+=-Werror -DDEBUG -DPZ_DEV
BUILD_TYPE=dev

8 changes: 4 additions & 4 deletions docs/getting_started.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ Now it’s time to clone the plasma repo:
----
git clone https://github.com/PlasmaLang/plasma.git
----
If you want or need to, you can configure Plasma's build settings by editing
the `Makefile`.
The `Makefile` itself contains documentation that explains the build
options. These include which C compiler to use, and compilation flags.
If you want or need to, you can configure Plasma's build settings by
copying `template.mk` to `build.mk` and editing it.
It some contains documentation that explains the build options.
These include which C compiler to use, and compilation flags.
The default build is reasonable if you have `gcc`.
Then run `make` and it will build you the plasma compiler (`src/plzc`)
Expand Down
5 changes: 4 additions & 1 deletion runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ interpreted as comma-seperated, case-sensative tokens.
* load\_verbose - verbose loading messages

* PZ\_RUNTIME\_DEV\_OPTS for developer runtime options.

These require PZ\_DEV to be defined during compile time.

* interp\_trace - tracing of PZ bytecode interpreter

* gc\_zealous - Make the GC zealously perform a GC before every
allocation.
allocation. To test this mode run:
( cd tests; ./run-tests.sh gc )

6 changes: 4 additions & 2 deletions runtime/pz_gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,10 @@ Heap::end_no_gc_scope()
*/

// 8 bits per byte
static_assert(WORDSIZE_BYTES * 8 == WORDSIZE_BITS);
static_assert(WORDSIZE_BYTES * 8 == WORDSIZE_BITS,
"8 bits in a byte");

// 32 or 64 bit.
static_assert(WORDSIZE_BITS == 64 || WORDSIZE_BITS == 32);
static_assert(WORDSIZE_BITS == 64 || WORDSIZE_BITS == 32,
"Either 32 or 64bit wordsize");

15 changes: 8 additions & 7 deletions runtime/pz_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,20 @@ class HeapMarkState {
mark_root_interior(void *heap_ptr);

/*
* root and len specify a memory area within a root (such as a stack) that
* may contain pointers the GC should not collect.
* root and len_bytes specify a memory area within a root (such as a
* stack) that may contain pointers the GC should not collect.
*/
void
mark_root_conservative(void *root, size_t len);
mark_root_conservative(void *root, size_t len_bytes);

/*
* root and len specify a memory area within a root (such as a stack) that
* may contain pointers the GC should not collect. This version supports
* interior pointers, such as might be found on the return stack.
* root and len_bytes specify a memory area within a root (such as a
* stack) that may contain pointers the GC should not collect. This
* version supports interior pointers, such as might be found on the
* return stack.
*/
void
mark_root_conservative_interior(void *root, size_t len);
mark_root_conservative_interior(void *root, size_t len_bytes);

void
print_stats(FILE *stream);
Expand Down
3 changes: 1 addition & 2 deletions runtime/pz_gc_alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ Heap::alloc_bytes(size_t size_in_bytes, GCCapability &gc_cap,
void *
Heap::try_allocate(size_t size_in_words)
{
static_assert(64 <= Block::Max_Cell_Size);
if (size_in_words <= 64) {
if (size_in_words <= GC_Small_Alloc_Threshold) {
return try_small_allocate(size_in_words);
} else {
return try_medium_allocate(size_in_words);
Expand Down
Loading

0 comments on commit 85c2265

Please sign in to comment.