scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 76df51d8984e56b5353000583a80b731c5e88330
parent fe8418f0998293be3c03ce8d0fd55788fa1a6573
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Jan 2020 11:18:37 +0100

build: Fix compilation for tests

If we want to be able to test easilly we have to remove
some gcc capabilities while we build the libc. For this
reason, it is better if we set the toolchain based in
the the system.

Diffstat:
MMakefile | 10+++++-----
Mconfig/tool/gnu.mk | 2+-
Ascripts/config | 13+++++++++++++
Dscripts/host | 13-------------
Msrc/libc/rules.mk | 2+-
Mtests/libc/execute/Makefile | 2+-
Mtests/libc/execute/cc.sh | 5+++--
7 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/Makefile b/Makefile @@ -7,11 +7,11 @@ PREFIX= /usr/local DIRS = src src/libc include/scc/scc tests all: - +@$(MAKE) HOST=`$(SCRIPTDIR)/host` toolchain - +@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-linux libc - +@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-openbsd libc - +@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-netbsd libc - +@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-dragonfly libc + +@$(MAKE) `$(SCRIPTDIR)/config` toolchain + +@$(MAKE) `$(SCRIPTDIR)/config` CONF=amd64-linux libc + +@$(MAKE) `$(SCRIPTDIR)/config` CONF=amd64-openbsd libc + +@$(MAKE) `$(SCRIPTDIR)/config` CONF=amd64-netbsd libc + +@$(MAKE) `$(SCRIPTDIR)/config` CONF=amd64-dragonfly libc toolchain: dirs src diff --git a/config/tool/gnu.mk b/config/tool/gnu.mk @@ -9,4 +9,4 @@ ARCHIVE = ar ARCHIVEFLAGS = -U NOPIE_CFLAGS = -nopie NOPIE_LDFLAGS = -nopie -TOOLCFLAGS = -std=c99 +TOOLCFLAGS = -std=c99 -fno-stack-protector -static diff --git a/scripts/config b/scripts/config @@ -0,0 +1,13 @@ +#!/bin/sh + +case `uname` in +*BSD) + echo TOOL=gnu HOST=bsd + ;; +Linux) + echo TOOL=gnu + ;; +Plan9) + echo HOST=plan9 + ;; +esac diff --git a/scripts/host b/scripts/host @@ -1,13 +0,0 @@ -#!/bin/sh - -case `uname` in -*BSD) - echo bsd - ;; -Plan9) - echo plan9 - ;; -*) - echo unix - ;; -esac diff --git a/src/libc/rules.mk b/src/libc/rules.mk @@ -6,7 +6,7 @@ INCLUDE =\ SYSERRNO = $(INCDIR)/bits/$(SYS)/sys/errno.h LIBC = $(LIBCDIR)/libc.a -CRT = $(LIBCDIR)/libcrt.o +CRT = $(LIBCDIR)/crt.o LIBCLST= $(PROJECTDIR)/src/libc/libc.lst MKLST = \ diff --git a/tests/libc/execute/Makefile b/tests/libc/execute/Makefile @@ -10,7 +10,7 @@ CC = SCCPREFIX=$(ROOT) ./cc.sh all: tests tests: - @CFLAGS='' SCCPREFIX=$(ROOT) ./chktest.sh libc-tests.lst + @SCCPREFIX=$(ROOT) ./chktest.sh libc-tests.lst clean: rm -f *.o *core test.log `awk '{print $$1}' libc-tests.lst` diff --git a/tests/libc/execute/cc.sh b/tests/libc/execute/cc.sh @@ -22,7 +22,7 @@ do shift 2 ;; -*) - echo usage: cc.sh [-t target] file + echo usage: cc.sh [-o outfile][-r root][-a abi][-s sys] file exit 1 ;; esac @@ -36,6 +36,7 @@ inc=$root/include arch_inc=$inc/bits/$abi sys_inc=$inc/bits/$sys lib=$root/lib/scc/${abi}-${sys} +crt=$root/lib/scc/${abi}-${sys}/crt.o obj=${1%.c}.o cc=${CROSS_COMPILE}gcc ld=${CROSS_COMPILE}ld @@ -49,4 +50,4 @@ then fi ${cc} $flags $pie $includes -c $1 -${ld} -g -z nodefaultlib -static -L$lib $obj -lc -lcrt -o $out +${ld} -g -z nodefaultlib -static -L$lib $obj $crt -lc -lcrt -o $out