Skip to content

Commit

Permalink
Merge pull request #10350 from hannesm/zarith-free
Browse files Browse the repository at this point in the history
zarith-freestanding.1.6 + zarith-xen.1.6
  • Loading branch information
samoht authored Oct 10, 2017
2 parents a13dc28 + b34604f commit 73d7098
Show file tree
Hide file tree
Showing 36 changed files with 429 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/gmp-freestanding/gmp-freestanding.6.0.0-1/descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The GNU Multiple Precision Arithmetic Library

Freestanding build of GNU GMP.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
libdir=${pcfiledir}/../gmp-freestanding
includedir=${libdir}/include

Name: gmp-freestanding
Version: 6.0.0
URL: https://gmplib.org
Description: The GNU Multiple Precision Arithmetic Library
Cflags: -I${includedir}
Libs: -L${libdir} -lgmp-freestanding
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh -ex
if [ -z "$PREFIX" ]; then
PREFIX="`opam config var prefix`/lib/gmp-freestanding"
fi

PKG_CONFIG_DEPS="ocaml-freestanding"
check_deps () {
pkg-config --print-errors --exists ${PKG_CONFIG_DEPS}
}

if ! check_deps 2>/dev/null; then
# rely on `opam` if deps are unavailable
export PKG_CONFIG_PATH="`opam config var prefix`/lib/pkgconfig"
fi
check_deps || exit 1

#
# ocaml-freestanding does not provide a real cross compiler, so we fake it:
#
# - set CC to stop configure trying to find a host compiler
# - set CPPFLAGS to ocaml-freestanding CFLAGS, this prevents inclusion of
# system headers
# - manually override tests for missing functions
# - manually trim the components (SUBDIRS) of libgmp we build to the subset
# actually used by zarith-freestanding (our sole dependency)
# - set -Werror=implicit-function-declaration at *build* time to catch any
# undefined symbols
#
ac_cv_func_obstack_vprintf=no \
ac_cv_func_localeconv=no \
./configure \
--host=x86_64-unknown-none --enable-fat --disable-shared --with-pic \
CC=cc "CPPFLAGS=$(pkg-config --cflags ${PKG_CONFIG_DEPS})"

make SUBDIRS="mpn mpz mpq mpf" \
PRINTF_OBJECTS= SCANF_OBJECTS= \
CFLAGS+=-Werror=implicit-function-declaration
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -ex
if [ -z "$PREFIX" ]; then
PREFIX=`opam config var prefix`
fi
PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
LIBDIR=${PREFIX}/lib/gmp-freestanding

mkdir -p ${PKG_CONFIG_PATH}
cp gmp-freestanding.pc ${PKG_CONFIG_PATH}
mkdir -p ${LIBDIR}
cp .libs/libgmp.a ${LIBDIR}/libgmp-freestanding.a
touch ${LIBDIR}/META
mkdir -p ${LIBDIR}/include
cp gmp.h ${LIBDIR}/include
18 changes: 18 additions & 0 deletions packages/gmp-freestanding/gmp-freestanding.6.0.0-1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
opam-version: "1.2"
maintainer: "Martin Lucina <[email protected]>"
homepage: "https://gmplib.org/"
license: "GNU LGPL v3 and GNU GPL v2"
authors: "Torbjörn Granlund and contributors"
bug-reports: "[email protected]"

build: ["sh" "-ex" "./mirage-build.sh"]
install: ["sh" "-ex" "./mirage-install.sh"]
remove: [
"rm" "-rf"
"%{prefix}%/lib/pkgconfig/gmp-freestanding.pc"
"%{prefix}%/lib/gmp-freestanding"
]
depends: [
"ocaml-freestanding"
"conf-m4" {build}
]
2 changes: 2 additions & 0 deletions packages/gmp-freestanding/gmp-freestanding.6.0.0-1/url
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
archive: "https://gmplib.org/download/gmp/gmp-6.0.0a.tar.xz"
checksum: "1e6da4e434553d2811437aa42c7f7c76"
1 change: 1 addition & 0 deletions packages/gmp-freestanding/gmp-freestanding.6.0.0/opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ remove: [
]
depends: [
"ocaml-freestanding"
"conf-m4" {build}
]
1 change: 1 addition & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/descr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The GNU Multiple Precision Arithmetic Library
20 changes: 20 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/files/gmp-6a.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- gmp-6.0.0.orig.orig/config.guess 2014-03-25 14:37:55.000000000 +0000
+++ gmp-6.0.0.orig/config.guess 2014-09-16 15:46:57.457485087 +0000
@@ -173,7 +173,7 @@
;;

