[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
17/26: commencement: tcc-boot: Support ARM.
From: |
guix-commits |
Subject: |
17/26: commencement: tcc-boot: Support ARM. |
Date: |
Tue, 12 Jan 2021 13:49:15 -0500 (EST) |
janneke pushed a commit to branch wip-arm-bootstrap
in repository guix.
commit 898e46727d17bc068743470048cfc037496fecf0
Author: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
AuthorDate: Sun Dec 13 15:00:06 2020 +0100
commencement: tcc-boot: Support ARM.
* gnu/packages/commencement.scm (tcc-boot)[arguments]: Cater for
armhf-linux,
aarch64-linux.
[supported-systems]: Add aarch64-linux, armhf-linux.
---
gnu/packages/commencement.scm | 146 +++++++++++++++++++++++++++++++-----------
1 file changed, 110 insertions(+), 36 deletions(-)
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 9b9d30f..c14cf54 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -855,11 +855,14 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
;; `patches' needs XZ
;; (patches (search-patches "tcc-boot-0.9.27.patch"))
))
+ (supported-systems '("armhf-linux" "aarch64-linux"
+ "i686-linux" "x86_64-linux"))
(build-system gnu-build-system)
(inputs '())
(propagated-inputs '())
(native-inputs `(;;("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
("bzip2" ,bzip2-mesboot)
+ ("mes" ,mes-boot)
,@(%boot-tcc0-inputs)))
(arguments
`(#:implicit-inputs? #f
@@ -888,45 +891,81 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
(("s->alacarte_link = 1;" all)
(string-append all "
s->static_link = 1;")))
+ (substitute* "tccelf.c"
+ (("tcc_add_support\\(s1, TCC_LIBTCC1\\);" all)
+ (string-append all "
+#if CONFIG_TCC_LIBTCC1_MES
+ tcc_add_support(s1, TCC_LIBTCC1_MES);
+#endif
+")))
+ ,@(match (%current-system)
+ ((or "armhf-linux" "aarch64-linux")
+ '((substitute* "tccelf.c"
+ ;; This fixes
+ ;; "cannot execute binary file: Exec format error"
+ ;; when building on aarch64-linux for ARM
+ (("#ifdef TCC_ARM_EABI")
+ "#if defined (TCC_ARM_EABI) || BOOTSTRAP"))))
+ ((or "i686-linux" "x86_64-linux")
+ '()))
#t))
(replace 'configure
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref %outputs "out"))
(tcc (assoc-ref %build-inputs "tcc"))
(libc (assoc-ref %build-inputs "libc"))
- (interpreter "/mes/loader"))
- (invoke "sh" "configure"
- (string-append "--cc=tcc")
- (string-append "--cpu=i386")
- (string-append "--prefix=" out)
- (string-append "--elfinterp=" interpreter)
- (string-append "--crtprefix=" tcc "/lib")
- (string-append "--sysincludepaths=" tcc "/include")
- (string-append "--libpaths=" tcc "/lib")))))
+ (interpreter "/mes/loader")
+ (configure-flags
+ (list "--cc=tcc"
+ ,@(match (%current-system)
+ ((or "i686-linux" "x86_64-linux")
'("--cpu=i386"))
+ ((or "armhf-linux" "aarch64-linux")
'("--cpu=arm")))
+ (string-append "--prefix=" out)
+ (string-append "--elfinterp=" interpreter)
+ (string-append "--crtprefix=" tcc "/lib")
+ (string-append "--sysincludepaths=" tcc "/include")
+ (string-append "--libpaths=" tcc "/lib"))))
+ (format (current-error-port)
+ "running ./configure ~a\n" (string-join
configure-flags))
+ (apply invoke "sh" "configure" configure-flags))))
(replace 'build
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref %outputs "out"))
(tcc (assoc-ref %build-inputs "tcc"))
(libc (assoc-ref %build-inputs "libc"))
- (interpreter "/mes/loader"))
- (invoke
- "tcc"
- "-vvv"
- "-D" "BOOTSTRAP=1"
- "-D" "ONE_SOURCE=1"
- "-D" "TCC_TARGET_I386=1"
- "-D" "CONFIG_TCC_STATIC=1"
- "-D" "CONFIG_USE_LIBGCC=1"
- "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
- "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out
"/lib:{B}/lib:.\"")
- "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out
"/lib:{B}/lib:.\"")
- "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
- "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc
"/lib:{B}/lib:.\"")
- "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
- tcc "/include" ":/include:{B}/include\"")
- "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
- "-o" "tcc"
- "tcc.c"))))
+ (interpreter "/mes/loader")
+ (cppflags
+ (list
+ "-D" "BOOTSTRAP=1"
+ "-D" "ONE_SOURCE=1"
+ ,@(match (%current-system)
+ ((or "i686-linux" "x86_64-linux")
+ '("-D" "TCC_TARGET_I386=1"))
+ ((or "armhf-linux" "aarch64-linux")
+ '("-D" "TCC_TARGET_ARM=1"
+ "-D" "TCC_ARM_VFP=1"
+ "-D" "CONFIG_TCC_LIBTCC1_MES=1")))
+ "-D" "CONFIG_TCCBOOT=1"
+ "-D" "CONFIG_TCC_STATIC=1"
+ "-D" "CONFIG_USE_LIBGCC=1"
+ "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
+ "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out
"/lib:{B}/lib:.\"")
+ "-D" (string-append "CONFIG_TCC_ELFINTERP=\""
interpreter "\"")
+ "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc
"/lib:{B}/lib:{B}/lib/tcc:.\"")
+ "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
+ tcc "/include"
":/include:{B}/include\"")
+ "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
+ "-D" (string-append
"TCC_LIBTCC1_MES=\"libtcc1-mes.a\"")))
+ (files ',(match (%current-system)
+ ((or "i686-linux" "x86_64-linux")
+ '("tcc.c"))
+ ((or "armhf-linux" "aarch64-linux")
+ '("tcc.c" "lib/armflush.c"))))
+ (arguments (cons* "-vvv" "-g" "-o" "tcc"
+ (append cppflags files))))
+ (format (current-error-port)
+ "running tcc ~a\n" (string-join arguments))
+ (apply invoke "tcc" arguments))))
(replace 'check
(lambda _
;; FIXME: add sensible check target (without depending on make)
@@ -935,8 +974,16 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref %outputs "out"))
- (tcc (assoc-ref %build-inputs "tcc")))
- (and
+ (tcc (assoc-ref %build-inputs "tcc"))
+ (mes (assoc-ref %build-inputs "mes"))
+ (cppflags '(,@(match (%current-system)
+ ((or "armhf-linux" "aarch64-linux")
+ '("-D" "TCC_TARGET_ARM=1"
+ "-D" "TCC_ARM_VFP=1"))
+ ((or "i686-linux" "x86_64-linux")
+ '("-D" "TCC_TARGET_I386=1")))
+ "-D HAVE_FLOAT=1"
+ "-D HAVE_LONG_LONG=1")))
(mkdir-p (string-append out "/bin"))
(copy-file "tcc" (string-append out "/bin/tcc"))
(mkdir-p (string-append out "/lib/tcc"))
@@ -944,12 +991,39 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
(string-append out "/include"))
(copy-recursively (string-append tcc "/lib")
(string-append out "/lib"))
- (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o"
"lib/libtcc1.c")
- (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
- (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
- (delete-file (string-append out "/lib/tcc/libtcc1.a"))
- (copy-file "libtcc1.a" (string-append out
"/lib/tcc/libtcc1.a"))
- #t)))))))))
+ ,@(match (%current-system)
+ ((or "armhf-linux" "aarch64-linux")
+ '((format (current-error-port) "compiling...\n")
+ (format (current-error-port) "cpp-flags=~s\n" cppflags)
+
+ (delete-file (string-append out "/lib/tcc/libtcc1.a"))
+ (apply invoke "./tcc" "-c" "-o" "libtcc1.o"
"lib/libtcc1.c" cppflags)
+ (apply invoke "./tcc" "-c" "-o" "armeabi.o"
"lib/armeabi.c" cppflags)
+ (invoke "./tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o"
"armeabi.o")
+ (copy-file "libtcc1.a" (string-append out
"/lib/tcc/libtcc1.a"))
+
+ (delete-file (string-append out
"/lib/tcc/libtcc1-mes.a"))
+ (apply invoke "./tcc" "-c" "-o" "libtcc1-mes.o"
+ (string-append mes "/lib/libtcc1.c") cppflags)
+ (invoke "./tcc" "-ar" "rc" "libtcc1-mes.a"
+ "libtcc1-mes.o" "armeabi.o")
+ (copy-file "libtcc1-mes.a"
+ (string-append out "/lib/tcc/libtcc1-mes.a"))
+
+ (delete-file (string-append out "/lib/libc.a"))
+ (apply invoke "./tcc" "-c" "-o" "libc.o"
+ "-I" (string-append tcc "/include")
+ "-I" (string-append tcc "/include/linux/arm")
+ (string-append mes "/lib/libc+gnu.c")
+ cppflags)
+ (invoke "./tcc" "-ar" "rc" "libc.a" "libc.o")
+ (copy-file "libc.a" (string-append out "/lib/libc.a"))))
+ ((or "i686-linux" "x86_64-linux")
+ '((delete-file (string-append out
"/lib/tcc/libtcc1.a"))
+ (apply invoke "./tcc" "-c" "-o" "libtcc1.o"
"lib/libtcc1.c" cppflags)
+ (invoke "./tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
+ (copy-file "libtcc1.a" (string-append out
"/lib/tcc/libtcc1.a")))))
+ #t))))))))
(define diffutils-mesboot
;; The initial diffutils.
- 08/26: DRAFT bootstrap: %bootstrap-mes: Support ARM., (continued)
- 08/26: DRAFT bootstrap: %bootstrap-mes: Support ARM., guix-commits, 2021/01/12
- 07/26: DRAFT bootstrap: %bootstrap-mescc-tools: Support ARM., guix-commits, 2021/01/12
- 15/26: commencement: bzip2-mesboot: Support ARM., guix-commits, 2021/01/12
- 03/26: gnu: mes: Update to nyacc-1.00.2., guix-commits, 2021/01/12
- 13/26: commencement: gzip-mesboot: Support ARM., guix-commits, 2021/01/12
- 19/26: commencement: patch-mesboot: Support ARM., guix-commits, 2021/01/12
- 04/26: DRAFT gnu: mes: Update to 0.22-123-g9cd754498., guix-commits, 2021/01/12
- 06/26: bootstrap: mes-minimal: Support ARM, update for mes-0.23., guix-commits, 2021/01/12
- 11/26: commencement: mes-boot: Support ARM., guix-commits, 2021/01/12
- 14/26: commencement: make-mesboot0: Support ARM., guix-commits, 2021/01/12
- 17/26: commencement: tcc-boot: Support ARM.,
guix-commits <=
- 25/26: commencement: glibc-mesboot0: Support ARM., guix-commits, 2021/01/12
- 02/26: gnu: Add nyacc-1.00.2., guix-commits, 2021/01/12
- 09/26: commencement: gash-boot: Build fix for ARM., guix-commits, 2021/01/12
- 18/26: commencement: diffutils-mesboot: Support ARM., guix-commits, 2021/01/12
- 01/26: gnu: mescc-tools: Update to 0.7.0., guix-commits, 2021/01/12
- 10/26: commencement: bootstrap-mes-rewired: Support ARM., guix-commits, 2021/01/12
- 12/26: commencement: tcc-boot0: Support ARM, update to 0.9.26-1136-g0fbeb2dd., guix-commits, 2021/01/12
- 16/26: commencement: bash-mesboot0: Support ARM., guix-commits, 2021/01/12
- 21/26: commencement: binutils-mesboot0: Support ARM., guix-commits, 2021/01/12
- 20/26: commencement: sed-mesboot0: Support ARM., guix-commits, 2021/01/12