From: Ben Gras Date: Tue, 7 Jun 2011 12:48:31 +0000 (+0200) Subject: changes for detecting and building for clang/binutils elf X-Git-Tag: v3.2.0~547 X-Git-Url: http://zhaoyanbai.com/repos/man.nsupdate.html?a=commitdiff_plain;h=230b7775fecd7522e8fc30d40452177abf49c142;p=minix.git 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) --- diff --git a/.gitignore b/.gitignore index 87eb10770..33f193d73 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ cscope.* .depend obj-ack obj-gnu +obj-elf-base tools/revision TAGS tags diff --git a/Makefile b/Makefile index 22069051a..db671a644 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/commands/unstack/unstack.sh b/commands/unstack/unstack.sh index e26347f77..bb781c624 100644 --- a/commands/unstack/unstack.sh +++ b/commands/unstack/unstack.sh @@ -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 diff --git a/common/include/minix/config.h b/common/include/minix/config.h index c0dfdd521..b247bc0a9 100644 --- a/common/include/minix/config.h +++ b/common/include/minix/config.h @@ -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 diff --git a/docs/UPDATING b/docs/UPDATING index 8125c6fa7..e44dfeba9 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -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 diff --git a/kernel/const.h b/kernel/const.h index f5b7edbcb..16857462b 100644 --- a/kernel/const.h +++ b/kernel/const.h @@ -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 diff --git a/lib/Makefile b/lib/Makefile index e1485acec..aed92d42b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 clang_build.sh clean sh gnu_build.sh clean - -clean_elf: + sh elf_build_base.sh clean sh elf_build.sh clean - -clean_clang: - sh clang_build.sh clean diff --git a/lib/ack_build.sh b/lib/ack_build.sh index c824b9761..67946fe71 100755 --- a/lib/ack_build.sh +++ b/lib/ack_build.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + export CC=cc export MAKEOBJDIR=obj-ack diff --git a/lib/elf_build.sh b/lib/elf_build.sh index 2d4d5fe3f..b14ac7fe3 100755 --- a/lib/elf_build.sh +++ b/lib/elf_build.sh @@ -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 $@ diff --git a/lib/elf_build_base.sh b/lib/elf_build_base.sh new file mode 100755 index 000000000..6279914de --- /dev/null +++ b/lib/elf_build_base.sh @@ -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 $@ diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index e8bcb7678..ea5e9e425 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -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 # diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index efa998e6a..69aaf2077 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -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 diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 686ce224c..71eb4c110 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -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". diff --git a/tools/chrootmake.sh b/tools/chrootmake.sh index 8a4e59764..a86825a61 100755 --- a/tools/chrootmake.sh +++ b/tools/chrootmake.sh @@ -8,7 +8,7 @@ then make $@ exit $? fi -make NOASSERTS=yes world +make world cd tools rm revision rm /boot/image/* diff --git a/tools/release.sh b/tools/release.sh index d780d4366..649add35e 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -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 ] [-u] [-f ] [-s ]" >&2 + echo "Usage: $0 [-l] [-p] [-c] [-h] [-m] [-M] [-r ] [-u] [-f ] [-s ]" >&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"