changes for detecting and building for clang/binutils elf

and minor fixes:
 . add ack/clean target to lib, 'unify' clean target
 . add includes as library dependency
 . mk: exclude warning options clang doesn't have in non-gcc
 . set -e in lib/*.sh build files
 . clang compile error circumvention (disable NOASSERTS for release builds)
This commit is contained in:
Ben Gras 2011-06-07 14:48:31 +02:00
parent ef257bcc1b
commit 230b7775fe
15 changed files with 96 additions and 52 deletions

1
.gitignore vendored
View file

@ -15,6 +15,7 @@ cscope.*
.depend
obj-ack
obj-gnu
obj-elf-base
tools/revision
TAGS
tags

View file

@ -12,13 +12,18 @@ usage:
@echo "Usage:"
@echo " make world # Compile everything (libraries & commands)"
@echo " make includes # Install include files from src/"
@echo " make libraries # Compile and install libraries"
@echo " make libraries # Compile and install libraries (ack)"
.ifdef MINIX_GENERATE_ELF
@echo " make elf-libraries # Compile and install gcc/clang elf libs"
.endif
@echo " make commands # Compile all, commands, but don't install"
@echo " make install # Compile and install commands"
@echo " make depend # Generate required .depend files"
@echo " make gnu-includes # Install include files for GCC"
.ifndef MINIX_GENERATE_ELF
@echo " make gnu-libraries # Compile and install libraries for GCC"
@echo " make clang-libraries # Compile and install libraries for GCC with clang"
.endif
@echo " make clean # Remove all compiler results"
@echo ""
@echo "Run 'make' in tools/ to create a new MINIX configuration."
@ -32,6 +37,9 @@ usage:
# 'make install' target.
#
# etcfiles has to be done first.
.ifdef MINIX_GENERATE_ELF
world: mkfiles includes depend libraries elf-libraries install etcforce
.else
.if ${COMPILER_TYPE} == "ack"
world: mkfiles includes depend libraries install etcforce
.elif ${COMPILER_TYPE} == "gnu"
@ -41,6 +49,7 @@ world: mkfiles includes depend gnu-libraries install etcforce
world: mkfiles elf-includes depend elf-libraries install etcforce
.endif
.endif
.endif
mkfiles:
make -C share/mk install
@ -60,19 +69,21 @@ gnu-includes: includes
SHELL=/bin/sh; if [ -f $(MKHEADERS443) ] ; then sh -e $(MKHEADERS443) ; fi
SHELL=/bin/sh; if [ -f $(MKHEADERS443_PKGSRC) ] ; then sh -e $(MKHEADERS443_PKGSRC) ; fi
.ifndef MINIX_GENERATE_ELF
gnu-libraries: #gnu-includes
$(MAKE) -C lib build_gnu
clang-libraries: includes
$(MAKE) -C lib build_clang
.endif
MKHEADERS443_ELF=/usr/gnu_cross/libexec/gcc/i386-pc-minix3/4.4.3/install-tools/mkheaders
elf-includes: includes
cp -r /usr/include/* /usr/gnu_cross/i386-pc-minix3/sys-include
SHELL=/bin/sh; if [ -f $(MKHEADERS443_ELF) ] ; then sh -e $(MKHEADERS443_ELF) ; fi
.ifdef MINIX_GENERATE_ELF
elf-libraries: includes
$(MAKE) -C lib build_elf_base
.else
elf-libraries: elf-includes
$(MAKE) -C lib build_elf
.endif
commands: includes libraries
$(MAKE) -C commands all
@ -106,10 +117,7 @@ clean:
$(MAKE) -C boot clean
$(MAKE) -C commands clean
$(MAKE) -C tools clean
$(MAKE) -C lib clean_gnu
$(MAKE) -C lib clean_ack
$(MAKE) -C lib clean_elf
$(MAKE) -C lib clean_clang
$(MAKE) -C lib clean_all
$(MAKE) -C test clean
cleandepend:

View file

@ -34,13 +34,11 @@ then GNM=gnm
else GNM=nm
fi
ELFNM=/usr/gnu_cross/bin/i386-pc-minix3-nm
# Invoke gnu nm or ack nm?
if file $executable | grep NSYM >/dev/null 2>&1
then NM="$GNM --radix=d"
elif file $executable | grep ELF >/dev/null 2>&1
then NM="$ELFNM --radix=d"
then NM="$GNM --radix=d"
else NM="acknm -d"
fi

View file

@ -3,7 +3,7 @@
/* Minix release and version numbers. */
#define OS_RELEASE "3"
#define OS_VERSION "1.9"
#define OS_VERSION "2.0"
/* This file sets configuration parameters for the MINIX kernel, FS, and PM.
* It is divided up into two main sections. The first section contains

View file

@ -1,3 +1,12 @@
20110228:
(Next release bumped to MINIX 3.2.0.)
ELF support in the base system. /usr/lib libraries
will be in ELF format once you upgrade.
These were know as 'gcc format', but now more properly refered
to as 'elf format,' as they are shared between gcc and clang.
To start producing ELF, please see:
http://wiki.minix3.org/en/UsersGuide/ELFSwitch
20110225:
Create ddekit include dirs:
mkdir -p /usr/include/ddekit/minix

View file

@ -9,8 +9,10 @@
#include "debug.h"
/* Translate an endpoint number to a process number, return success. */
#ifndef isokendpt
#define isokendpt(e,p) isokendpt_d((e),(p),0)
#define okendpt(e,p) isokendpt_d((e),(p),1)
#endif
/* Constants used in virtual_copy(). Values must be 0 and 1, respectively. */
#define _SRC_ 0

