build: Support mescc-tools 0.5.2.

* configure: Remove version check for mescc-tools.
Check for stage0 architecture flag type.
* configure.sh: Likewise.
* build-aux/build-scaffold.sh: Add stage0 flag type indirection.
* module/mescc/mescc.scm (arch-get-architecture): Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2019-12-07 14:39:19 +01:00
parent 778fbd4f48
commit 82c85c24da
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
9 changed files with 68 additions and 19 deletions

View file

@ -44,13 +44,21 @@ fi
case "$mes_cpu" in
arm)
stage0_cpu=armv7l;;
stage0_arch=40
stage0_cpu=armv7l
;;
x86_64)
stage0_cpu=amd64;;
stage0_arch=2
stage0_cpu=amd64
;;
x86)
stage0_cpu=x86;;
stage0_arch=1
stage0_cpu=x86
;;
*)
stage0_cpu=$mes_cpu;;
stage0_arch=1
stage0_cpu=$mes_cpu
;;
esac
trace "CCLD ${srcdest}lib/$mes_cpu-mes-$compiler/exit-42.S" $CC\
@ -64,9 +72,15 @@ trace "TEST exit-42"
[ $r != 42 ] && echo " => $r"
[ $r = 42 ]
if $numbered_arch; then
stage0_cpu_flag="--Architecture $stage0_arch";
else
stage0_cpu_flag="--architecture $stage0_cpu";
fi
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\
--LittleEndian\
--architecture $stage0_cpu\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\
@ -80,7 +94,7 @@ trace "TEST 0exit-42"
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\
--LittleEndian\
--architecture $stage0_cpu\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\
@ -107,7 +121,7 @@ trace "TEST hello-mes"
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\
--LittleEndian\
--architecture $stage0_cpu\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\
@ -121,7 +135,7 @@ trace "TEST 0hello-mes"
trace "HEX2 ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\
--LittleEndian\
--architecture $stage0_cpu\
$stage0_cpu_flag\
--BaseAddress 0x1000000\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\

View file

@ -116,7 +116,7 @@ fi
LDFLAGS=
${SHELL} ${srcdest}build-aux/build-lib.sh
${SHELL} ${srcdest}build-aux/build-source-lib.sh
if bootstrap; then
if $bootstrap; then
${SHELL} ${srcdest}build-aux/build-mes.sh
fi
)

View file

@ -54,6 +54,7 @@ abs_top_srcdir="@abs_top_srcdir@"
arch="@arch@"
build="@build@"
host="@host@"
numbered_arch=${numbered_arch-"@numbered_arch@"}
bootstrap=${bootstrap-@bootstrap@}
compiler=${compiler-@compiler@}

16
configure vendored
View file

