tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Moving to --sysroot=$D for compiler invocations
Hi all,
attached is a patch to clean up some issues with the --sysroot support
in our GCC patches. It also changes the infrastructure to switch to
using --sysroot=$D instead of the combination of -B, -nostdinc,
-isystem, -nostdlib, -L, -Wl,-rpath etc. This makes it a lot cleaner and
easire to integrate other modern compiler drivers.
There is one down side: it currently breaks PCC. I'm working on that
separately, but PCC already has issues with the use of two -B options,
so I don't consider this a show stopper.
Joerg
Index: src/distrib/i386/ramdisks/common/Makefile.ramdisk
===================================================================
--- src/distrib/i386/ramdisks/common/Makefile.ramdisk
+++ src/distrib/i386/ramdisks/common/Makefile.ramdisk
@@ -27,11 +27,12 @@
${DISTRIBDIR}/common/services
PARSELISTENV+= BOOTMODEL=${BOOTMODEL:Q}
# This propogates through to the link of ramdiskbin
# The map file is useful when trying to prune the image
-CRUNCHENV += LDFLAGS='-Wl,-Map,${CRUNCHBIN}.map,--cref'
+LDFLAGS+= -Wl,-Map,${CRUNCHBIN}.map,--cref
+CRUNCHENV += LDFLAGS=${LDFLAGS:Q}
.if defined(USE_SYSINST)
.if ${USE_SYSINST} != yes
LISTS+= ${DISTRIBDIR}/common/list.sysinst.${USE_SYSINST}
.else
Index: src/gnu/dist/gcc4/gcc/Makefile.in
===================================================================
--- src/gnu/dist/gcc4/gcc/Makefile.in
+++ src/gnu/dist/gcc4/gcc/Makefile.in
@@ -3145,13 +3145,13 @@
rm -f include/$$realfile; \
cp $$file include; \
chmod a+r include/$$realfile; \
fi; \
done; \
- rm -f include/limits.h; \
- chmod a+r include/limits.h; fi
- cp xlimits.h include/limits.h
+ true || rm -f include/limits.h; \
+ true || chmod a+r include/limits.h; fi
+ true || cp xlimits.h include/limits.h
cp $(UNWIND_H) include/unwind.h
# Install the README
rm -f include/README
cp $(srcdir)/../fixincludes/README-fixinc include/README
chmod a+r include/README
Index: src/gnu/dist/gcc4/gcc/config/netbsd.h
===================================================================
--- src/gnu/dist/gcc4/gcc/config/netbsd.h
+++ src/gnu/dist/gcc4/gcc/config/netbsd.h
@@ -41,13 +41,17 @@
"%{posix:-D_POSIX_SOURCE} \
%{pthread:-D_REENTRANT -D_PTHREADS}"
/* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD
source tree so it can be configured appropriately without using
- the GNU configure/build mechanism. */
+ the GNU configure/build mechanism.
-#ifdef NETBSD_NATIVE
+ NETBSD_TOOLS is defined when gcc is built as cross-compiler for
+ the in-tree toolchain.
+ */
+
+#if defined(NETBSD_NATIVE) || defined(NETBSD_TOOLS)
/* Look for the include files in the system-defined places. */
#undef GPLUSPLUS_INCLUDE_DIR
#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
@@ -59,37 +63,41 @@
#define GCC_INCLUDE_DIR "/usr/include"
#undef INCLUDE_DEFAULTS
#define INCLUDE_DEFAULTS \
{ \
- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1 }, \
- { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1 }, \
+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1 }, \
+ { GCC_INCLUDE_DIR, "GCC", 0, 0, 1 }, \
{ 0, 0, 0, 0 } \
}
-
-/* Under NetBSD, the normal location of the compiler back ends is the
- /usr/libexec directory. */
-
-#undef STANDARD_EXEC_PREFIX
-#define STANDARD_EXEC_PREFIX "/usr/libexec/"
/* Under NetBSD, the normal location of the various *crt*.o files is the
/usr/lib directory. */
#undef STANDARD_STARTFILE_PREFIX
#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
+#undef STANDARD_STARTFILE_PREFIX_1
+#define STANDARD_STARTFILE_PREFIX_1 "/usr/lib/"
+
+#endif /* NETBSD_NATIVE || NETBSD_TOOLS */
+
+#if defined(NETBSD_NATIVE)
+/* Under NetBSD, the normal location of the compiler back ends is the
+ /usr/libexec directory. */
+
+#undef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX "/usr/libexec/"
#undef TOOLDIR_BASE_PREFIX
#define TOOLDIR_BASE_PREFIX "/usr/"
#undef STANDARD_BINDIR_PREFIX
#define STANDARD_BINDIR_PREFIX "/usr/bin"
#undef STANDARD_LIBEXEC_PREFIX
#define STANDARD_LIBEXEC_PREFIX STANDARD_EXEC_PREFIX
-
#endif /* NETBSD_NATIVE */
/* Provide a LIB_SPEC appropriate for NetBSD. Here we:
Index: src/gnu/dist/gcc4/gcc/gcc.c
===================================================================
--- src/gnu/dist/gcc4/gcc/gcc.c
+++ src/gnu/dist/gcc4/gcc/gcc.c
@@ -6275,11 +6275,11 @@
add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, 1);
else if (*cross_compile == '0')
{
-#ifndef NETBSD_NATIVE
+#if !defined(NETBSD_NATIVE) && !defined(NETBSD_TOOLS)
if (gcc_exec_prefix)
add_prefix (&startfile_prefixes,
concat (gcc_exec_prefix, machine_suffix,
standard_startfile_prefix, NULL),
NULL, PREFIX_PRIORITY_LAST, 0, 1);
@@ -6293,11 +6293,11 @@
standard_startfile_prefix,
NULL, PREFIX_PRIORITY_LAST, 0, 1);
#endif /* NETBSD_NATIVE */
}
-#ifndef NETBSD_NATIVE
+#if !defined(NETBSD_NATIVE) && !defined(NETBSD_TOOLS)
if (*standard_startfile_prefix_1)
add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix_1, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, 1);
if (*standard_startfile_prefix_2)
Index: src/gnu/usr.bin/gdb6/gdb/Makefile
===================================================================
--- src/gnu/usr.bin/gdb6/gdb/Makefile
+++ src/gnu/usr.bin/gdb6/gdb/Makefile
@@ -8,11 +8,11 @@
.include "${.CURDIR}/../arch/${MACHINE_ARCH}/defs.mk"
PROG= gdb
SRCS= gdb.c
-CPPFLAGS= -I${.CURDIR} \
+CPPFLAGS+= -I${.CURDIR} \
-I${.CURDIR}/../arch/${MACHINE_ARCH} \
-I${DIST}/gdb \
-I${DIST}/gdb/config \
-I${DIST}/include/opcode \
-I${DIST} \
Index: src/gnu/usr.bin/gdb6/gdbtui/Makefile
===================================================================
--- src/gnu/usr.bin/gdb6/gdbtui/Makefile
+++ src/gnu/usr.bin/gdb6/gdbtui/Makefile
@@ -8,11 +8,11 @@
.include "${.CURDIR}/../arch/${MACHINE_ARCH}/defs.mk"
PROG= gdbtui
SRCS= tui-main.c
-CPPFLAGS= -I${.CURDIR} \
+CPPFLAGS+= -I${.CURDIR} \
-I${.CURDIR}/../arch/${MACHINE_ARCH} \
-I${DIST}/gdb \
-I${DIST}/gdb/config \
-I${DIST}/include/opcode \
-I${DIST} \
Index: src/gnu/usr.bin/gdb6/libgdb/Makefile
===================================================================
--- src/gnu/usr.bin/gdb6/libgdb/Makefile
+++ src/gnu/usr.bin/gdb6/libgdb/Makefile
@@ -12,11 +12,11 @@
DIST= ${NETBSDSRCDIR}/gnu/dist/gdb6
SRCS= ${G_LIBGDB_OBS:.o=.c}
GCPPFLAGS= ${G_INTERNAL_CFLAGS}
CPPFLAGS.bsd-kvm.c= -D_KMEMUSER
-CPPFLAGS= -I${.CURDIR} \
+CPPFLAGS+= -I${.CURDIR} \
-I${.CURDIR}/../arch/${MACHINE_ARCH} \
-I${DIST}/gdb \
-I${DIST}/gdb/config \
-I${DIST}/include/opcode \
-I${DIST} \
Index: src/lib/libbsdmalloc/Makefile
===================================================================
--- src/lib/libbsdmalloc/Makefile
+++ src/lib/libbsdmalloc/Makefile
@@ -5,9 +5,8 @@
.include <bsd.own.mk>
LIB= bsdmalloc
SRCS= malloc.c
-CPPFLAGS= -D_REENTRANT
-CPPFLAGS= -I${.CURDIR}/../libc/include/
+CPPFLAGS+= -D_REENT -D_REENTRANT -I${.CURDIR}/../libc/include/
.include <bsd.lib.mk>
Index: src/sbin/mount_ffs/Makefile
===================================================================
--- src/sbin/mount_ffs/Makefile
+++ src/sbin/mount_ffs/Makefile
@@ -8,12 +8,12 @@
MLINKS= mount_ffs.8 mount_ufs.8
LINKS= ${BINDIR}/mount_ffs ${BINDIR}/mount_ufs
MOUNT= ${NETBSDSRCDIR}/sbin/mount
-CPPFLAGS=-I${MOUNT}
+CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil
.include <bsd.prog.mk>
Index: src/sbin/mount_hfs/Makefile
===================================================================
--- src/sbin/mount_hfs/Makefile
+++ src/sbin/mount_hfs/Makefile
@@ -5,12 +5,12 @@
PROG= mount_hfs
SRCS= mount_hfs.c pathadj.c
MAN= mount_hfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
-CPPFLAGS=-I${MOUNT}
+CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL}
LDADD+=-lutil
.include <bsd.prog.mk>
Index: src/sbin/mount_nfs/Makefile
===================================================================
--- src/sbin/mount_nfs/Makefile
+++ src/sbin/mount_nfs/Makefile
@@ -7,11 +7,11 @@
PROG= mount_nfs
SRCS= mount_nfs.c pathadj.c
MAN= mount_nfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
-CPPFLAGS=-I${MOUNT}
+CPPFLAGS+=-I${MOUNT}
.PATH: ${MOUNT}
.ifndef SMALLPROG
SRCS+= getnfsargs.c
.else
Index: src/share/mk/bsd.dep.mk
===================================================================
--- src/share/mk/bsd.dep.mk
+++ src/share/mk/bsd.dep.mk
@@ -55,12 +55,10 @@
.C.d .cc.d .cpp.d .cxx.d:
${_MKTARGET_CREATE}
${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \
- ${HOSTLIB:U${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
- ${DESTDIR}/usr/include/g++}} \
${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
.endif # defined(SRCS) # }
##### Clean rules
Index: src/share/mk/bsd.lib.mk
===================================================================
--- src/share/mk/bsd.lib.mk
+++ src/share/mk/bsd.lib.mk
@@ -61,21 +61,10 @@
.endif # }
##### Build and install rules
MKDEP_SUFFIXES?= .o .po .pico .go .ln
-# Use purely kernel private headers in rump builds
-# Skip NetBSD headers for the toolchain builds
-.if !defined(RUMPKERNEL) && !defined(HOSTLIB)
-.if empty(CPPFLAGS:M-nostdinc)
-CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
-.endif
-.if empty(CXXFLAGS:M-nostdinc++)
-CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX}
${DESTDIR}/usr/include/g++}
-.endif
-.endif
-
.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # {
SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
@@ -520,16 +509,16 @@
lib${LIB}_g.a:: ${GOBJS} __archivebuild
_LIBLDOPTS=
.if ${SHLIBDIR} != "/usr/lib"
-_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
- -Wl,-rpath,${SHLIBDIR} \
- -L${DESTDIR}${SHLIBDIR}
+_LIBLDOPTS+= -Wl,-rpath-link,=${SHLIBDIR} \
+ -Wl,-rpath,=${SHLIBDIR} \
+ -L=${SHLIBDIR}
.elif ${SHLIBINSTALLDIR} != "/usr/lib"
-_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib
\
- -L${DESTDIR}${SHLIBINSTALLDIR}
+_LIBLDOPTS+= -Wl,-rpath-link,=${SHLIBINSTALLDIR} \
+ -L=${SHLIBINSTALLDIR}
.endif
# gcc -shared now adds -lc automatically. For libraries other than libc and
# libgcc* we add as a dependency the installed shared libc. For libc and
# libgcc* we avoid adding libc as a dependency by using -nostdlib. Note that
@@ -563,22 +552,13 @@
lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \
${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
${_MKTARGET_BUILD}
rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
-.if defined(DESTDIR)
- ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/
-B${DESTDIR}${SHLIBDIR}/ \
- -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
- -Wl,--whole-archive ${SOLIB} \
- -Wl,--no-whole-archive ${_LDADD.lib${LIB}} \
- ${_LIBLDOPTS} ${_LDFLAGS.lib${LIB}} \
- -L${_GCC_LIBGCCDIR}
-.else
${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS}
${_LDFLAGS.lib${LIB}} \
-o ${.TARGET} ${_LIBLDOPTS} \
-Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive
${_LDADD.lib${LIB}}
-.endif
# We don't use INSTALL_SYMLINK here because this is just
# happening inside the build directory/objdir. XXX Why does
# this spend so much effort on libraries that aren't live??? XXX
.if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \
"${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
Index: src/share/mk/bsd.own.mk
===================================================================
--- src/share/mk/bsd.own.mk
+++ src/share/mk/bsd.own.mk
@@ -62,19 +62,10 @@
HAVE_GDB?= 6
# default to binutils 2.19
HAVE_BINUTILS?= 219
-CPPFLAG_ISYSTEM= -isystem
-.if defined(HAVE_GCC)
-.if ${HAVE_GCC} == 3
-CPPFLAG_ISYSTEMXX= -isystem-cxx
-.else # GCC 4
-CPPFLAG_ISYSTEMXX= -cxx-isystem
-.endif
-.endif
-
.if empty(.MAKEFLAGS:M-V*)
.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx
.else
PRINTOBJDIR= ${MAKE} -V .OBJDIR
@@ -214,10 +205,12 @@
CXX= false
FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
OBJC= false
.endif
+CPPFLAGS+= ${HOSTPROG:U${HOSTLIB:U${DESTDIR:D--sysroot=${DESTDIR}}}}
+LDFLAGS+= ${HOSTPROG:U${HOSTLIB:U${DESTDIR:D--sysroot=${DESTDIR}}}}
.endif # EXTERNAL_TOOLCHAIN # }
HOST_MKDEP= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
Index: src/share/mk/bsd.prog.mk
===================================================================
--- src/share/mk/bsd.prog.mk
+++ src/share/mk/bsd.prog.mk
@@ -50,20 +50,10 @@
CFLAGS+= ${PIE_CFLAGS}
AFLAGS+= ${PIE_AFLAGS}
LDFLAGS+= ${PIE_LDFLAGS}
.endif
-##### Default values
-.if !defined(HOSTLIB)
-.if empty(CPPFLAGS:M-nostdinc)
-CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
-.endif
-.if empty(CXXFLAGS:M-nostdinc++)
-CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX}
${DESTDIR}/usr/include/g++}
-.endif
-.endif
-
CFLAGS+= ${COPTS}
OBJCFLAGS+= ${OBJCOPTS}
MKDEP_SUFFIXES?= .o .ln
# CTF preserve debug symbols
@@ -170,19 +160,17 @@
_PROGLDOPTS=
.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves
_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER}
.endif
.if ${SHLIBDIR} != "/usr/lib"
-_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR} \
- -Wl,-rpath,${SHLIBDIR} \
- -L${DESTDIR}${SHLIBDIR}
+_PROGLDOPTS+= -Wl,-rpath-link,=${SHLIBDIR} \
+ -Wl,-rpath,=${SHLIBDIR} \
+ -L=${SHLIBDIR}
.elif ${SHLIBINSTALLDIR} != "/usr/lib"
-_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
- -L${DESTDIR}${SHLIBINSTALLDIR}
+_PROGLDOPTS+= -Wl,-rpath-link,=${SHLIBINSTALLDIR} \
+ -L=${SHLIBINSTALLDIR}
.endif
-_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}/usr/lib \
- -L${DESTDIR}/usr/lib
__proginstall: .USE
${_MKTARGET_INSTALL}
${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${STRIPFLAG} ${.ALLSRC} ${.TARGET}
@@ -206,13 +194,10 @@
_APPEND_MANS=yes
_APPEND_SRCS=yes
_CCLINKFLAGS=
-.if defined(DESTDIR)
-_CCLINKFLAGS+= -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/
-.endif
.if defined(PROG_CXX)
PROG= ${PROG_CXX}
_CCLINK= ${CXX} ${_CCLINKFLAGS}
.endif
@@ -325,14 +310,12 @@
${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND}
${DPADD}
.if !commands(${_P})
${_MKTARGET_LINK}
${_CCLINK.${_P}} \
- ${DESTDIR:D-Wl,-nostdlib} \
${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \
${OBJS.${_P}} ${_LDADD.${_P}} \
- ${DESTDIR:D-L${_GCC_LIBGCCDIR}} \
${_PROGLDOPTS}
.if defined(CTFMERGE)
${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}}
.endif
.if defined(PAXCTL_FLAGS.${_P})
Index: src/share/mk/bsd.x11.mk
===================================================================
--- src/share/mk/bsd.x11.mk
+++ src/share/mk/bsd.x11.mk
@@ -164,19 +164,17 @@
-e '/^[ ]*XHASH/s/XHASH/\#/' \
-e '/\@\@$$/s/\@\@$$/\\/'
CPPFLAGS+= -DCSRG_BASED -DFUNCPROTO=15 -DNARROWPROTO
-CPPFLAGS+= -I${DESTDIR}${X11INCDIR}
+CPPFLAGS+= -I=${X11INCDIR}
.if ${MACHINE_ARCH} == "x86_64"
CPPFLAGS+= -D__AMD64__
.endif
-LDFLAGS+= -Wl,-rpath-link,${DESTDIR}${X11USRLIBDIR} \
- -Wl,-rpath,${X11USRLIBDIR} \
- -L${DESTDIR}${X11USRLIBDIR}
+LDFLAGS+= -Wl,-rpath,=${X11USRLIBDIR} -L=${X11USRLIBDIR}
#
# .cpp -> "" handling
# CPPSCRIPTS list of files/scripts to run through cpp
Index: src/tools/Makefile.host
===================================================================
--- src/tools/Makefile.host
+++ src/tools/Makefile.host
@@ -40,11 +40,11 @@
.endif
HOSTPROGNAME?= ${HOSTPROG}
HOST_BINDIR?= ${TOOLDIR}/bin
HOST_CPPFLAGS:= ${HOST_CPPFLAGS} ${CPPFLAGS}
-HOST_CPPFLAGS:= ${HOST_CPPFLAGS:N-Wp,-iremap,*}
+HOST_CPPFLAGS:= ${HOST_CPPFLAGS:N-Wp,-iremap,*:N--sysroot=*}
.undef LINKS
SRCS?= ${HOSTPROG}.c
SRCS+= ${HOST_SRCS}
Home |
Main Index |
Thread Index |
Old Index