View file

@ -18,23 +18,17 @@ SUBDIR+= libend
build_ack:
sh ack_build.sh obj depend all install
.if defined(MINIX_GENERATE_ELF)
build_elf_base:
sh elf_build_base.sh obj depend all install
.else
build_gnu:
sh gnu_build.sh obj depend all install
.endif
build_clang:
sh clang_build.sh obj depend all install
build_elf:
sh elf_build.sh obj depend all install
clean_ack:
clean_all:
sh ack_build.sh clean
clean_gnu:
sh gnu_build.sh clean
clean_elf:
sh elf_build.sh clean
clean_clang:
sh clang_build.sh clean
sh gnu_build.sh clean
sh elf_build_base.sh clean
sh elf_build.sh clean

View file

@ -1,5 +1,7 @@
#!/bin/sh
set -e
export CC=cc
export MAKEOBJDIR=obj-ack

View file

@ -1,8 +1,15 @@
#!/bin/sh
# This file is obsolete and is only useful to 'clean' its objects.
export CC=i386-pc-minix3-gcc
export COMPILER_TYPE=gnu
export MAKEOBJDIR=obj-elf
export PATH=$PATH:/usr/gnu_cross/bin
if [ "$@" != clean ]
then echo "$0: Unexpected arguments $@"
exit 1
fi
make $@

10
lib/elf_build_base.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
set -e
export CC=clang
export COMPILER_TYPE=gnu
export MAKEOBJDIR=obj-elf-base
export PATH=$PATH:/usr/pkg/bin
make $@

View file

@ -484,7 +484,7 @@ INFOGRP?= operator
INFOOWN?= root
INFOMODE?= ${NONBINMODE}
#LIBDIR?= /usr/lib
LIBDIR?= /usr/lib
.if ${COMPILER_TYPE} == "ack"
LIBDIR?= /usr/lib/i386
.endif
@ -535,20 +535,16 @@ DEBUGMODE?= ${NONBINMODE}
# All platforms are ELF.
#
#OBJECT_FMT= ELF
.if !empty(CC:Mi386-pc-minix3-gcc) || !empty(CC:Mclang)
.if defined(MINIX_GENERATE_ELF) && ${COMPILER_TYPE} == "gnu"
OBJECT_FMT= ELF
.else
OBJECT_FMT= a.out
.endif
.if ${COMPILER_TYPE} == "gnu"
.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no")
LIBDIR?= /usr/netbsd/lib
.endif
.if ${OBJECT_FMT} == "a.out"
LIBDIR?= /usr/lib
.elif ${OBJECT_FMT} == "ELF"
LIBDIR?= /usr/gnu_cross/i386-pc-minix3/lib
.endif
.endif
#

View file

@ -15,8 +15,11 @@ CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
# in a traditional environment' warning, as opposed to 'this code behaves
# differently in traditional and ansi environments' which is the warning
# we wanted, and now we don't get anymore.
CFLAGS+= -Wno-sign-compare -Wno-traditional
.if !defined(NOGCCERROR)
CFLAGS+= -Wno-sign-compare
.if !empty(CC:Mgcc)
CFLAGS+= -Wno-traditional
.endif
.if !defined(NOGCCERROR) && !empty(CC:Mgcc)
# Set assembler warnings to be fatal
CFLAGS+= -Wa,--fatal-warnings
.endif
@ -24,7 +27,8 @@ CFLAGS+= -Wa,--fatal-warnings
# XXX no proper way to avoid "FOO is a patented algorithm" warnings
# XXX on linking static libs
.if (!defined(MKPIC) || ${MKPIC} != "no") && \
(!defined(LDSTATIC) || ${LDSTATIC} != "-static")
(!defined(LDSTATIC) || ${LDSTATIC} != "-static") \
&& !empty(CC:Mgcc)
LDFLAGS+= -Wl,--fatal-warnings
.endif
.endif