arm*-*-*)
- cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null`
+ cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo | head -1 2>/dev/null`
case "$cpu_code" in
0xa10 | 0xa11 | 0xb11) # v4 strongarm/sa1100
exact_cpu="armsa1";;
@@ -200,7 +200,7 @@
0xc15) exact_cpu="armcortexr5";; # v7r
0xc23) exact_cpu="armcortexm3";; # v7m
esac
- exact_cpu="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo 2>/dev/null`"
+ exact_cpu="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo | head -1 2>/dev/null`"
;;

ia64*-*-*)
9 changes: 9 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/files/gmp-xen.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
libdir=${pcfiledir}/../gmp-xen
includedir=${libdir}/include

Name: gmp-xen
Version: 6.0.0
URL: https://gmplib.org
Description: The GNU Multiple Precision Arithmetic Library
Cflags: -I${includedir}
Libs: -L${libdir} -lgmp-xen
31 changes: 31 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/files/mirage-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh -ex
if [ -z "$PREFIX" ]; then
PREFIX="`opam config var prefix`/lib/gmp-xen"
fi

PKG_CONFIG_DEPS="mirage-xen-posix"
check_deps () {
pkg-config --print-errors --exists ${PKG_CONFIG_DEPS}
}

if ! check_deps 2>/dev/null; then
# rely on `opam` if deps are unavailable
export PKG_CONFIG_PATH="`opam config var prefix`/lib/pkgconfig"
fi
check_deps || exit 1

CPPFLAGS="$CPPFLAGS `pkg-config $PKG_CONFIG_DEPS --cflags` -O2 -pedantic -fomit-frame-pointer -fno-builtin -D_FORTIFY_SOURCE=0 -Wmissing-prototypes --std=gnu99"
# Use different --host and --build to trigger cross-compilation mode (don't try to test binaries during configure)
# Set CC to stop it trying to find a separate compiler for HOST.
# Pass CPPFLAGS (not just CFLAGS) to stop it finding the Linux headers (just generates warnings).
# Use -Werror=missing-prototypes because we're not running the tests due to cross-compiling.
HOST="`uname -m`-unknown-none"
BUILD=`./config.guess`
./configure --host="$HOST" --build="$BUILD" --enable-fat CC=gcc --prefix="$PREFIX" --disable-shared CPPFLAGS="$CPPFLAGS" --with-pic
# Because we're cross-compiling, configurate can't tell whether a function
# actually exists and just assumes they all do. For localeconv, this is wrong.
sed -e '/HAVE_LOCALECONV/d' \
-e '/HAVE_OBSTACK_VPRINTF/d'\
-i config.status
./config.status
make
13 changes: 13 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/files/mirage-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh -ex
if [ -z "$PREFIX" ]; then
PREFIX=`opam config var prefix`
fi
LIBDIR="$PREFIX/lib/gmp-xen"
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export PKG_CONFIG_PATH

make install
mkdir -p "$PKG_CONFIG_PATH"
cp gmp-xen.pc "$PKG_CONFIG_PATH/"
mkdir -p "$LIBDIR"
cp .libs/libgmp.a "$LIBDIR/libgmp-xen.a"
18 changes: 18 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
opam-version: "1.2"
maintainer: "Thomas Leonard <[email protected]>"
homepage: "https://gmplib.org/"
license: "GNU LGPL v3 and GNU GPL v2"
authors: "Torbjörn Granlund and contributors"

patches: ["gmp-6a.diff"]
build: ["sh" "-ex" "./mirage-build.sh"]
install: ["sh" "-ex" "./mirage-install.sh"]
remove: [
"rm" "-rf"
"%{prefix}%/lib/pkgconfig/gmp-xen.pc"
"%{prefix}%/lib/gmp-xen"
]
depends: [
"mirage-xen-posix"
"conf-m4" {build}
]
2 changes: 2 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0-1/url
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
archive: "https://gmplib.org/download/gmp/gmp-6.0.0a.tar.xz"
checksum: "1e6da4e434553d2811437aa42c7f7c76"
2 changes: 2 additions & 0 deletions packages/gmp-xen/gmp-xen.6.0.0/opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ opam-version: "1.2"
maintainer: "Thomas Leonard <[email protected]>"
homepage: "https://gmplib.org/"
license: "GNU LGPL v3 and GNU GPL v2"
authors: "Torbjörn Granlund and contributors"

