From 331e8db191c547d64ed983bf89b0e61c18f68121 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Sat, 16 Jan 2021 13:37:43 +0000 Subject: [PATCH] New platform lia6ll (linux, arm64, clang/llvm). --- mps/.travis.yml | 7 ++++ mps/code/.p4ignore | 1 + mps/code/lia6ll.gmk | 55 ++++++++++++++++++++++++++++ mps/code/ll.gmk | 2 +- mps/code/mps.c | 15 ++++++++ mps/code/mpstd.h | 19 ++++++++++ mps/code/prmclia6.c | 53 +++++++++++++++++++++++++++ mps/configure | 8 ++++ mps/configure.ac | 7 ++++ mps/design/prmc.txt | 4 +- mps/manual/build.txt | 1 + mps/manual/source/code-index.rst | 2 + mps/manual/source/release.rst | 5 ++- mps/manual/source/topic/platform.rst | 8 ++++ mps/manual/source/topic/porting.rst | 5 ++- 15 files changed, 186 insertions(+), 6 deletions(-) create mode 100644 mps/code/lia6ll.gmk create mode 100644 mps/code/prmclia6.c diff --git a/mps/.travis.yml b/mps/.travis.yml index 30c85c5c410..883617763c1 100644 --- a/mps/.travis.yml +++ b/mps/.travis.yml @@ -5,6 +5,9 @@ language: c os: - linux - osx +arch: + - amd64 + - arm64 compiler: - clang - gcc @@ -12,6 +15,10 @@ matrix: exclude: - os: osx compiler: gcc + exclude: + - os: linux + arch: arm64 + compiler: gcc notifications: email: - mps-travis@ravenbrook.com diff --git a/mps/code/.p4ignore b/mps/code/.p4ignore index 682821ffd84..7ac128137a3 100644 --- a/mps/code/.p4ignore +++ b/mps/code/.p4ignore @@ -8,6 +8,7 @@ fri3gc fri3ll fri6gc fri6ll +lia6ll lii3gc lii6gc lii6ll diff --git a/mps/code/lia6ll.gmk b/mps/code/lia6ll.gmk new file mode 100644 index 00000000000..9e329ee98a4 --- /dev/null +++ b/mps/code/lia6ll.gmk @@ -0,0 +1,55 @@ +# -*- makefile -*- +# +# lia6ll.gmk: BUILD FOR LINUX/ARM64/Clang PLATFORM +# +# $Id$ +# Copyright (c) 2001-2021 Ravenbrook Limited. See end of file for license. + +PFM = lia6ll + +MPMPF = \ + lockix.c \ + prmcanan.c \ + prmcix.c \ + prmclia6.c \ + protix.c \ + protsgix.c \ + pthrdext.c \ + span.c \ + thix.c \ + vmix.c + +LIBS = -lm -lpthread + +include ll.gmk +include comm.gmk + + +# C. COPYRIGHT AND LICENSE +# +# Copyright (C) 2001-2021 Ravenbrook Limited . +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/mps/code/ll.gmk b/mps/code/ll.gmk index ce1db14aef8..16ebf0e7874 100644 --- a/mps/code/ll.gmk +++ b/mps/code/ll.gmk @@ -14,11 +14,11 @@ CFLAGSDEBUG = -O0 -g3 CFLAGSOPT = -O2 -g3 # Warnings that might be enabled by clients . +# TODO: add -Wcomma when all our continuous integration platforms support it. CFLAGSCOMPILER := \ -Waggregate-return \ -Wall \ -Wcast-qual \ - -Wcomma \ -Wconversion \ -Wduplicate-enum \ -Werror \ diff --git a/mps/code/mps.c b/mps/code/mps.c index 3fbfc579f7e..543b40166c8 100644 --- a/mps/code/mps.c +++ b/mps/code/mps.c @@ -182,6 +182,21 @@ #include "prmcfri6.c" /* x86-64 for FreeBSD mutator context */ #include "span.c" /* generic stack probe */ +/* Linux on ARM64 with Clang */ + +#elif defined(MPS_PF_LIA6LL) + +#include "lockix.c" /* Posix locks */ +#include "thix.c" /* Posix threading */ +#include "pthrdext.c" /* Posix thread extensions */ +#include "vmix.c" /* Posix virtual memory */ +#include "protix.c" /* Posix protection */ +#include "protsgix.c" /* Posix signal handling */ +#include "prmcanan.c" /* generic architecture mutator context */ +#include "prmcix.c" /* Posix mutator context */ +#include "prmclia6.c" /* x86-64 for Linux mutator context */ +#include "span.c" /* generic stack probe */ + /* Linux on IA-32 with GCC */ #elif defined(MPS_PF_LII3GC) diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h index df56d29f2a6..f836efdb56d 100644 --- a/mps/code/mpstd.h +++ b/mps/code/mpstd.h @@ -222,6 +222,25 @@ #define MPS_PF_ALIGN 8 +/* Clang/LLVM 10.0, clang -E -dM */ + +#elif defined(__linux__) && defined(__aarch64__) && defined(__GNUC__) \ + && defined(__clang__) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_LIA6LL) +#error "specified CONFIG_PF_... inconsistent with detected lia6ll" +#endif +#define MPS_PF_LIA6LL +#define MPS_PF_STRING "lia6ll" +#define MPS_OS_LI +#define MPS_ARCH_A6 +#define MPS_BUILD_LL +#define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long +#define MPS_WORD_WIDTH 64 +#define MPS_WORD_SHIFT 6 +#define MPS_PF_ALIGN 8 + + /* GCC 2.6.3, gcc -E -dM * The actual granularity of GNU malloc is 8, but field alignments are * all 4. diff --git a/mps/code/prmclia6.c b/mps/code/prmclia6.c new file mode 100644 index 00000000000..b79bb9db48c --- /dev/null +++ b/mps/code/prmclia6.c @@ -0,0 +1,53 @@ +/* prmclia6.c: MUTATOR CONTEXT ARM64 (LINUX) + * + * $Id$ + * Copyright (c) 2001-2021 Ravenbrook Limited. See end of file for license. + * + * .purpose: Implement the mutator context module. . + */ + +#include "prmcix.h" + +SRCID(prmclia6, "$Id$"); + +#if !defined(MPS_OS_LI) || !defined(MPS_ARCH_A6) +#error "prmclia6.c is specific to MPS_OS_LI and MPS_ARCH_A6" +#endif + + +Addr MutatorContextSP(MutatorContext context) +{ + AVERT(MutatorContext, context); + + return (Addr)context->ucontext->uc_mcontext.sp; +} + + +/* C. COPYRIGHT AND LICENSE + * + * Copyright (C) 2001-2021 Ravenbrook Limited . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/mps/configure b/mps/configure index cb018412424..fefd2a0051a 100755 --- a/mps/configure +++ b/mps/configure @@ -3454,6 +3454,14 @@ CLEAN_TARGET=clean-make-build INSTALL_TARGET=install-make-build TEST_TARGET=test-make-build case $host/$CLANG in + aarch64-*-linux*/yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Linux ARM64" >&5 +$as_echo "Linux ARM64" >&6; } + MPS_OS_NAME=li + MPS_ARCH_NAME=a6 + MPS_BUILD_NAME=ll + PFMCFLAGS="$CFLAGS_LL" + ;; i*86-*-linux*/no) { $as_echo "$as_me:${as_lineno-$LINENO}: result: Linux x86" >&5 $as_echo "Linux x86" >&6; } diff --git a/mps/configure.ac b/mps/configure.ac index acf935b640e..fbf19cec06e 100644 --- a/mps/configure.ac +++ b/mps/configure.ac @@ -45,6 +45,13 @@ CLEAN_TARGET=clean-make-build INSTALL_TARGET=install-make-build TEST_TARGET=test-make-build case $host/$CLANG in + aarch64-*-linux*/yes) + AC_MSG_RESULT([Linux ARM64]) + MPS_OS_NAME=li + MPS_ARCH_NAME=a6 + MPS_BUILD_NAME=ll + PFMCFLAGS="$CFLAGS_LL" + ;; i*86-*-linux*/no) AC_MSG_RESULT([Linux x86]) MPS_OS_NAME=li diff --git a/mps/design/prmc.txt b/mps/design/prmc.txt index fb141f23a8c..6c55634a8b0 100644 --- a/mps/design/prmc.txt +++ b/mps/design/prmc.txt @@ -178,8 +178,8 @@ Posix implementation _`.impl.ix`: In ``prmcix.c`` and ``protsgix.c``, with processor-specific parts in ``prmci3.c`` and ``prmci6.c``, and other -platform-specific parts in ``prmcfri3.c``, ``prmclii3.c``, -``prmcfri6.c``, and ``prmclii6.c``. +platform-specific parts in ``prmcfri3.c``, ``prmcfri6.c``, +``prmclia6.c``, ``prmclii3.c``, and ``prmclii6.c``. _`.impl.ix.context`: The context consists of the |siginfo_t|_ and |ucontext_t|_ structures. POSIX specifies some of the fields in diff --git a/mps/manual/build.txt b/mps/manual/build.txt index 8a5e55c1795..7f7f8813f81 100644 --- a/mps/manual/build.txt +++ b/mps/manual/build.txt @@ -139,6 +139,7 @@ Platform OS Architecture Compiler Makefile ``fri3ll`` FreeBSD IA-32 Clang ``fri3ll.gmk`` ``fri6gc`` FreeBSD x86-64 GCC ``fri6gc.gmk`` ``fri6ll`` FreeBSD x86-64 Clang ``fri6ll.gmk`` +``lia6ll`` Linux ARM64 Clang ``lia6ll.gmk`` ``lii3gc`` Linux IA-32 GCC ``lii3gc.gmk`` ``lii6gc`` Linux x86-64 GCC ``lii6gc.gmk`` ``lii6ll`` Linux x86-64 Clang ``lii6ll.gmk`` diff --git a/mps/manual/source/code-index.rst b/mps/manual/source/code-index.rst index f30ac3a1e59..3fc9530cf5c 100644 --- a/mps/manual/source/code-index.rst +++ b/mps/manual/source/code-index.rst @@ -175,6 +175,7 @@ prmci6.c Mutator context implementation for x86-64. prmci6.h Mutator context interface for x86-64. prmcix.c Mutator context implementation for POSIX. prmcix.h Mutator context interface for POSIX. +prmclia6.c Mutator context implementation for Linux, ARM64. prmclii3.c Mutator context implementation for Linux, IA-32. prmclii6.c Mutator context implementation for Linux, x86-64. prmcw3.c Mutator context implementation for Windows. @@ -384,6 +385,7 @@ fri6gc.gmk GNU makefile for platform FRI6GC. fri6ll.gmk GNU makefile for platform FRI6LL. gc.gmk GNU make fragment for GCC. gp.gmk GNU make fragment for GCC/GProf (broken). +lia6ll.gmk GNU makefile for platform LIA6LL. lii3gc.gmk GNU makefile for platform LII3GC. lii6gc.gmk GNU makefile for platform LII6GC. lii6ll.gmk GNU makefile for platform LII6LL. diff --git a/mps/manual/source/release.rst b/mps/manual/source/release.rst index 70d5b7ccded..167af1bec87 100644 --- a/mps/manual/source/release.rst +++ b/mps/manual/source/release.rst @@ -12,7 +12,10 @@ Release 1.118.0 New features ............ -#. New supported platform ``xca6ll`` (macOS, ARM64, Clang/LLVM). +#. New supported platforms: + + * ``lia6ll`` (Linux, ARM64, Clang/LLVM). + * ``xca6ll`` (macOS, ARM64, Clang/LLVM). #. The MPS no longer supports building for the xci3ll platform (macOS, IA-32, Clang/LLVM) using Xcode. This is because Xcode 10.0 no diff --git a/mps/manual/source/topic/platform.rst b/mps/manual/source/topic/platform.rst index d72f3fb7a28..72ecedc8d39 100644 --- a/mps/manual/source/topic/platform.rst +++ b/mps/manual/source/topic/platform.rst @@ -171,6 +171,13 @@ Platform interface x86-64 processor architecture, and the Clang/LLVM compiler. +.. c:macro:: MPS_PF_LIA6LL + + A :term:`C` preprocessor macro that indicates, if defined, that + the :term:`platform` consists of the Linux operating system, the + ARM64 processor architecture, and the Clang/LLVM compiler. + + .. c:macro:: MPS_PF_LII3GC A :term:`C` preprocessor macro that indicates, if defined, that @@ -370,6 +377,7 @@ Platform Status ``fri6ll`` Supported ``i5m2cc`` *Not supported* ``iam4cc`` *Not supported* +``lia6ll`` Supported ``lii3eg`` *Not supported* ``lii3gc`` Supported ``lii4gc`` Corrected to ``lii3gc`` diff --git a/mps/manual/source/topic/porting.rst b/mps/manual/source/topic/porting.rst index 30e039d9627..87cdf95e06c 100644 --- a/mps/manual/source/topic/porting.rst +++ b/mps/manual/source/topic/porting.rst @@ -76,8 +76,9 @@ usable. stack` can be scanned. See :ref:`design-prmc` for the design, and ``prmc.h`` for the - interface. There are implementations on Unix and Windows for - IA-32 and x86-64, and on macOS for IA-32, x86-64, and ARM64. + interface. There are implementations on FreeBSD and Windows for + IA-32 and x86-64, and on Linux and macOS for IA-32, x86-64, and + ARM64. There is a generic implementation in ``prmcan.c``, which can't provide these features, and so only supports a single thread.