View file

@ -228,16 +228,17 @@ YACC.y?= ${YACC} ${YFLAGS}
# chmod a+x ${.TARGET}
# MINIX
.if !empty(CC:Mcc)
COMPILER_TYPE=ack
.elif !empty(CC:Mgcc)
.elif !empty(CC:Mgcc) || !empty(CC:Mclang)
COMPILER_TYPE=gnu
AR=ar
.elif !empty(CC:Mi386-pc-minix3-gcc) || !empty(CC:Mclang)
COMPILER_TYPE=gnu
AR=i386-pc-minix3-ar
LD=i386-pc-minix3-ld
OBJCOPY=i386-pc-minix3-objcopy
.endif
.if exists(/usr/pkg/i386-pc-minix/lib/ldscripts/elf_i386_minix.x) \
&& exists(/usr/pkg/lib/clang/2.9)
MINIX_GENERATE_ELF=yes
.endif
# Set NBSD_LIBC to either "yes" or "no".

View file

@ -8,7 +8,7 @@ then make $@
exit $?
fi
make NOASSERTS=yes world
make world
cd tools
rm revision
rm /boot/image/*

View file

@ -18,6 +18,7 @@ secs=`expr 32 '*' 64`
export SHELL=/bin/sh
PKG_ADD=/usr/pkg/sbin/pkg_add
PKG_INFO=/usr/pkg/sbin/pkg_info
if [ ! -x $PKG_ADD ]
then echo Please install pkg_install from pkgsrc.
@ -25,8 +26,17 @@ then echo Please install pkg_install from pkgsrc.
fi
# Packages we have to pre-install, and url to use
PREINSTALLED_PACKAGES="pkgin-0.3.3.4.tgz pkg_install-20101212 bmake-20100808"
PACKAGEURL=ftp://ftp.minix3.org/pub/minix/packages/$version_pretty/`uname -m`/All/
PREINSTALLED_PACKAGES="
pkgin-0.4.1
pkg_install-20101212
bmake-20100808
binutils-2.17nb3
clang-2.9nb2
compiler-rt-r123836nb3
"
PKG_ADD_URL=$PACKAGEURL
RELEASERC=$HOME/.releaserc
@ -68,11 +78,11 @@ fi
FILENAMEOUT=""
while getopts "s:pmMchu?r:f:" c
while getopts "ls:pmMchu?r:f:" c
do
case "$c" in
\?)
echo "Usage: $0 [-p] [-c] [-h] [-m] [-M] [-r <tag>] [-u] [-f <filename>] [-s <username>]" >&2
echo "Usage: $0 [-l] [-p] [-c] [-h] [-m] [-M] [-r <tag>] [-u] [-f <filename>] [-s <username>]" >&2
exit 1
;;
h)
@ -106,6 +116,8 @@ do
;;
M) MAKEMAP=1
;;
l) PKG_ADD_URL=file://$PACKAGEDIR
;;
esac
done
@ -197,7 +209,7 @@ else
echo "Copying contents from current src dir."
( cd .. && make depend && make clean )
srcdir=/usr/$SRC
( cd $srcdir && tar cf - . ) | ( cd $RELEASEDIR/usr && mkdir $SRC && cd $SRC && tar xf - )
( cd $srcdir && tar --exclude .svn -cf - . ) | ( cd $RELEASEDIR/usr && mkdir $SRC && cd $SRC && tar xf - )
REVTAG=copy
REVISION=unknown
IMG=${IMG_BASE}_copy.iso
@ -230,8 +242,8 @@ echo " * Make hierarchy"
chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/$SRC/tools/chrootmake.sh etcfiles" || exit 1
for p in $PREINSTALLED_PACKAGES
do echo " * Pre-installing: $p from $PACKAGEURL"
$PKG_ADD -P $RELEASEDIR $PACKAGEURL/$p
do echo " * Pre-installing: $p from $PKG_ADD_URL"
$PKG_ADD -P $RELEASEDIR $PKG_ADD_URL/$p
done
echo " * Chroot build"