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 .depend
obj-ack obj-ack
obj-gnu obj-gnu
obj-elf-base
tools/revision tools/revision
TAGS TAGS
tags tags

View file

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

View file

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

View file

@ -3,7 +3,7 @@
/* Minix release and version numbers. */ /* Minix release and version numbers. */
#define OS_RELEASE "3" #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. /* This file sets configuration parameters for the MINIX kernel, FS, and PM.
* It is divided up into two main sections. The first section contains * 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: 20110225:
Create ddekit include dirs: Create ddekit include dirs:
mkdir -p /usr/include/ddekit/minix mkdir -p /usr/include/ddekit/minix

View file

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

View file

@ -18,23 +18,17 @@ SUBDIR+= libend
build_ack: build_ack:
sh ack_build.sh obj depend all install 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: build_gnu:
sh gnu_build.sh obj depend all install sh gnu_build.sh obj depend all install
.endif
build_clang: clean_all:
sh clang_build.sh obj depend all install
build_elf:
sh elf_build.sh obj depend all install
clean_ack:
sh ack_build.sh clean 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 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 #!/bin/sh
set -e
export CC=cc export CC=cc
export MAKEOBJDIR=obj-ack export MAKEOBJDIR=obj-ack

View file

@ -1,8 +1,15 @@
#!/bin/sh #!/bin/sh
# This file is obsolete and is only useful to 'clean' its objects.
export CC=i386-pc-minix3-gcc export CC=i386-pc-minix3-gcc
export COMPILER_TYPE=gnu export COMPILER_TYPE=gnu
export MAKEOBJDIR=obj-elf export MAKEOBJDIR=obj-elf
export PATH=$PATH:/usr/gnu_cross/bin export PATH=$PATH:/usr/gnu_cross/bin
if [ "$@" != clean ]
then echo "$0: Unexpected arguments $@"
exit 1
fi
make $@ 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 INFOOWN?= root
INFOMODE?= ${NONBINMODE} INFOMODE?= ${NONBINMODE}
#LIBDIR?= /usr/lib LIBDIR?= /usr/lib
.if ${COMPILER_TYPE} == "ack" .if ${COMPILER_TYPE} == "ack"
LIBDIR?= /usr/lib/i386 LIBDIR?= /usr/lib/i386
.endif .endif
@ -535,20 +535,16 @@ DEBUGMODE?= ${NONBINMODE}
# All platforms are ELF. # All platforms are ELF.
# #
#OBJECT_FMT= 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 OBJECT_FMT= ELF
.else .else
OBJECT_FMT= a.out OBJECT_FMT= a.out
.endif .endif
.if ${COMPILER_TYPE} == "gnu" .if ${COMPILER_TYPE} == "gnu"
.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") .if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no")
LIBDIR?= /usr/netbsd/lib LIBDIR?= /usr/netbsd/lib
.endif .endif
.if ${OBJECT_FMT} == "a.out"
LIBDIR?= /usr/lib
.elif ${OBJECT_FMT} == "ELF"
LIBDIR?= /usr/gnu_cross/i386-pc-minix3/lib
.endif
.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 # in a traditional environment' warning, as opposed to 'this code behaves
# differently in traditional and ansi environments' which is the warning # differently in traditional and ansi environments' which is the warning
# we wanted, and now we don't get anymore. # we wanted, and now we don't get anymore.
CFLAGS+= -Wno-sign-compare -Wno-traditional CFLAGS+= -Wno-sign-compare
.if !defined(NOGCCERROR) .if !empty(CC:Mgcc)
CFLAGS+= -Wno-traditional
.endif
.if !defined(NOGCCERROR) && !empty(CC:Mgcc)
# Set assembler warnings to be fatal # Set assembler warnings to be fatal
CFLAGS+= -Wa,--fatal-warnings CFLAGS+= -Wa,--fatal-warnings
.endif .endif
@ -24,7 +27,8 @@ CFLAGS+= -Wa,--fatal-warnings
# XXX no proper way to avoid "FOO is a patented algorithm" warnings # XXX no proper way to avoid "FOO is a patented algorithm" warnings
# XXX on linking static libs # XXX on linking static libs
.if (!defined(MKPIC) || ${MKPIC} != "no") && \ .if (!defined(MKPIC) || ${MKPIC} != "no") && \
(!defined(LDSTATIC) || ${LDSTATIC} != "-static") (!defined(LDSTATIC) || ${LDSTATIC} != "-static") \
&& !empty(CC:Mgcc)
LDFLAGS+= -Wl,--fatal-warnings LDFLAGS+= -Wl,--fatal-warnings
.endif .endif
.endif .endif

View file

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

View file

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

View file

@ -18,6 +18,7 @@ secs=`expr 32 '*' 64`
export SHELL=/bin/sh export SHELL=/bin/sh
PKG_ADD=/usr/pkg/sbin/pkg_add PKG_ADD=/usr/pkg/sbin/pkg_add
PKG_INFO=/usr/pkg/sbin/pkg_info
if [ ! -x $PKG_ADD ] if [ ! -x $PKG_ADD ]
then echo Please install pkg_install from pkgsrc. then echo Please install pkg_install from pkgsrc.
@ -25,8 +26,17 @@ then echo Please install pkg_install from pkgsrc.
fi fi
# Packages we have to pre-install, and url to use # 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/ 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 RELEASERC=$HOME/.releaserc
@ -68,11 +78,11 @@ fi
FILENAMEOUT="" FILENAMEOUT=""
while getopts "s:pmMchu?r:f:" c while getopts "ls:pmMchu?r:f:" c
do do
case "$c" in 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 exit 1
;; ;;
h) h)
@ -106,6 +116,8 @@ do
;; ;;
M) MAKEMAP=1 M) MAKEMAP=1
;; ;;
l) PKG_ADD_URL=file://$PACKAGEDIR
;;
esac esac
done done
@ -197,7 +209,7 @@ else
echo "Copying contents from current src dir." echo "Copying contents from current src dir."
( cd .. && make depend && make clean ) ( cd .. && make depend && make clean )
srcdir=/usr/$SRC 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 REVTAG=copy
REVISION=unknown REVISION=unknown
IMG=${IMG_BASE}_copy.iso 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 chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/$SRC/tools/chrootmake.sh etcfiles" || exit 1
for p in $PREINSTALLED_PACKAGES for p in $PREINSTALLED_PACKAGES
do echo " * Pre-installing: $p from $PACKAGEURL" do echo " * Pre-installing: $p from $PKG_ADD_URL"
$PKG_ADD -P $RELEASEDIR $PACKAGEURL/$p $PKG_ADD -P $RELEASEDIR $PKG_ADD_URL/$p
done done
echo " * Chroot build" echo " * Chroot build"