patches: ["gmp-6a.diff"]
build: ["sh" "-ex" "./mirage-build.sh"]
Expand All @@ -13,4 +14,5 @@ remove: [
]
depends: [
"mirage-xen-posix"
"conf-m4" {build}
]
5 changes: 5 additions & 0 deletions packages/solo5-kernel-ukvm/solo5-kernel-ukvm.0.2.2-1/descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Solo5 unikernel base (ukvm target)

This package provides the Solo5 base layer to run MirageOS unikernels on the
"ukvm" target. ukvm, a specialized unikernel monitor, runs as a Linux process
and uses KVM.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/ukvm/ukvm-core.c
+++ b/ukvm/ukvm-core.c
@@ -36,7 +36,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/const.h>
-#include <asm/msr-index.h>
#include <elf.h>
#include <errno.h>
#include <assert.h>
--- a/ukvm/ukvm-cpu.h
+++ b/ukvm/ukvm-cpu.h
@@ -133,4 +133,7 @@ struct _kvm_segment {
seg.avl = GDT_GET_AVL(gdt_ent); \
} while (0)

+#define EFER_LME_BIT 8 /* Long mode enable (R/W) */
+#define EFER_LME _BITUL(EFER_LME_BIT)
+
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/ukvm/ukvm-configure
+++ b/ukvm/ukvm-configure
@@ -40,7 +40,7 @@

UKVM_CC?=cc
UKVM_FLAGS=-D__UKVM_HOST__ \$(UKVM_MODULE_FLAGS)
-UKVM_CFLAGS=-Wall -Werror -std=c99 -O2 -g \$(UKVM_FLAGS)
+UKVM_CFLAGS=-Wall -std=c99 -O2 -g \$(UKVM_FLAGS)
UKVM_OBJS=_build-ukvm/ukvm-core.o \$(UKVM_MODULE_OBJS)
ifdef UKVM_STATIC
UKVM_LDFLAGS=-static
--- a/Makefile.common
+++ b/Makefile.common
@@ -32,4 +32,4 @@
# Likewise.
LDFLAGS=-nostdlib -z max-page-size=0x1000 -static
# CFLAGS used for building kernel/ and in-tree tests.
-CFLAGS=$(MD_CFLAGS) -isystem $(TOP)/include-host -std=gnu99 -Wall -Wextra -Werror -O2 -g
+CFLAGS=$(MD_CFLAGS) -isystem $(TOP)/include-host -std=gnu99 -Wall -Wextra -O2 -g
25 changes: 25 additions & 0 deletions packages/solo5-kernel-ukvm/solo5-kernel-ukvm.0.2.2-1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
opam-version: "1.2"
maintainer: "[email protected]"
authors: [
"Dan Williams <[email protected]>"
"Martin Lucina <[email protected]>"
"Ricardo Koller <[email protected]>"
]
homepage: "https://github.com/solo5/solo5"
bug-reports: "https://github.com/solo5/solo5/issues"
license: "ISC"
dev-repo: "https://github.com/solo5/solo5.git"
build: [make "ukvm"]
install: [make "opam-ukvm-install" "PREFIX=%{prefix}%"]
remove: [make "opam-ukvm-uninstall" "PREFIX=%{prefix}%"]
depends: "conf-pkg-config"
depexts: [
[["alpine"] ["linux-headers"]]
[["debian"] ["linux-libc-dev"]]
[["fedora"] ["kernel-headers"]]
[["rhel"] ["kernel-headers"]]
[["ubuntu"] ["linux-libc-dev"]]
]
conflicts: "solo5-kernel-virtio"
available: [ocaml-version >= "4.02.3" & arch = "x86_64" & os = "linux"]
patches: [ "solo5-no-werror.diff" "solo5-no-asm-msr-index.diff" ]
2 changes: 2 additions & 0 deletions packages/solo5-kernel-ukvm/solo5-kernel-ukvm.0.2.2-1/url
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
http: "https://github.com/Solo5/solo5/archive/v0.2.2.tar.gz"
checksum: "29e344999bd7476e6e83e9533b8a4dd9"
11 changes: 11 additions & 0 deletions packages/solo5-kernel-virtio/solo5-kernel-virtio.0.2.2-1/descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Solo5 unikernel base (virtio target)

This package provides the Solo5 base layer to run MirageOS unikernels on the
"virtio" target. Unikernels built for the "virtio" target run directly on
existing hypervisors, such as KVM/QEMU and bhyve.

Additionally, this package installs the "solo5-run-virtio" tool, a wrapper for
launching unikernels on various hypervisors, and the "solo5-mkimage" tool for
building MBR-partitioned disk images with a bootloader and unikernel installed.
The latter includes support for building images suitable for upload to Google
Compute Engine.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/ukvm/ukvm-configure
+++ b/ukvm/ukvm-configure
@@ -40,7 +40,7 @@

