Enable optional GCC install and GCC improvements

-By adding MKGCC=yes and MKGCCCMDS=yes on the make commandline
   it is now possible to compile and install GCC on the system.

   Before doing this, if you are not using the build.sh script,
   you will need to call the fetch scripts in order to retrieve
   the sources of GCC and its dependencies.

 -Reduce difference with NetBSD share/mk

   Move Minix-specific parameters from bsd.gcc.mk to bsd.own.mk,
   which is anyway patched, so that bsd.gcc.mk is now aligned
   on the NetBSD version.

 -Clean libraries dependencies, compiles stdc++ only if gcc is
   also compiled (it is part of the gcc sources)

 -Correct minix.h header sequence, cleanup spec headers.

 -Fix cross-compilation from a 32bit host targeting MINIX/arm

Change-Id: I1b234af18eed4ab5675188244e931b2a2b7bd943
This commit is contained in:
2013-04-24 18:57:59 +02:00
parent c566d4623b
commit 0cdf705cc6
95 changed files with 4521 additions and 599 deletions

View File

@@ -3,7 +3,7 @@
.if !defined(_BSD_GCC_MK_)
_BSD_GCC_MK_=1
.if defined(EXTERNAL_TOOLCHAIN) && !defined(__MINIX)
.if defined(EXTERNAL_TOOLCHAIN)
_GCC_CRTBEGIN!= ${CC} --print-file-name=crtbegin.o
_GCC_CRTBEGINS!= ${CC} --print-file-name=crtbeginS.o
_GCC_CRTEND!= ${CC} --print-file-name=crtend.o
@@ -23,20 +23,4 @@ _GCC_CRTDIR?= ${DESTDIR}/usr/lib
_GCC_LIBGCCDIR?= ${DESTDIR}/usr/lib
.endif
.if defined(__MINIX)
AFLAGS+=-D__ASSEMBLY__
CPPFLAGS+= -fno-builtin -Wall -Wno-sign-compare
#LSC FIXME: Needed by clang for now
.if ${MACHINE_ARCH} == "i386"
CPUFLAGS+= -march=i586
.endif
# LSC In the current state there is too much to be done
# Some package have been identified by directly adding NOGCCERROR
# To their Makefiles
NOGCCERROR:= yes
NOCLANGERROR:= yes
.endif # defined(__MINIX)
.endif # ! defined(_BSD_GCC_MK_)

View File

@@ -582,17 +582,33 @@ _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
DPLIBC ?= ${DESTDIR}${LIBC_SO}
.endif
.else
.if ${LIB} != "c" && ${LIB:Mgcc*} == ""
.if ${LIB} != "c" && ${LIB:Mgcc*} == "" \
&& ${LIB} != "minlib" && ${LIB} != "sys" && ${LIB} != "minc" # Minix-specific libs
.if !empty(LIBC_SO)
DPLIBC ?= ${DESTDIR}${LIBC_SO}
.endif
.else
LDLIBC ?= -nodefaultlibs
.if ${LIB} == "c"
.if ${LIB} == "c" || ${LIB} == "minc"
LDADD+= ${${ACTIVE_CC} == "gcc":?-lgcc:}
LDADD+= ${${ACTIVE_CC} == "clang":?-L/usr/pkg/compiler-rt/lib -lCompilerRT-Generic:}
.endif
.endif
.if defined(__MINIX)
.if ${LIB} == "m" || ${LIB} == "vtreefs"
# LSC: gcc generate calls to its runtime library for some floating point
# operations and convertions, which are not included in libc.
LDADD+= ${${ACTIVE_CC} == "gcc":?-lgcc:}
.endif # ${LIB} == "m" || ${LIB} == "vtreefs"
.if ${LIB} == "stdc++"
# LSC we can't build this library without compiling gcc
LDADD+= -lgcc_s
DPADD+= ${DESTDIR}/usr/lib/libgcc_s.a
.endif # ${LIB} == "stdc++"
.endif #defined(__MINIX)
.endif
.if ${LIBISCXX} != "no"

View File

