[RFC] Un-staticise the toolchain
Konstantin Belousov
kostikbel at gmail.com
Thu Apr 26 09:36:09 UTC 2012
I think it is time to stop building the toolchain static. I was told that
original reasoning for static linking was the fear of loosing the ability
to recompile if some problem appears with rtld and any required dynamic
library. Apparently, current dependencies are much more spread, e.g. /bin/sh
is dynamically linked, and statically linked make does not solve anything.
Patch below makes the dynamically linked toolchain a default, adding an
WITHOUT_SHARED_TOOLCHAIN build-time option for real conservators.
I did not looked in details why including bsd.own.mk makes NO_MAN
non-functional. Please see the diffs for gnu/usr.bin/cc1*/Makefile.
gnu/usr.bin/binutils/ar/Makefile | 3 +++
gnu/usr.bin/binutils/as/Makefile | 3 +++
gnu/usr.bin/binutils/ld/Makefile | 3 +++
gnu/usr.bin/binutils/ranlib/Makefile | 3 +++
gnu/usr.bin/cc/cc/Makefile | 2 ++
gnu/usr.bin/cc/cc1/Makefile | 5 ++++-
gnu/usr.bin/cc/cc1plus/Makefile | 5 ++++-
share/mk/bsd.own.mk | 3 ++-
tools/build/options/WITH_STATIC_TOOLCHAIN | 6 ++++++
usr.bin/ar/Makefile | 4 ++++
usr.bin/make/Makefile | 4 ++++
11 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/gnu/usr.bin/binutils/ar/Makefile b/gnu/usr.bin/binutils/ar/Makefile
index 464445e..e26be85 100644
--- a/gnu/usr.bin/binutils/ar/Makefile
+++ b/gnu/usr.bin/binutils/ar/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include "../Makefile.inc0"
+.include <bsd.own.mk>
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
@@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
CFLAGS+= -I${SRCDIR}/binutils
CFLAGS+= -I${SRCDIR}/bfd
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= yes
+.endif
DPADD= ${RELTOP}/libbinutils/libbinutils.a
DPADD+= ${RELTOP}/libbfd/libbfd.a
DPADD+= ${RELTOP}/libiberty/libiberty.a
diff --git a/gnu/usr.bin/binutils/as/Makefile b/gnu/usr.bin/binutils/as/Makefile
index bf8df81..a39918c 100644
--- a/gnu/usr.bin/binutils/as/Makefile
+++ b/gnu/usr.bin/binutils/as/Makefile
@@ -4,6 +4,7 @@
# BINDIR
.include "${.CURDIR}/../../Makefile.inc"
.include "${.CURDIR}/../Makefile.inc0"
+.include <bsd.own.mk>
.PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config
@@ -79,7 +80,9 @@ CFLAGS+= -D_GNU_SOURCE
CFLAGS+= -I${SRCDIR}/gas -I${SRCDIR}/bfd -I${SRCDIR}/gas/config -I${SRCDIR}
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= yes
+.endif
DPADD= ${RELTOP}/libbfd/libbfd.a
DPADD+= ${RELTOP}/libiberty/libiberty.a
diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile
index d4420ed..50d88b5 100644
--- a/gnu/usr.bin/binutils/ld/Makefile
+++ b/gnu/usr.bin/binutils/ld/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include "../Makefile.inc0"
+.include <bsd.own.mk>
.PATH: ${SRCDIR}/ld
@@ -34,7 +35,9 @@ CFLAGS+= -DBINDIR=\"${BINDIR}\" -DTARGET_SYSTEM_ROOT=\"${TOOLS_PREFIX}\"
CFLAGS+= -DTOOLBINDIR=\"${TOOLS_PREFIX}/${BINDIR}/libexec\"
CFLAGS+= -D_GNU_SOURCE
CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= yes
+.endif
DPADD= ${RELTOP}/libbfd/libbfd.a
DPADD+= ${RELTOP}/libiberty/libiberty.a
LDADD= ${DPADD}
diff --git a/gnu/usr.bin/binutils/ranlib/Makefile b/gnu/usr.bin/binutils/ranlib/Makefile
index 8679375..6d4b13e 100644
--- a/gnu/usr.bin/binutils/ranlib/Makefile
+++ b/gnu/usr.bin/binutils/ranlib/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include "../Makefile.inc0"
+.include <bsd.own.mk>
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
@@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
CFLAGS+= -I${SRCDIR}/binutils
CFLAGS+= -I${SRCDIR}/bfd
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= yes
+.endif
DPADD= ${RELTOP}/libbinutils/libbinutils.a
DPADD+= ${RELTOP}/libbfd/libbfd.a
DPADD+= ${RELTOP}/libiberty/libiberty.a
diff --git a/gnu/usr.bin/cc/cc/Makefile b/gnu/usr.bin/cc/cc/Makefile
index 78c83a5..6a65d69 100644
--- a/gnu/usr.bin/cc/cc/Makefile
+++ b/gnu/usr.bin/cc/cc/Makefile
@@ -9,7 +9,9 @@ PROG= gcc
MAN= gcc.1
SRCS+= gccspec.c
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?=yes
+.endif
MLINKS= gcc.1 g++.1
.if ${MK_CLANG_IS_CC} == "no"
diff --git a/gnu/usr.bin/cc/cc1/Makefile b/gnu/usr.bin/cc/cc1/Makefile
index c65acd2..bb8fe19 100644
--- a/gnu/usr.bin/cc/cc1/Makefile
+++ b/gnu/usr.bin/cc/cc1/Makefile
@@ -1,14 +1,17 @@
# $FreeBSD$
.include "../Makefile.inc"
+.include <bsd.own.mk>
.PATH: ${GCCDIR}
PROG= cc1
SRCS= main.c c-parser.c c-lang.c
BINDIR= /usr/libexec
-NO_MAN=
+MAN=
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?=yes
+.endif
OBJS+= ${PROG}-checksum.o
DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY}
diff --git a/gnu/usr.bin/cc/cc1plus/Makefile b/gnu/usr.bin/cc/cc1plus/Makefile
index 964d20f..0bcbe61 100644
--- a/gnu/usr.bin/cc/cc1plus/Makefile
+++ b/gnu/usr.bin/cc/cc1plus/Makefile
@@ -1,6 +1,7 @@
# $FreeBSD$
.include "../Makefile.inc"
+.include <bsd.own.mk>
.PATH: ${GCCDIR}/cp ${GCCDIR}
@@ -13,8 +14,10 @@ SRCS+= main.c cp-lang.c c-opts.c call.c class.c cvt.c cxx-pretty-print.c \
cp-objcp-common.c cp-gimplify.c tree-mudflap.c
BINDIR= /usr/libexec
-NO_MAN=
+MAN=
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?=yes
+.endif
CFLAGS+= -I${GCCDIR}/cp -I.
diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
index 55d6ba2..b0acbfd 100644
--- a/share/mk/bsd.own.mk
+++ b/share/mk/bsd.own.mk
@@ -425,7 +425,8 @@ __DEFAULT_NO_OPTIONS = \
ICONV \
IDEA \
LIBCPLUSPLUS \
- OFED
+ OFED \
+ SHARED_TOOLCHAIN
#
# Default behaviour of some options depends on the architecture. Unfortunately
diff --git a/tools/build/options/WITH_STATIC_TOOLCHAIN b/tools/build/options/WITH_STATIC_TOOLCHAIN
new file mode 100644
index 0000000..fa96a9f
--- /dev/null
+++ b/tools/build/options/WITH_STATIC_TOOLCHAIN
@@ -0,0 +1,6 @@
+.\" $FreeBSD$
+Set to build the toolchain binaries static.
+The set includes
+.Xr cc 1 ,
+.Xr make 1
+and neccessary utilites like assembler, linker and librarian.
\ No newline at end of file
diff --git a/usr.bin/ar/Makefile b/usr.bin/ar/Makefile
index e373120..72d1244 100644
--- a/usr.bin/ar/Makefile
+++ b/usr.bin/ar/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
PROG= ar
SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
@@ -8,7 +10,9 @@ LDADD= -larchive -lelf
CFLAGS+=-I. -I${.CURDIR}
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= yes
+.endif
LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
MLINKS= ar.1 ranlib.1
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index 2dc7e58..40243ed 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -2,13 +2,17 @@
# $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $
# $FreeBSD$
+.include <bsd.own.mk>
+
PROG= make
CFLAGS+=-I${.CURDIR}
SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \
lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \
util.c var.c
+.if ${MK_SHARED_TOOLCHAIN} != "no"
NO_SHARED?= YES
+.endif
# Version has the RYYYYMMDDX format, where R is from RELENG_<R>
CFLAGS+=-DMAKE_VERSION=\"5201111300\"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20120426/3fadceed/attachment.pgp
More information about the freebsd-current
mailing list