UKVM_CC?=cc
UKVM_FLAGS=-D__UKVM_HOST__ \$(UKVM_MODULE_FLAGS)
-UKVM_CFLAGS=-Wall -Werror -std=c99 -O2 -g \$(UKVM_FLAGS)
+UKVM_CFLAGS=-Wall -std=c99 -O2 -g \$(UKVM_FLAGS)
UKVM_OBJS=_build-ukvm/ukvm-core.o \$(UKVM_MODULE_OBJS)
ifdef UKVM_STATIC
UKVM_LDFLAGS=-static
--- a/Makefile.common
+++ b/Makefile.common
@@ -32,4 +32,4 @@
# Likewise.
LDFLAGS=-nostdlib -z max-page-size=0x1000 -static
# CFLAGS used for building kernel/ and in-tree tests.
-CFLAGS=$(MD_CFLAGS) -isystem $(TOP)/include-host -std=gnu99 -Wall -Wextra -Werror -O2 -g
+CFLAGS=$(MD_CFLAGS) -isystem $(TOP)/include-host -std=gnu99 -Wall -Wextra -O2 -g
21 changes: 21 additions & 0 deletions packages/solo5-kernel-virtio/solo5-kernel-virtio.0.2.2-1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
opam-version: "1.2"
maintainer: "[email protected]"
authors: [
"Dan Williams <[email protected]>"
"Martin Lucina <[email protected]>"
"Ricardo Koller <[email protected]>"
]
homepage: "https://github.com/solo5/solo5"
bug-reports: "https://github.com/solo5/solo5/issues"
license: "ISC"
dev-repo: "https://github.com/solo5/solo5.git"
build: [make "virtio"]
install: [make "opam-virtio-install" "PREFIX=%{prefix}%"]
remove: [make "opam-virtio-uninstall" "PREFIX=%{prefix}%"]
depends: "conf-pkg-config"
conflicts: "solo5-kernel-ukvm"
available: [
ocaml-version >= "4.02.3" & (arch = "x86_64" | arch = "amd64") &
os != "darwin"
]
patches: [ "solo5-no-werror.diff" ]
2 changes: 2 additions & 0 deletions packages/solo5-kernel-virtio/solo5-kernel-virtio.0.2.2-1/url
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
http: "https://github.com/Solo5/solo5/archive/v0.2.2.tar.gz"
checksum: "29e344999bd7476e6e83e9533b8a4dd9"
5 changes: 5 additions & 0 deletions packages/zarith-freestanding/zarith-freestanding.1.6/descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Implements arithmetic and logical operations over arbitrary-precision integers
The Zarith library implements arithmetic and logical operations over
arbitrary-precision integers. It uses GMP to efficiently implement
arithmetic over big integers. Small integers are represented as Caml
unboxed integers, for speed and space economy.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/configure 2016-07-22 21:53:10.872919000 +0200
+++ b/configure 2016-07-22 21:55:23.788871000 +0200
@@ -340,12 +340,8 @@
if test "$gmp" = 'gmp' -o "$gmp" = 'auto'; then
checkinc gmp.h
if test $? -eq 1; then
- checklib gmp
- if test $? -eq 1; then
- gmp='OK'
- cclib="$cclib -lgmp"
- ccdef="-DHAS_GMP $ccdef"
- fi
+ gmp='OK'
+ ccdef="-DHAS_GMP $ccdef"
fi
fi
if test "$gmp" = 'mpir' -o "$gmp" = 'auto'; then
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -eux

PREFIX=`opam config var prefix`
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export PKG_CONFIG_PATH

# WARNING: if you pass invalid cflags here, zarith will silently
# fall back to compiling with the default flags instead!
CFLAGS="$(pkg-config --cflags gmp-freestanding ocaml-freestanding)" \
LDFLAGS="$(pkg-config --libs gmp-freestanding)" \
./configure -gmp

if [ `uname -s` = "FreeBSD" ]; then
gmake
else
make
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -eux

PREFIX=`opam config var prefix`
PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export PKG_CONFIG_PATH

cp libzarith.a "$PREFIX/lib/zarith/libzarith-freestanding.a"

# This is a hack to get freestanding_linkopts into the host 'zarith' package.
cat >>"$PREFIX/lib/zarith/META" <<EOM
freestanding_linkopts = "-lzarith-freestanding -L@gmp-freestanding -lgmp-freestanding"
EOM
Loading

0 comments on commit 73d7098

Please sign in to comment.