@@ -13,6 +13,8 @@ _BSD_OWN_MK_=1
# Some Minix deviations from NetBSD
LDSTATIC?= -static
MKDYNAMICROOT?= no
NO_LIBGOMP?= yes
MKKYUA?= yes
BINMODE?= 755
NONBINMODE?= 644
@@ -25,6 +27,7 @@ DOCGRP?= operator
MKBINUTILS?= no
MKGDB:= no
MKGCC?= no
MKGCCCMDS?= no
# LSC MINIX SMP Support?
.ifdef CONFIG_SMP
@@ -81,6 +84,23 @@ LDS_DYNAMIC_BIN= ${LDS_PATH}/elf_${MACHINE_ARCH}_minix.xc
LDS_RELOC= ${LDS_PATH}/elf_${MACHINE_ARCH}_minix.xr
LDS_SHARED_LIB= ${LDS_PATH}/elf_${MACHINE_ARCH}_minix.xsc
LDS_N= ${LDS_PATH}/elf_${MACHINE_ARCH}_minix.xbn
# LSC In the current state there is too much to be done
# Some package have been identified by directly adding NOGCCERROR
# To their Makefiles
NOGCCERROR?= yes
NOCLANGERROR?= yes
AFLAGS+= -D__ASSEMBLY__
CFLAGS+= -fno-builtin
# For C++ programs
#CPPFLAGS+= -I${DESTDIR}/usr/include/g++
#LSC FIXME: Needed by clang for now
.if ${MACHINE_ARCH} == "i386"
CPUFLAGS+= -march=i586
.endif
.endif # defined(__MINIX)
MAKECONF?= /etc/mk.conf

View File

@@ -84,35 +84,47 @@ LIBCRT0= ${DESTDIR}/usr/lib/crt0.o
# NB: If you are a library here, add it in bsd.README
.for _lib in \
audiodriver \
blockdriver \
chardriver \
netdriver \
atf_c \
atf_cxx \
bz2 \
c \
c_pic \
crt0 \
crypt \
curses \
edit \
expat \
end \
sys \
timers \
util \
bz2 \
l \
m \
m \
magic \
rmt \
terminfo \
util \
z
.ifndef LIB${_lib:tu}
LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib:S/xx/++/:S/atf_c/atf-c/}.a
.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded
.endif
.endfor
# Minix libraries
.for _lib in \
audiodriver \
bdev \
blockdriver \
chardriver \
elf \
exec \
ddekit \
devman \
usb \
elf \
bdev \
sffs \
hgfs \
vboxfs \
minc \
minlib \
min\
lib
netdriver \
sffs \
sys \
timers \
usb
.ifndef LIB${_lib:tu}
LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib:S/xx/++/:S/atf_c/atf-c/}.a
.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded
@@ -229,6 +241,10 @@ _APPEND_SRCS=yes
_CCLINKFLAGS=
.if defined(PROG_CXX)
#.if defined(__MINIX) # LSC: Can't test as bsd.own.mk may not have been sourced
LDADD+= -lgcc_s
DPADD+= ${DESTDIR}/usr/lib/libgcc_s.a
#.endif # defined(__MINIX)
PROG= ${PROG_CXX}
_CCLINK= ${CXX} ${_CCLINKFLAGS}
.endif

View File

@@ -31,6 +31,11 @@ BINDIR.${_T}= ${TESTSDIR}
LDADD.${_T}+= -latf-c++ -latf-c
DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
MAN.${_T}?= # empty
#.if defined(__MINIX) # LSC: Can't test as bsd.own.mk may not have been sourced
# Somehow it resets / ignore the settings in bsd.prog.mk, so duplicate here
LDADD.${_T}+= -lgcc_s
DPADD.${_T}+= ${DESTDIR}/usr/lib/libgcc_s.a
#.endif # defined(__MINIX)
. endfor
.endif

View File

@@ -6,7 +6,7 @@
# version of clang.
# 1. No default libs
LDADD+= -nodefaultlibs
LDADD:= -nodefaultlibs ${LDADD}
# 2. Compiler-specific libs
.if !empty(CC:M*gcc)