Compare commits
2 Commits
691ee7dd19
...
7b74b2733c
Author | SHA1 | Date |
---|---|---|
Alexander Sosedkin | 7b74b2733c | |
Ekaitz | 743710064f |
23
boot.sh
23
boot.sh
|
@ -22,6 +22,13 @@ case $arch in
|
|||
triplet=arm-unknown-linux-gnueabihf
|
||||
cross_prefix=${triplet}-
|
||||
;;
|
||||
riscv*)
|
||||
cpu=riscv64
|
||||
mes_cpu=riscv64
|
||||
tcc_cpu=riscv64
|
||||
triplet=riscv64-unknown-linux-gnu
|
||||
cross_prefix=${triplet}-
|
||||
;;
|
||||
*)
|
||||
cpu=x86
|
||||
mes_cpu=x86
|
||||
|
@ -133,6 +140,9 @@ elif test "$mes_cpu" = arm; then
|
|||
elif test "$mes_cpu" = x86_64; then
|
||||
BOOT_CPPFLAGS_TCC="$BOOT_CPPFLAGS_TCC -D HAVE_SETJMP=1"
|
||||
CPP_TARGET_FLAG="-D TCC_TARGET_X86_64=1"
|
||||
elif test "$mes_cpu" = riscv64; then
|
||||
BOOT_CPPFLAGS_TCC="$BOOT_CPPFLAGS_TCC -D HAVE_SETJMP=1"
|
||||
CPP_TARGET_FLAG="-D TCC_TARGET_RISC64=1"
|
||||
else
|
||||
echo "cpu not supported: $mes_cpu"
|
||||
fi
|
||||
|
@ -234,6 +244,19 @@ if $REBUILD_LIBC; then
|
|||
./${program_prefix}tcc -ar rc libtcc1.a libtcc1.o armeabi.o
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
if [ $mes_cpu = riscv64 ]; then
|
||||
./${program_prefix}tcc -c -g $BOOT_CPPFLAGS lib/lib-arm64.c
|
||||
|
||||
./${program_prefix}tcc -c -g $CPP_TARGET_FLAG $BOOT_CPPFLAGS_TCC -o libtcc1-tcc.o lib/libtcc1.c
|
||||
./${program_prefix}tcc -ar rc libtcc1-tcc.a libtcc1-tcc.o lib-arm64.o
|
||||
|
||||
./${program_prefix}tcc -c -g $CPP_TARGET_FLAG -D HAVE_FLOAT=1 -D HAVE_LONG_LONG=1 -o libtcc1-mes.o $MES_LIB/libtcc1.c
|
||||
./${program_prefix}tcc -ar rc libtcc1-mes.a libtcc1-mes.o lib-arm64.o
|
||||
|
||||
./${program_prefix}tcc -c -g $CPP_TARGET_FLAG $BOOT_CPPFLAGS_TCC -o libtcc1.o lib/libtcc1.c
|
||||
./${program_prefix}tcc -ar rc libtcc1.a libtcc1.o lib-arm64.o
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
|
||||
cp -f libtcc1.a $prefix/lib/tcc
|
||||
fi
|
||||
|
|
35
bootstrap.sh
35
bootstrap.sh
|
@ -32,6 +32,13 @@ case "$mes_cpu" in
|
|||
have_long_long=${have_long_long-true}
|
||||
have_setjmp=${have_setjmp-false}
|
||||
;;
|
||||
riscv*)
|
||||
cpu=riscv64
|
||||
mes_cpu=riscv64
|
||||
tcc_cpu=riscv64
|
||||
triplet=riscv64-unknown-linux-gnu
|
||||
cross_prefix=${triplet}-
|
||||
;;
|
||||
amd64)
|
||||
tcc_cpu=x86_64
|
||||
mes_cpu=x86_64
|
||||
|
@ -81,6 +88,8 @@ elif test "$mes_cpu" = arm; then
|
|||
CPP_TARGET_FLAG="-D TCC_TARGET_ARM=1 -D TCC_ARM_VFP=1 -D CONFIG_TCC_LIBTCC1_MES=1"
|
||||
elif test "$mes_cpu" = x86_64; then
|
||||
CPP_TARGET_FLAG=" -D TCC_TARGET_X86_64=1"
|
||||
elif test "$mes_cpu" = riscv64; then
|
||||
CPP_TARGET_FLAG=" -D TCC_TARGET_RISCV64=1 -D HAVE_LONG_LONG=1"
|
||||
else
|
||||
echo "cpu not supported: $mes_cpu"
|
||||
fi
|
||||
|
@ -172,6 +181,17 @@ if $REBUILD_LIBC; then
|
|||
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
if [ $mes_cpu = riscv64]; then
|
||||
$CC -c $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG lib/lib-arm64.c
|
||||
$CC -c $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG lib/libtcc1.c
|
||||
$AR cr libtcc1.a libtcc1.o lib-arm64.o
|
||||
|
||||
$CC -c $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG -o libtcc1-mes.o $MES_LIB/libtcc1.c
|
||||
# $AR cr libtcc1-mes.a libtcc1-mes.o armeabi.o
|
||||
$AR cr libtcc1-mes.a libtcc1-mes.o
|
||||
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
|
||||
rm -f libgetopt.a
|
||||
cp -f $MES_LIB/libgetopt.c .
|
||||
|
@ -244,6 +264,21 @@ if true; then
|
|||
cp -f libtcc1-tcc.a $prefix/lib/tcc
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
if [ $mes_cpu = riscv64 ]; then
|
||||
$CC -c -g $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG lib/lib-arm64.c
|
||||
|
||||
$CC -c -g $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG -o libtcc1-tcc.o lib/libtcc1.c
|
||||
$AR rc libtcc1-tcc.a libtcc1-tcc.o lib-arm64.o
|
||||
|
||||
$CC -c -g $CPPFLAGS $CFLAGS -D HAVE_FLOAT=1 -D HAVE_LONG_LONG=1 libtcc1-mes.o $MES_LIB/libtcc1.c
|
||||
$AR cr libtcc1-mes.a libtcc1-mes.o lib-arm64.o
|
||||
|
||||
$CC -c -g $CPP_TARGET_FLAG $CFLAGS -o libtcc1.o lib/libtcc1.c
|
||||
$AR cr libtcc1.a libtcc1.o lib-arm64.o
|
||||
|
||||
cp -f libtcc1-tcc.a $prefix/lib/tcc
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
|
||||
rm -f libgetopt.a
|
||||
$CC -c -g $CPPFLAGS $CFLAGS libgetopt.c
|
||||
|
|
22
build.sh
22
build.sh
|
@ -149,6 +149,8 @@ elif test "$mes_cpu" = arm; then
|
|||
CPP_TARGET_FLAG="-D TCC_TARGET_ARM=1 -D TCC_ARM_VFP=1 -D CONFIG_TCC_LIBTCC1_MES=1"
|
||||
elif test "$mes_cpu" = x86_64; then
|
||||
CPP_TARGET_FLAG="-D TCC_TARGET_X86_64=1"
|
||||
elif test "$mes_cpu" = riscv64; then
|
||||
CPP_TARGET_FLAG="-D TCC_TARGET_RISCV64=1 -D CONFIG_TCC_LIBTCC1_MES=1"
|
||||
else
|
||||
echo "cpu not supported: $mes_cpu"
|
||||
fi
|
||||
|
@ -192,6 +194,22 @@ if $REBUILD_LIBC; then
|
|||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
|
||||
if [ $mes_cpu = riscv64 ]; then
|
||||
$CC -c -g $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG lib/lib-arm64.c
|
||||
|
||||
$CC -c -g $CPPFLAGS $CFLAGS $CPP_TARGET_FLAG -o libtcc1-tcc.o lib/libtcc1.c
|
||||
$AR rc libtcc1-tcc.a libtcc1-tcc.o lib-arm64.o
|
||||
|
||||
$CC -c -g $CPPFLAGS $CFLAGS -D HAVE_FLOAT=1 -D HAVE_LONG_LONG=1 -o libtcc1-mes.o $MES_LIB/libtcc1.c
|
||||
$AR cr libtcc1-mes.a libtcc1-mes.o lib-arm64.o
|
||||
|
||||
$CC -c -g $CPP_TARGET_FLAG $CFLAGS -o libtcc1.o lib/libtcc1.c
|
||||
$AR cr libtcc1.a libtcc1.o
|
||||
|
||||
cp -f libtcc1-tcc.a $prefix/lib/tcc
|
||||
cp -f libtcc1-mes.a $prefix/lib/tcc
|
||||
fi
|
||||
|
||||
rm -f libgetopt.a
|
||||
cp -f $MES_LIB/libgetopt.c .
|
||||
$CC -c $CPPFLAGS $CFLAGS libgetopt.c
|
||||
|
@ -208,6 +226,10 @@ else
|
|||
$CC -c $CPPFLAGS $CFLAGS $MES_LIB/libtcc1.c
|
||||
$CC -c $CPPFLAGS $CFLAGS lib/armeabi.c
|
||||
fi
|
||||
if [ $mes_cpu = riscv64]; then
|
||||
$CC -c $CPPFLAGS $CFLAGS $MES_LIB/libtcc1.c
|
||||
$CC -c $CPPFLAGS $CFLAGS lib/lib-arm64.c
|
||||
fi
|
||||
fi
|
||||
|
||||
cp -f libc.a $prefix/lib
|
||||
|
|
6
check.sh
6
check.sh
|
@ -19,6 +19,12 @@ case $arch in
|
|||
triplet=arm-unknown-linux-gnueabihf
|
||||
cross_prefix=${triplet}-
|
||||
;;
|
||||
riscv64*)
|
||||
cpu=riscv64
|
||||
tcc_cpu=riscv64
|
||||
triplet=riscv64-unknown-linux
|
||||
cross_prefix=${triplet}-
|
||||
;;
|
||||
*)
|
||||
cpu=x86
|
||||
tcc_cpu=i386
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(list (channel
|
||||
(name 'guix)
|
||||
(url "https://git.savannah.gnu.org/git/guix.git")
|
||||
(branch "master")
|
||||
(commit
|
||||
"a0d2ecde943bd1854ddbb7c0cad35a1fc64dc5ab")))
|
|
@ -0,0 +1,624 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
|
||||
;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
|
||||
;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
|
||||
;;; Copyright © 2017, 2018, 2019, 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
|
||||
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
|
||||
;;; Copyright © 2018, 2019, 2020, 2021, 2022, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2019-2022 Marius Bakke <marius@gnu.org>
|
||||
;;; Copyright © 2020, 2022 Timothy Sample <samplet@ngyro.com>
|
||||
;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
|
||||
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
|
||||
;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
|
||||
;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;; Copyright © 2022 Ekaitz Zarraga <ekaitz@elenq.tech>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
||||
;;; under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||
;;; your option) any later version.
|
||||
;;;
|
||||
;;; GNU Guix is distributed in the hope that it will be useful, but
|
||||
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (commencement)
|
||||
#:use-module (gnu packages)
|
||||
#:use-module (gnu packages bootstrap)
|
||||
#:use-module (gnu packages autotools)
|
||||
#:use-module (gnu packages base)
|
||||
#:use-module (gnu packages bash)
|
||||
#:use-module (gnu packages c)
|
||||
#:use-module (gnu packages gcc)
|
||||
#:use-module (gnu packages m4)
|
||||
#:use-module (gnu packages gawk)
|
||||
#:use-module (gnu packages bison)
|
||||
#:use-module (gnu packages flex)
|
||||
#:use-module (gnu packages guile)
|
||||
#:use-module (gnu packages gettext)
|
||||
#:use-module (gnu packages multiprecision)
|
||||
#:use-module (gnu packages compression)
|
||||
#:use-module (gnu packages mes)
|
||||
#:use-module (gnu packages perl)
|
||||
#:use-module (gnu packages python)
|
||||
#:use-module (gnu packages linux)
|
||||
#:use-module (gnu packages hurd)
|
||||
#:use-module (gnu packages shells)
|
||||
#:use-module (gnu packages texinfo)
|
||||
#:use-module (gnu packages pkg-config)
|
||||
#:use-module (gnu packages xml)
|
||||
#:use-module (guix gexp)
|
||||
#:use-module (guix packages)
|
||||
#:use-module ((guix store) #:select (%store-monad))
|
||||
#:use-module (guix monads)
|
||||
#:use-module (guix download)
|
||||
#:use-module (guix git-download)
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix build-system trivial)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
#:use-module (guix memoization)
|
||||
#:use-module (guix utils)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (ice-9 popen)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 vlist)
|
||||
#:use-module (ice-9 match)
|
||||
#:export (make-gcc-toolchain))
|
||||
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; This is the commencement, this is where things start. Before the
|
||||
;;; commencement, of course, there's the 'bootstrap' module, which provides us
|
||||
;;; with the initial binaries. This module uses those bootstrap binaries to
|
||||
;;; actually build up the whole tool chain that make up the implicit inputs of
|
||||
;;; 'gnu-build-system'.
|
||||
;;;
|
||||
;;; To avoid circular dependencies, this module should not be imported
|
||||
;;; directly from anywhere.
|
||||
;;;
|
||||
;;; Below, we frequently use "inherit" to create modified packages. The
|
||||
;;; reason why we use "inherit" instead of "package/inherit" is because we do
|
||||
;;; not want these commencement packages to inherit grafts. By definition,
|
||||
;;; these packages are not depended on at run time by any of the packages we
|
||||
;;; use. Thus it does not make sense to inherit grafts. Furthermore, those
|
||||
;;; grafts would often lead to extra overhead for users who would end up
|
||||
;;; downloading those "-boot0" packages just to build package replacements
|
||||
;;; that are in fact not going to be used.
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
(define* (git-fetch-from-tarball tarball)
|
||||
"Return an <origin> method equivalent to 'git-fetch', except that it fetches
|
||||
the checkout from TARBALL, a tarball containing said checkout.
|
||||
|
||||
The purpose of this procedure is to work around bootstrapping issues:
|
||||
'git-fetch' depends on Git, which is much higher in the dependency graph."
|
||||
(lambda* (url hash-algo hash
|
||||
#:optional name
|
||||
#:key (system (%current-system))
|
||||
(guile %bootstrap-guile))
|
||||
(mlet %store-monad ((guile (package->derivation guile system)))
|
||||
(gexp->derivation
|
||||
(or name "git-checkout")
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils)
|
||||
(ice-9 ftw)
|
||||
(ice-9 match))
|
||||
(setenv "PATH"
|
||||
#+(file-append %bootstrap-coreutils&co "/bin"))
|
||||
(invoke "tar" "xf" #$tarball)
|
||||
(match (scandir ".")
|
||||
(("." ".." directory)
|
||||
(copy-recursively directory #$output)))))
|
||||
#:recursive? #t
|
||||
#:hash-algo hash-algo
|
||||
#:hash hash
|
||||
#:system system
|
||||
#:guile-for-build guile
|
||||
#:graft? #f
|
||||
#:local-build? #t))))
|
||||
|
||||
(define bootar
|
||||
(package
|
||||
(name "bootar")
|
||||
(version "1b")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (list (string-append
|
||||
"mirror://gnu/guix/mirror/bootar-" version ".ses")
|
||||
(string-append
|
||||
"https://files.ngyro.com/bootar/bootar-"
|
||||
version ".ses")))
|
||||
(sha256
|
||||
(base32
|
||||
"0cf5vj5yxfvkgzvjvh2l7b2nz5ji5l534n9g4mfp8f5jsjqdrqjc"))))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
`(#:implicit-inputs? #f
|
||||
#:tests? #f
|
||||
#:guile ,%bootstrap-guile
|
||||
#:imported-modules ((guix build gnu-bootstrap)
|
||||
,@%gnu-build-system-modules)
|
||||
#:phases
|
||||
(begin
|
||||
(use-modules (guix build gnu-bootstrap))
|
||||
(modify-phases %standard-phases
|
||||
(replace 'unpack
|
||||
(lambda* (#:key inputs #:allow-other-keys)
|
||||
(let* ((source (assoc-ref inputs "source"))
|
||||
(guile-dir (assoc-ref inputs "guile"))
|
||||
(guile (string-append guile-dir "/bin/guile")))
|
||||
(invoke guile "--no-auto-compile" source)
|
||||
(chdir "bootar"))))
|
||||
(replace 'configure (bootstrap-configure "Bootar" ,version
|
||||
'(".") "scripts"))
|
||||
(replace 'build (bootstrap-build '(".")))
|
||||
(replace 'install (bootstrap-install '(".") "scripts"))))))
|
||||
(inputs `(("guile" ,%bootstrap-guile)))
|
||||
(home-page "https://git.ngyro.com/bootar")
|
||||
(synopsis "Tar decompression and extraction in Guile Scheme")
|
||||
(description "Bootar is a simple Tar extractor written in Guile
|
||||
Scheme. It supports running 'tar xvf' on uncompressed tarballs or
|
||||
tarballs that are compressed with BZip2, GZip, or XZ. It also provides
|
||||
standalone scripts for 'bzip2', 'gzip', and 'xz' that each support
|
||||
decompression to standard output.
|
||||
|
||||
What makes this special is that Bootar is distributed as a
|
||||
self-extracting Scheme (SES) program. That is, a little script that
|
||||
outputs the source code of Bootar. This makes it possible to go from
|
||||
pure Scheme to Tar and decompression in one easy step.")
|
||||
(license license:gpl3+)))
|
||||
|
||||
(define gash-boot
|
||||
(package
|
||||
(inherit gash)
|
||||
(name "gash-boot")
|
||||
(arguments
|
||||
`(#:implicit-inputs? #f
|
||||
#:tests? #f
|
||||
#:guile ,%bootstrap-guile
|
||||
#:imported-modules ((guix build gnu-bootstrap)
|
||||
,@%gnu-build-system-modules)
|
||||
#:phases
|
||||
(begin
|
||||
(use-modules (guix build gnu-bootstrap))
|
||||
(modify-phases %standard-phases
|
||||
(replace 'configure
|
||||
(bootstrap-configure "Gash" ,(package-version gash)
|
||||
'("gash") "scripts"))
|
||||
(replace 'build (bootstrap-build '("gash")))
|
||||
(replace 'install (bootstrap-install '("gash") "scripts"))
|
||||
(add-after 'install 'install-symlinks
|
||||
(lambda* (#:key outputs #:allow-other-keys)
|
||||
(let ((out (assoc-ref outputs "out")))
|
||||
(symlink (string-append out "/bin/gash")
|
||||
(string-append out "/bin/sh"))
|
||||
(symlink (string-append out "/bin/gash")
|
||||
(string-append out "/bin/bash")))))))))
|
||||
(inputs `(("guile" ,%bootstrap-guile)))
|
||||
(native-inputs `(("bootar" ,bootar)))))
|
||||
|
||||
(define gash-utils-boot
|
||||
(package
|
||||
(inherit gash-utils)
|
||||
(name "gash-utils-boot")
|
||||
(arguments
|
||||
`(#:implicit-inputs? #f
|
||||
#:tests? #f
|
||||
#:guile ,%bootstrap-guile
|
||||
#:imported-modules ((guix build gnu-bootstrap)
|
||||
,@%gnu-build-system-modules)
|
||||
#:phases
|
||||
(begin
|
||||
(use-modules (guix build gnu-bootstrap))
|
||||
(modify-phases %standard-phases
|
||||
(add-after 'unpack 'set-load-path
|
||||
(lambda* (#:key inputs #:allow-other-keys)
|
||||
(let ((gash (assoc-ref inputs "gash")))
|
||||
(add-to-load-path (string-append gash "/share/guile/site/"
|
||||
(effective-version))))))
|
||||
(add-before 'configure 'pre-configure
|
||||
(lambda _
|
||||
(format #t "Creating gash/commands/testb.scm~%")
|
||||
(copy-file "gash/commands/test.scm"
|
||||
"gash/commands/testb.scm")
|
||||
(substitute* "gash/commands/testb.scm"
|
||||
(("gash commands test") "gash commands testb")
|
||||
(("apply test [(]cdr") "apply test/bracket (cdr"))
|
||||
(for-each (lambda (script)
|
||||
(let ((target (string-append "scripts/"
|
||||
script ".in")))
|
||||
(format #t "Creating scripts/~a~%" target)
|
||||
(copy-file "scripts/template.in" target)
|
||||
(substitute* target
|
||||
(("@UTILITY@") script))))
|
||||
'("awk" "basename" "cat" "chmod" "cmp" "command"
|
||||
"compress" "cp" "cut" "diff" "dirname" "env"
|
||||
"expr" "false" "find" "grep" "head" "ln" "ls"
|
||||
"mkdir" "mv" "printf" "pwd" "reboot" "rm" "rmdir"
|
||||
"sed" "sleep" "sort" "tar" "test" "touch" "tr"
|
||||
"true" "uname" "uniq" "wc" "which"))
|
||||
(format #t "Creating scripts/[.in~%")
|
||||
(copy-file "scripts/template.in" "scripts/[.in")
|
||||
(substitute* "scripts/[.in"
|
||||
(("@UTILITY@") "testb"))
|
||||
(delete-file "scripts/template.in")))
|
||||
(replace 'configure
|
||||
(bootstrap-configure "Gash-Utils" ,(package-version gash-utils)
|
||||
'("gash" "gash-utils") "scripts"))
|
||||
(replace 'build (bootstrap-build '("gash" "gash-utils")))
|
||||
(replace 'install
|
||||
(bootstrap-install '("gash" "gash-utils") "scripts"))
|
||||
;; XXX: The scripts should add Gash to their load paths and
|
||||
;; this phase should not exist.
|
||||
(add-after 'install 'copy-gash
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(let* ((out (assoc-ref outputs "out"))
|
||||
(moddir (string-append out "/share/guile/site/"
|
||||
(effective-version)))
|
||||
(godir (string-append out "/lib/guile/"
|
||||
(effective-version)
|
||||
"/site-ccache"))
|
||||
(gash (assoc-ref inputs "gash"))
|
||||
(gash-moddir (string-append gash "/share/guile/site/"
|
||||
(effective-version)))
|
||||
(gash-godir (string-append gash "/lib/guile/"
|
||||
(effective-version)
|
||||
"/site-ccache")))
|
||||
(copy-file (string-append gash-moddir "/gash/compat.scm")
|
||||
(string-append moddir "/gash/compat.scm"))
|
||||
(copy-recursively (string-append gash-moddir "/gash/compat")
|
||||
(string-append moddir "/gash/compat"))
|
||||
(copy-file (string-append gash-godir "/gash/compat.go")
|
||||
(string-append godir "/gash/compat.go"))
|
||||
(copy-recursively (string-append gash-godir "/gash/compat")
|
||||
(string-append godir "/gash/compat")))))
|
||||
;; We need an external echo.
|
||||
(add-after 'install 'make-echo
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(let* ((out (assoc-ref outputs "out"))
|
||||
(gash (assoc-ref inputs "gash")))
|
||||
(with-output-to-file (string-append out "/bin/echo")
|
||||
(lambda ()
|
||||
(display (string-append "#!" gash "/bin/gash\n"))
|
||||
(newline)
|
||||
(display "echo \"$@\"")
|
||||
(newline)))
|
||||
(chmod (string-append out "/bin/echo") #o755))))))))
|
||||
(inputs `(("gash" ,gash-boot)
|
||||
("guile" ,%bootstrap-guile)))
|
||||
(native-inputs `(("bootar" ,bootar)))))
|
||||
|
||||
(define (%boot-gash-inputs)
|
||||
`(("bash" , gash-boot) ; gnu-build-system wants "bash"
|
||||
("coreutils" , gash-utils-boot)
|
||||
("bootar" ,bootar)
|
||||
("guile" ,%bootstrap-guile)))
|
||||
|
||||
(define bootstrap-seeds
|
||||
(package
|
||||
(name "bootstrap-seeds")
|
||||
(version "1.0.0")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (list
|
||||
(string-append "mirror://gnu/guix/mirror/"
|
||||
"bootstrap-seeds-" version ".tar.gz")
|
||||
(string-append
|
||||
"https://lilypond.org/janneke/guix/20220501/"
|
||||
"bootstrap-seeds-" version ".tar.gz")))
|
||||
(sha256
|
||||
(base32
|
||||
"0scz2bx8fd8c821h6y1j3x6ywgxxns7iinyn9z32dnkiacfdcpfn"))))
|
||||
(native-inputs (list bootar))
|
||||
(build-system trivial-build-system)
|
||||
(arguments
|
||||
(list #:guile %bootstrap-guile
|
||||
#:modules '((guix build utils))
|
||||
#:builder
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(let ((source #$(package-source this-package))
|
||||
(tar #$(this-package-native-input "bootar"))
|
||||
(out #$output))
|
||||
(setenv "PATH" (string-append tar "/bin:"))
|
||||
(invoke "tar" "xvf" source)
|
||||
(mkdir-p out)
|
||||
(copy-recursively "bootstrap-seeds" out)))))
|
||||
(home-page "https://github.com/oriansj/bootstrap-seeds")
|
||||
(synopsis "The initial bootstrap seeds: 357-byte hex0 and kaem shell")
|
||||
(description
|
||||
"This package provides pre-built binaries of the bootstrap seeds. It
|
||||
contains a hex0-seed and an optional kaem-minimal shell. The size of the hex0
|
||||
seeds are for knight: 250 bytes, x86-linux: 357 bytes, x86_64-linux: 431
|
||||
bytes, and aarch64-linux 526 bytes. These can be used to build stage0: hex0,
|
||||
hex1, hex2, M1, and M2-Planet.")
|
||||
(license license:gpl3+)))
|
||||
|
||||
(define stage0-posix
|
||||
;; The initial bootstrap package: no binary inputs except those from
|
||||
;; `bootstrap-seeds, for x86 a 357 byte binary seed: `x86/hex0-seed'.
|
||||
(package
|
||||
(name "stage0-posix")
|
||||
(version "1.4")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url "https://github.com/oriansj/stage0-posix/")
|
||||
(commit "master")
|
||||
(recursive? #t)))
|
||||
(sha256
|
||||
(base32
|
||||
"0mp0d0q0776571igw62j9hvqy4lq9gb5819wanw0hxi8pyhsk3z6"))))
|
||||
(supported-systems '("i686-linux" "x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"riscv64-linux"))
|
||||
(native-inputs
|
||||
`(("bootstrap-seeds" ,bootstrap-seeds)
|
||||
,@(%boot-gash-inputs)))
|
||||
(build-system trivial-build-system)
|
||||
(arguments
|
||||
(list
|
||||
#:guile %bootstrap-guile
|
||||
#:modules '((guix build utils))
|
||||
#:builder
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(let* ((bootstrap-seeds #$(this-package-native-input
|
||||
"bootstrap-seeds"))
|
||||
(source #$(package-source this-package))
|
||||
(tar #$(this-package-native-input "bootar"))
|
||||
(bash #$(this-package-native-input "bash"))
|
||||
(coreutils #$(this-package-native-input "coreutils"))
|
||||
(guile #$(this-package-input "guile"))
|
||||
(out #$output)
|
||||
(bindir (string-append out "/bin"))
|
||||
(target (or #$(%current-target-system)
|
||||
#$(%current-system)))
|
||||
(stage0-cpu
|
||||
(cond
|
||||
((or #$(target-x86-64?) #$(target-x86-32?))
|
||||
"x86")
|
||||
(#$(target-aarch64?)
|
||||
"AArch64")
|
||||
(#$(target-riscv64?)
|
||||
"riscv64")
|
||||
(else
|
||||
(error "stage0-posix: system not supported" target))))
|
||||
(kaem (string-append "bootstrap-seeds/POSIX/"
|
||||
stage0-cpu "/kaem-optional-seed")))
|
||||
(setenv "PATH" (string-append tar "/bin:"
|
||||
coreutils "/bin:"
|
||||
bash "/bin"))
|
||||
(copy-recursively source "stage0-posix")
|
||||
(chdir "stage0-posix")
|
||||
(invoke kaem (string-append "kaem." stage0-cpu))
|
||||
(with-directory-excursion (string-append stage0-cpu "/bin")
|
||||
(install-file "hex2" bindir)
|
||||
(install-file "M1" bindir)
|
||||
(install-file "blood-elf" bindir)
|
||||
(install-file "kaem" bindir)
|
||||
(install-file "get_machine" bindir)
|
||||
(install-file "M2-Planet" bindir))))))
|
||||
(home-page "https://github.com/oriansj/stage0-posix/")
|
||||
(synopsis "The initial bootstrap package, builds stage0 up to M2-Planet")
|
||||
(description "Starting from the 357-byte hex0-seed binary provided by
|
||||
the bootstrap-seeds, the stage0-posix package first builds hex0 and then all
|
||||
the way up: hex1, catm, hex2, M0, cc_x86, M1, M2, get_machine (that's all of
|
||||
MesCC-Tools), and finally M2-Planet.")
|
||||
(license license:gpl3+)))
|
||||
|
||||
(define mes-boot
|
||||
(package
|
||||
(inherit mes)
|
||||
(name "mes-boot")
|
||||
(version "0.24.2")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url "https://github.com/ekaitz-zarraga/mes/")
|
||||
(commit "wip-riscv")))
|
||||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32
|
||||
"19wkdwqh1bsd1hz3ip2w5q7nnkkddcbpr4cmwh81d95q8zf60rm1"))))
|
||||
(inputs '())
|
||||
(propagated-inputs '())
|
||||
(supported-systems '("i686-linux" "x86_64-linux" "riscv64-linux"))
|
||||
(native-inputs
|
||||
`(("m2-planet" ,stage0-posix)
|
||||
("nyacc-source" ,(bootstrap-origin
|
||||
(origin (inherit (package-source nyacc-1.00.2))
|
||||
(snippet #f))))
|
||||
,@(%boot-gash-inputs)))
|
||||
(arguments
|
||||
(list
|
||||
#:implicit-inputs? #f
|
||||
#:tests? #f
|
||||
#:guile %bootstrap-guile
|
||||
#:strip-binaries? #f ;no strip yet
|
||||
#:phases
|
||||
#~(modify-phases %standard-phases
|
||||
(add-after 'unpack 'unpack-seeds
|
||||
(lambda _
|
||||
(let ((nyacc-source #$(this-package-native-input "nyacc-source")))
|
||||
(with-directory-excursion ".."
|
||||
(invoke "tar" "-xvf" nyacc-source)))))
|
||||
(replace 'configure
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(let ((out #$output)
|
||||
(gash #$(this-package-native-input "bash"))
|
||||
(dir (with-directory-excursion ".." (getcwd))))
|
||||
(setenv "GUILE_LOAD_PATH" (string-append
|
||||
dir "/nyacc-1.00.2/module"))
|
||||
(invoke "gash" "configure.sh"
|
||||
(string-append "--prefix=" out)
|
||||
"--host=riscv64-linux-gnu"))))
|
||||
(replace 'build
|
||||
(lambda _
|
||||
(invoke "gash" "bootstrap.sh")))
|
||||
(delete 'check)
|
||||
(replace 'install
|
||||
(lambda* (#:key outputs #:allow-other-keys)
|
||||
(substitute* "install.sh" ; show some progress
|
||||
((" -xf") " -xvf")
|
||||
(("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
|
||||
(string-append space "echo '" cmd "'\n"
|
||||
space cmd "\n")))
|
||||
(invoke "gash" "install.sh")
|
||||
;; Keep ASCII output, for friendlier comparison and bisection
|
||||
(let* ((out #$output)
|
||||
(cache (string-append out "/lib/cache")))
|
||||
(define (objects-in-dir dir)
|
||||
(find-files dir
|
||||
(lambda (name stat)
|
||||
(and (equal? (dirname name) dir)
|
||||
(or (string-suffix? ".M1" name)
|
||||
(string-suffix? ".hex2" name)
|
||||
(string-suffix? ".o" name)
|
||||
(string-suffix? ".s" name))))))
|
||||
(for-each (lambda (x) (install-file x cache))
|
||||
(append (objects-in-dir "m2")
|
||||
(objects-in-dir ".")
|
||||
(objects-in-dir "mescc-lib")))))))))
|
||||
(native-search-paths
|
||||
(list (search-path-specification
|
||||
(variable "C_INCLUDE_PATH")
|
||||
(files '("include")))
|
||||
(search-path-specification
|
||||
(variable "LIBRARY_PATH")
|
||||
(files '("lib")))
|
||||
(search-path-specification
|
||||
(variable "MES_PREFIX")
|
||||
(separator #f)
|
||||
(files '("")))))))
|
||||
|
||||
|
||||
|
||||
(define %source-dir-this (dirname (dirname (current-filename))))
|
||||
|
||||
(define %git-commit
|
||||
(read-line
|
||||
(open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2 " OPEN_READ)))
|
||||
|
||||
(define (discard-git path stat)
|
||||
(let* ((start (1+ (string-length %source-dir-this)) )
|
||||
(end (+ 4 start)))
|
||||
(not (false-if-exception (equal? ".git" (substring path start end))))))
|
||||
|
||||
(define-public tcc-boot0
|
||||
;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 30
|
||||
;; patches. In a very early and rough form they were presented to the
|
||||
;; TinyCC developers, who at the time showed no interest in supporting the
|
||||
;; bootstrappable effort; we will try again later. These patches have been
|
||||
;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
|
||||
;; mature, this package should use the 0.9.27 sources (or later).
|
||||
;;
|
||||
;;
|
||||
;; TODO: Read and adjust configure.sh and boostrap.sh...
|
||||
(package
|
||||
(inherit tcc)
|
||||
(name "tcc-boot0")
|
||||
(version "0.9.26-1136-g5bba73cc")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (list
|
||||
(string-append "mirror://gnu/guix/mirror/"
|
||||
"tcc-" version ".tar.gz")
|
||||
(string-append "https://lilypond.org/janneke/tcc/"
|
||||
"tcc-" version ".tar.gz")))
|
||||
(sha256
|
||||
(base32
|
||||
"1y2f04qwdqg7dgxiscbf0ibybx2gclniwbbcsxpayazzii2cvji3"))))
|
||||
|
||||
|
||||
(source (local-file %source-dir-this
|
||||
#:recursive? #t
|
||||
#:select? discard-git))
|
||||
(build-system gnu-build-system)
|
||||
(supported-systems '("i686-linux" "x86_64-linux" "riscv64-linux"))
|
||||
(inputs '())
|
||||
(propagated-inputs '())
|
||||
(native-inputs
|
||||
`(("mes" ,mes-boot)
|
||||
("mescc-tools" ,stage0-posix)
|
||||
("nyacc-source" ,(bootstrap-origin
|
||||
(origin (inherit (package-source nyacc-1.00.2))
|
||||
(snippet #f))))
|
||||
,@(%boot-gash-inputs)))
|
||||
(arguments
|
||||
(list
|
||||
#:implicit-inputs? #f
|
||||
#:guile %bootstrap-guile
|
||||
#:validate-runpath? #f ; no dynamic executables
|
||||
#:strip-binaries? #f ; no strip yet
|
||||
#:phases
|
||||
#~(modify-phases %standard-phases
|
||||
(add-after 'unpack 'unpack-extra-sources
|
||||
(lambda* (#:key outputs #:allow-other-keys)
|
||||
(let ((nyacc-source #$(this-package-native-input "nyacc-source")))
|
||||
(with-directory-excursion ".."
|
||||
(invoke "tar" "-xvf" nyacc-source)))))
|
||||
(replace 'configure
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(let* ((out #$output)
|
||||
(dir (with-directory-excursion ".." (getcwd)))
|
||||
(interpreter "/lib/mes-loader")
|
||||
(mes #$(this-package-native-input "mes"))
|
||||
(mescc (string-append mes "/bin/mescc")))
|
||||
(substitute* "conftest.c"
|
||||
(("volatile") ""))
|
||||
(setenv "prefix" out)
|
||||
(setenv "GUILE_LOAD_PATH"
|
||||
(string-append dir "/nyacc-1.00.2/module"))
|
||||
(invoke "sh" "configure"
|
||||
"--cc=mescc"
|
||||
(string-append "--prefix=" out)
|
||||
(string-append "--elfinterp=" interpreter)
|
||||
"--crtprefix=."
|
||||
"--tccdir=."))))
|
||||
(replace 'build
|
||||
(lambda _
|
||||
(setenv "V" "2")
|
||||
(substitute* "bootstrap.sh" ; Show some progress
|
||||
(("^( *)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{program_prefix[}]tcc) [^\"]*[^\\])\n" all space cmd)
|
||||
(string-append space "echo \"" cmd "\"\n"
|
||||
space cmd "\n")))
|
||||
(invoke "sh" "bootstrap.sh")))
|
||||
(replace 'check
|
||||
(lambda _
|
||||
;; fail fast tests
|
||||
(system* "./tcc" "--help") ; --help exits 1
|
||||
;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
|
||||
;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
|
||||
;; TODO: add sensible check target (without depending on make)
|
||||
;; (invoke "sh" "check.sh")
|
||||
))
|
||||
(replace 'install
|
||||
(lambda _
|
||||
(substitute* "install.sh" ; Show some progress
|
||||
(("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
|
||||
(string-append space "echo \"" cmd "\"\n"
|
||||
space cmd "\n")))
|
||||
|
||||
(invoke "sh" "install.sh"))))))
|
||||
(native-search-paths
|
||||
(list (search-path-specification
|
||||
(variable "C_INCLUDE_PATH")
|
||||
(files '("include")))
|
||||
(search-path-specification
|
||||
(variable "LIBRARY_PATH")
|
||||
(files '("lib")))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
tcc-boot0
|
|
@ -209,6 +209,9 @@ ST_FUNC int tcc_tool_ar(TCCState *s1, int argc, char **argv)
|
|||
(sym->st_info == 0x10
|
||||
|| sym->st_info == 0x11
|
||||
|| sym->st_info == 0x12
|
||||
|| sym->st_info == 0x20
|
||||
|| sym->st_info == 0x21
|
||||
|| sym->st_info == 0x22
|
||||
)) {
|
||||
//printf("symtab: %2Xh %4Xh %2Xh %s\n", sym->st_info, sym->st_size, sym->st_shndx, strtab + sym->st_name);
|
||||
istrlen = strlen(strtab + sym->st_name)+1;
|
||||
|
|
Loading…
Reference in New Issue