From b666482d846c6f74a04026cd0848a2bc83e15e50 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 26 Jul 2021 08:49:03 +0300 Subject: [PATCH] ci: fix the vinix-build job --- .github/workflows/build_vinix_locally.sh | 56 ++++++++++++++++++++++++ .github/workflows/vinix-kernel.yml | 6 +-- vlib/v/gen/c/cheaders.v | 2 + 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100755 .github/workflows/build_vinix_locally.sh diff --git a/.github/workflows/build_vinix_locally.sh b/.github/workflows/build_vinix_locally.sh new file mode 100755 index 000000000..488ec4add --- /dev/null +++ b/.github/workflows/build_vinix_locally.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +set -e + +V=$PWD/v + +if [[ -x "$V" ]] +then + echo "The v executable exists." +else + echo "This script should be run from the top level folder of a V repository" + echo "i.e. the folder where your V executable is." + exit 1 +fi + +BUILD=$PWD/vinix_build + +echo "Creating $BUILD folder..." +rm -rf $BUILD +mkdir -p $BUILD + +cd $BUILD +echo "Clone current Vinix" +git clone https://github.com/vlang/vinix.git --depth=1 + +cd $BUILD +echo "Clone current mlibc" +git clone https://github.com/managarm/mlibc.git --depth=1 + +cd $BUILD +echo "Patch mlibc for Vinix" +cd mlibc +patch -p3 < ../vinix/patches/mlibc/mlibc.patch + +cd $BUILD +echo "Install mlibc headers" +mkdir mlibc-build +cd mlibc-build +meson --cross-file ../vinix/cross_file.txt --prefix=/ -Dheaders_only=true ../mlibc +ninja +mkdir ../mlibc-headers +DESTDIR=`realpath ../mlibc-headers` ninja install + +cd $BUILD +echo "Attempt to build the Vinix kernel (debug)" +cd vinix/kernel +make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" +make clean + +cd $BUILD +echo "Attempt to build the Vinix kernel (prod)" +cd vinix/kernel +make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" +make clean + +rm -rf $BUILD diff --git a/.github/workflows/vinix-kernel.yml b/.github/workflows/vinix-kernel.yml index 5f0f2d67d..de79d9976 100644 --- a/.github/workflows/vinix-kernel.yml +++ b/.github/workflows/vinix-kernel.yml @@ -7,7 +7,7 @@ on: - master jobs: - build: + vinix-build: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -24,6 +24,6 @@ jobs: - name: Install mlibc headers run: mkdir mlibc-build && cd mlibc-build && meson --cross-file ../vinix/cross_file.txt --prefix=/ -Dheaders_only=true ../mlibc && ninja && mkdir ../mlibc-headers && DESTDIR=`realpath ../mlibc-headers` ninja install - name: Attempt to build the Vinix kernel (debug) - run: cd vinix/kernel && make PROD=false CFLAGS="-O2 -g -pipe -I../mlibc-headers/include" V="../../v" && make clean + run: cd vinix/kernel && make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean - name: Attempt to build the Vinix kernel (prod) - run: cd vinix/kernel && make PROD=true CFLAGS="-O2 -g -pipe -I../mlibc-headers/include" V="../../v" && make clean + run: cd vinix/kernel && make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index efb861caf..c51ed84c5 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -620,11 +620,13 @@ static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=0xa0761d6478bd642ful // the wyrand PRNG that pass BigCrush and PractRand static inline uint64_t wyrand(uint64_t *seed){ *seed+=0xa0761d6478bd642full; return _wymix(*seed,*seed^0xe7037ed1a0b428dbull);} +#ifndef __vinix__ // convert any 64 bit pseudo random numbers to uniform distribution [0,1). It can be combined with wyrand, wyhash64 or wyhash. static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} // convert any 64 bit pseudo random numbers to APPROXIMATE Gaussian distribution. It can be combined with wyrand, wyhash64 or wyhash. static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} +#endif #if(!WYHASH_32BIT_MUM) // fast range integer random number generation on [0,k) credit to Daniel Lemire. May not work when WYHASH_32BIT_MUM=1. It can be combined with wyrand, wyhash64 or wyhash. -- 2.30.2