ref: cfa8ebf26de75bc6c13ba4a872e1c9e4f12de3c4
parent: 87721662939577c4589ee5296640ceb62d8f6283
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 19 06:18:37 EST 2020
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.
--- a/Makefile
+++ b/Makefile
@@ -7,11 +7,11 @@
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
--- a/config/tool/gnu.mk
+++ b/config/tool/gnu.mk
@@ -9,4 +9,4 @@
ARCHIVEFLAGS = -U
NOPIE_CFLAGS = -nopie
NOPIE_LDFLAGS = -nopie
-TOOLCFLAGS = -std=c99
+TOOLCFLAGS = -std=c99 -fno-stack-protector -static
--- /dev/null
+++ b/scripts/config
@@ -1,0 +1,13 @@
+#!/bin/sh
+
+case `uname` in
+*BSD)
+ echo TOOL=gnu HOST=bsd
+ ;;
+Linux)
+ echo TOOL=gnu
+ ;;
+Plan9)
+ echo HOST=plan9
+ ;;
+esac
--- a/scripts/host
+++ /dev/null
@@ -1,13 +1,0 @@
-#!/bin/sh
-
-case `uname` in
-*BSD)
- echo bsd
- ;;
-Plan9)
- echo plan9
- ;;
-*)
- echo unix
- ;;
-esac
--- a/src/libc/rules.mk
+++ b/src/libc/rules.mk
@@ -6,7 +6,7 @@
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 = \
--- a/tests/libc/execute/Makefile
+++ b/tests/libc/execute/Makefile
@@ -10,7 +10,7 @@
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`
--- a/tests/libc/execute/cc.sh
+++ b/tests/libc/execute/cc.sh
@@ -22,7 +22,7 @@
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 @@
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 @@
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