@ -448,9 +448,9 @@ Some influential environment variables:
(deps (fold (lambda (program results)
(cons (check-program-version program) results))
'()
(list (make-dep "hex2" #:version '(0 6))
(make-dep "M1" #:version '(0 6))
(make-dep "blood-elf" #:version '(0 6))
(list (make-dep "hex2")
(make-dep "M1")
(make-dep "blood-elf")
(make-dep "diff" #:optional? #t)
(make-dep "guile" #:version '(2 0) #:commands '("guile-2.2" "guile-2.0" "guile-2" "guile") #:optional? #t)
(make-dep "mes" #:version '(0 20) #:optional? #t)
@ -534,7 +534,13 @@ Some influential environment variables:
(file-name "bash" deps)
(and (file-exists? "/bin/sh") "/bin/sh")
(file-name "sh" deps)
"sh")))
"sh"))
(hex2 (file-name "hex2" deps))
(numbered-arch? (begin
(stdout "checking for stage0 architecture flag... ")
(let ((numbered? (and hex2 (string-contains (gulp-pipe (string-append hex2 " --help 2>&1" )) "--Architecture 12345"))))
(stdout (if numbered? "numbered\n" "named\n"))
numbered?))))
(define* (substitute file-name pairs
#:key (target (if (string-suffix? ".in" file-name)
@ -625,6 +631,7 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g"))
("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") ""))
("@M1FLAGS@" . ,(or (getenv "M1FLAGS") ""))
("@numbered_arch@" . ,(if numbered-arch? "true" "false"))
,@(map
(lambda (o)
@ -687,6 +694,7 @@ GNU Mes is configured for
libc: " mes-libc "
kernel: " mes-kernel "
system: " mes-system "
tools: " (if numbered-arch? "numbered" "named") " arch
Run:
" (or make "./build.sh") " to build mes

View file

@ -99,6 +99,14 @@ if test -z "$GUILE" -o "$GUILE" = true; then
else
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
fi
numbered_arch=false
mes_tools=named
if ( $HEX2 --help 2>&1 ) | grep -q "\-\-Architecture 12345"; then
numbered_arch=true
mes_tools=numbered
fi
bindir=$(eval echo ${bindir-$prefix/bin})
datadir=$(eval echo ${datadir-$prefix/share})
docdir=$(eval echo ${docdir-$datadir/doc/mes})
@ -164,6 +172,7 @@ subst () {
-e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
-e s,"@MES_SEED@,$MES_SEED,"\
-e s,"@MES_SEED@,$MES_SEED,"\
-e s,"@numbered_arch@,$numbered_arch,"\
-e s,"@SHELL@,$SHELL,"\
$1 > $2
}
@ -259,6 +268,7 @@ GNU Mes is configured for
libc: $mes_libc
kernel: $mes_kernel
system: $mes_system
tools: $mes_tools arch
Run:
sh build.sh to build mes

View file

@ -41,6 +41,7 @@
(define %includedir (getenv "%includedir"))
(define %libdir (getenv "%libdir"))
(define %version (getenv "%version"))
(define %numbered-arch? (and=> (getenv "%numbered_arch") (lambda (x) (equal? x "true"))))
(when (and=> (getenv "V") (lambda (v) (and (= (string-length v) 1) (> (string->number v) 1))))
(format (current-error-port) "mescc[~a]...\n" %scheme))
@ -75,6 +76,7 @@
(nostartfiles)
(nostdinc)
(nostdlib)
(numbered-arch?)
(preprocess (single-char #\E))
(static)
(std (value #t))
@ -103,6 +105,7 @@ Options:
-dumpmachine display the compiler's target machine
--base-address=ADRRESS
use BaseAddress ADDRESS [0x1000000]
--numbered-arch mescc-tools use numbered arch
-D DEFINE[=VALUE] define DEFINE [VALUE=1]
-E preprocess only; do not compile, assemble or link
-g add debug info [GDB, objdump] TODO: hex2 footer
@ -164,6 +167,8 @@ General help using GNU software: <http://gnu.org/gethelp/>
(options (acons 'libdir %libdir options))
(arch (option-ref options 'arch %host-arch))
(options (if arch (acons 'arch arch options) options))
(numbered-arch? (option-ref options 'numbered-arch? %numbered-arch?))
(options (acons 'numbered-arch? numbered-arch? options))
(dumpmachine? (option-ref options 'dumpmachine #f))
(preprocess? (option-ref options 'preprocess #f))
(compile? (option-ref options 'compile #f))

View file

@ -186,7 +186,7 @@
(M1 (or (getenv "M1") "M1"))
(command `(,M1
"--LittleEndian"
"--architecture" ,(arch-get-architecture options)
,@(arch-get-architecture options)
"-f" ,(arch-find options (arch-get-m1-macros options))
,@(append-map (cut list "-f" <>) M1-files)
"-o" ,hex2-file-name)))
@ -211,7 +211,7 @@
`("-f" ,(arch-find options "crt1.o"))))
(command `(,hex2
"--LittleEndian"
"--architecture" ,(arch-get-architecture options)
,@(arch-get-architecture options)
"--BaseAddress" ,base-address
"-f" ,(arch-find options (string-append "elf" machine "-header.hex2"))
,@start-files
@ -322,10 +322,13 @@
((equal? arch "x86_64") "x86_64.M1"))))
(define (arch-get-architecture options)
(let ((arch (arch-get options)))
(cond ((equal? arch "arm") "armv7l")
((equal? arch "x86") "x86")
((equal? arch "x86_64") "amd64"))))
(let* ((arch (arch-get options))
(numbered-arch? (option-ref options 'numbered-arch? #f))
(flag (if numbered-arch? "--Architecture" "--architecture")))
(list flag
(cond ((equal? arch "arm") (if numbered-arch? "40" "armv7l"))
((equal? arch "x86") (if numbered-arch? "1" "x86"))
((equal? arch "x86_64") (if numbered-arch? "2" "amd64"))))))
(define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))
(define (count-opt options option-name)

View file

@ -43,6 +43,8 @@ includedir=${includedir-@includedir@}
export includedir
libdir=${libdir-@libdir@}
export libdir
numbered_arch=${numbered_arch=@numbered_arch@}
export numbered_arch
if [ ! -f $bindir/mescc.scm ]; then
bindir=$(dirname $0)

View file

@ -41,11 +41,17 @@
(define %arch (if (string-prefix? "@mes_cpu" "@mes_cpu@") %arch
"@mes_cpu@"))
(define %numbered-arch? (if (getenv "numbered_arch") (and=> (getenv "numbered_arch")
(lambda (x) (equal? x "true")))
(if (string-prefix? "@numbered_arch" "@numbered_arch@") #f
(equal? "@numbered_arch@" "true"))))
(setenv "%prefix" %prefix)
(setenv "%includedir" %includedir)
(setenv "%libdir" %libdir)
(setenv "%version" %version)
(setenv "%arch" %arch)
(setenv "%numbered_arch" (if %numbered-arch? "true" "false"))
(cond-expand
(mes