1994-05-27 05:00:24 +00:00
|
|
|
# @(#)Makefile 8.2 (Berkeley) 2/3/94
|
1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
2006-03-17 18:54:44 +00:00
|
|
|
|
2016-02-04 21:16:35 +00:00
|
|
|
PACKAGE= lib${LIB}
|
2015-06-15 19:28:07 +00:00
|
|
|
SHLIBDIR?= /lib
|
2006-03-18 11:01:06 +00:00
|
|
|
|
2014-05-06 04:22:01 +00:00
|
|
|
.include <src.opts.mk>
|
2006-03-17 18:54:44 +00:00
|
|
|
|
2014-03-04 02:19:39 +00:00
|
|
|
LIBC_SRCTOP?= ${.CURDIR}
|
|
|
|
|
2010-08-25 20:48:24 +00:00
|
|
|
# Pick the current architecture directory for libc. In general, this is
|
|
|
|
# named MACHINE_CPUARCH, but some ABIs are different enough to require
|
|
|
|
# their own libc, so allow a directory named MACHINE_ARCH to override this.
|
|
|
|
|
2014-03-04 02:19:39 +00:00
|
|
|
.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH})
|
2010-08-24 20:54:43 +00:00
|
|
|
LIBC_ARCH=${MACHINE_ARCH}
|
|
|
|
.else
|
2010-08-24 21:28:34 +00:00
|
|
|
LIBC_ARCH=${MACHINE_CPUARCH}
|
2010-08-24 20:54:43 +00:00
|
|
|
.endif
|
|
|
|
|
2002-03-23 20:08:00 +00:00
|
|
|
# All library objects contain FreeBSD revision strings by default; they may be
|
1994-05-27 05:00:24 +00:00
|
|
|
# excluded as a space-saving measure. To produce a library that does
|
2002-03-26 23:08:42 +00:00
|
|
|
# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
|
2003-12-11 09:53:25 +00:00
|
|
|
# below. Note: there are no IDs for syscall stubs whose sources are generated.
|
|
|
|
# To include legacy CSRG sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS
|
|
|
|
# to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs.
|
1994-05-27 05:00:24 +00:00
|
|
|
LIB=c
|
2006-05-21 15:15:21 +00:00
|
|
|
SHLIB_MAJOR= 7
|
Turn libc.so into an ld script rather than a symlink pointing to the
real shared object and libssp_nonshared.a.
This was the last showstopper that prevented from enabling SSP for ports
by default. portmgr@ performed a buildworld which showed no significant
breakage with this patch.
Details:
On i386 for PIC objects, gcc uses the __stack_chk_fail_local hidden
symbol instead of calling __stack_chk_fail directly [1]. This happen
not only with our gcc-4.2.1 but also with the latest gcc-4.8. If you
want the very nasty details, see [2].
OTOH the problem doesn't exist on other architectures. It also doesn't
exist with Clang as the latter will somehow manage to create the
function in the object file at compile time (contrary to only
referencing it through a symbol that will be brought in at link time).
In a perfect world, when an object file is compiled with
-fstack-protector, it will be linked into a binary or a DSO with this
same flag as well, so GCC will add libssp_nonshared.a to the linker
command-line. Unfortunately, we don't control softwares in ports and we
may have such broken DSO. This is the whole point of this patch.
You can reproduce the problem on i386 by compiling a source file into an
object file with "-fstack-protector-all -fPIE" and linking it
into a binary without "-fstack-protector".
This ld script automatically proposes libssp_nonshared.a along with the
real libc DSO to the linker. It is important to understand that the
object file contained in this library will be pulled in the resulting
binary _only if_ the linker notices one of its symbols is needed (i.e.
one of the SSP symbol is missing).
A theorical performance impact could be when compiling, but my testing
showed less than 0.1% of difference.
[1] For 32-bit code gcc saves the PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly. See comment line 19460 in:
src/contrib/gcc/config/i386/i386.c
[2] When compiling a source file to an object file, if you use something
which is external to the compilation unit, GCC doesn't know yet if
this symbol will be inside or outside the DSO. So it expects the
worst case and routes the symbol through the GOT, which means
additional space and extra relocation for rtld(1).
Declaring a symbol has hidden tells GCC to use the optimal route (no
GOT), but on the other hand this means the symbol has to be provided
in the same DSO (namely libssp_nonshared.a).
On i386, GCC actually uses an hidden symbol for SSP in PIC objects
to save PIC register setup, as said in [1].
PR: ports/138228
PR: ports/168010
Reviewed by: kib, kan
2013-06-12 21:12:05 +00:00
|
|
|
SHLIB_LDSCRIPT=libc.ldscript
|
2015-12-25 11:29:18 +00:00
|
|
|
SHLIB_LDSCRIPT_LINKS=libxnet.so
|
2004-01-19 16:16:53 +00:00
|
|
|
WARNS?= 2
|
2014-03-04 02:19:39 +00:00
|
|
|
CFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include
|
|
|
|
CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
|
2012-05-21 08:10:42 +00:00
|
|
|
.if ${MK_NLS} != "no"
|
2009-03-13 10:40:38 +00:00
|
|
|
CFLAGS+=-DNLS
|
2012-05-21 08:10:42 +00:00
|
|
|
.endif
|
1994-05-27 05:00:24 +00:00
|
|
|
CLEANFILES+=tags
|
2004-10-24 15:33:08 +00:00
|
|
|
INSTALL_PIC_ARCHIVE=
|
|
|
|
PRECIOUSLIB=
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-09-25 01:57:47 +00:00
|
|
|
.ifndef NO_THREAD_STACK_UNWIND
|
|
|
|
CANCELPOINTS_CFLAGS=-fexceptions
|
|
|
|
CFLAGS+=${CANCELPOINTS_CFLAGS}
|
|
|
|
.endif
|
|
|
|
|
2007-05-19 04:32:56 +00:00
|
|
|
#
|
2014-01-18 14:22:56 +00:00
|
|
|
# Link with static libcompiler_rt.a.
|
2007-05-19 04:32:56 +00:00
|
|
|
#
|
2007-05-19 16:38:39 +00:00
|
|
|
LDFLAGS+= -nodefaultlibs
|
2014-11-25 11:07:26 +00:00
|
|
|
LIBADD+= compiler_rt
|
2012-05-19 17:49:20 +00:00
|
|
|
|
|
|
|
.if ${MK_SSP} != "no"
|
2014-11-25 11:07:26 +00:00
|
|
|
LIBADD+= ssp_nonshared
|
2012-05-19 17:49:20 +00:00
|
|
|
.endif
|
2007-05-19 04:32:56 +00:00
|
|
|
|
2013-11-25 20:17:55 +00:00
|
|
|
# Extras that live in either libc.a or libc_nonshared.a
|
|
|
|
LIBC_NONSHARED_SRCS=
|
|
|
|
|
2002-11-18 09:50:57 +00:00
|
|
|
# Define (empty) variables so that make doesn't give substitution
|
|
|
|
# errors if the included makefiles don't change these:
|
|
|
|
MDSRCS=
|
|
|
|
MISRCS=
|
|
|
|
MDASM=
|
|
|
|
MIASM=
|
|
|
|
NOASM=
|
|
|
|
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/db/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/gen/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/gmon/Makefile.inc"
|
Add the BSD-licensed Citrus iconv to the base system with default off
setting. It can be built by setting the WITH_ICONV knob. While this
knob is unset, the library part, the binaries, the header file and
the metadata files will not be built or installed so it makes no impact
on the system if left turned off.
This work is based on the iconv implementation in NetBSD but a great
number of improvements and feature additions have been included:
- Some utilities have been added. There is a conversion table generator,
which can compare conversion tables to reference data generated by
GNU libiconv. This helps ensuring conversion compatibility.
- UTF-16 surrogate support and some endianness issues have been fixed.
- The rather chaotic Makefiles to build metadata have been refactored
and cleaned up, now it is easy to read and it is also easier to add
support for new encodings.
- A bunch of new encodings and encoding aliases have been added.
- Support for 1->2, 1->3 and 1->4 mappings, which is needed for
transliterating with flying accents as GNU does, like "u.
- Lots of warnings have been fixed, the major part of the code is
now WARNS=6 clean.
- New section 1 and section 5 manual pages have been added.
- Some GNU-specific calls have been implemented:
iconvlist(), iconvctl(), iconv_canonicalize(), iconv_open_into()
- Support for GNU's //IGNORE suffix has been added.
- The "-" argument for stdin is now recognized in iconv(1) as per POSIX.
- The Big5 conversion module has been fixed.
- The iconv.h header files is supposed to be compatible with the
GNU version, i.e. sources should build with base iconv.h and
GNU libiconv. It also includes a macro magic to deal with the
char ** and const char ** incompatibility.
- GNU compatibility: "" or "char" means the current local
encoding in use
- Various cleanups and style(9) fixes.
Approved by: delphij (mentor)
Obtained from: The NetBSD Project
Sponsored by: Google Summer of Code 2009
2011-02-25 00:04:39 +00:00
|
|
|
.if ${MK_ICONV} != "no"
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/iconv/Makefile.inc"
|
Add the BSD-licensed Citrus iconv to the base system with default off
setting. It can be built by setting the WITH_ICONV knob. While this
knob is unset, the library part, the binaries, the header file and
the metadata files will not be built or installed so it makes no impact
on the system if left turned off.
This work is based on the iconv implementation in NetBSD but a great
number of improvements and feature additions have been included:
- Some utilities have been added. There is a conversion table generator,
which can compare conversion tables to reference data generated by
GNU libiconv. This helps ensuring conversion compatibility.
- UTF-16 surrogate support and some endianness issues have been fixed.
- The rather chaotic Makefiles to build metadata have been refactored
and cleaned up, now it is easy to read and it is also easier to add
support for new encodings.
- A bunch of new encodings and encoding aliases have been added.
- Support for 1->2, 1->3 and 1->4 mappings, which is needed for
transliterating with flying accents as GNU does, like "u.
- Lots of warnings have been fixed, the major part of the code is
now WARNS=6 clean.
- New section 1 and section 5 manual pages have been added.
- Some GNU-specific calls have been implemented:
iconvlist(), iconvctl(), iconv_canonicalize(), iconv_open_into()
- Support for GNU's //IGNORE suffix has been added.
- The "-" argument for stdin is now recognized in iconv(1) as per POSIX.
- The Big5 conversion module has been fixed.
- The iconv.h header files is supposed to be compatible with the
GNU version, i.e. sources should build with base iconv.h and
GNU libiconv. It also includes a macro magic to deal with the
char ** and const char ** incompatibility.
- GNU compatibility: "" or "char" means the current local
encoding in use
- Various cleanups and style(9) fixes.
Approved by: delphij (mentor)
Obtained from: The NetBSD Project
Sponsored by: Google Summer of Code 2009
2011-02-25 00:04:39 +00:00
|
|
|
.endif
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/inet/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/isc/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/locale/Makefile.inc"
|
2014-08-12 12:25:56 +00:00
|
|
|
.include "${LIBC_SRCTOP}/md/Makefile.inc"
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/nameser/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/net/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/nls/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
|
2015-04-07 09:52:14 +00:00
|
|
|
.if ${LIBC_ARCH} != "aarch64" && \
|
|
|
|
${LIBC_ARCH} != "amd64" && \
|
2010-08-24 20:54:43 +00:00
|
|
|
${LIBC_ARCH} != "powerpc64" && \
|
2016-01-17 15:21:23 +00:00
|
|
|
${LIBC_ARCH} != "riscv" && \
|
2010-08-24 20:54:43 +00:00
|
|
|
${LIBC_ARCH} != "sparc64" && \
|
2011-01-27 14:16:12 +00:00
|
|
|
${MACHINE_ARCH:Mmipsn32*} == "" && \
|
2011-01-07 20:26:33 +00:00
|
|
|
${MACHINE_ARCH:Mmips64*} == ""
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/quad/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.endif
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/regex/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/resolv/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/stdio/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/stdlib/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/stdtime/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/string/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/sys/Makefile.inc"
|
2015-08-14 03:03:13 +00:00
|
|
|
.include "${LIBC_SRCTOP}/secure/Makefile.inc"
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/rpc/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/uuid/Makefile.inc"
|
|
|
|
.include "${LIBC_SRCTOP}/xdr/Makefile.inc"
|
2014-03-23 12:49:25 +00:00
|
|
|
.if (${LIBC_ARCH} == "arm" && ${MACHINE_ARCH} != "armv6hf") ||\
|
2016-01-18 09:36:10 +00:00
|
|
|
${LIBC_ARCH} == "mips"
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
|
2004-05-14 12:04:31 +00:00
|
|
|
.endif
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_NIS} != "no"
|
2002-11-18 09:50:57 +00:00
|
|
|
CFLAGS+= -DYP
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/yp/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.endif
|
2014-03-04 02:19:39 +00:00
|
|
|
.include "${LIBC_SRCTOP}/capability/Makefile.inc"
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_HESIOD} != "no"
|
2002-11-18 09:50:57 +00:00
|
|
|
CFLAGS+= -DHESIOD
|
|
|
|
.endif
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_FP_LIBC} == "no"
|
2004-05-02 10:55:07 +00:00
|
|
|
CFLAGS+= -DNO_FLOATING_POINT
|
|
|
|
.endif
|
2006-04-28 12:03:38 +00:00
|
|
|
.if ${MK_NS_CACHING} != "no"
|
|
|
|
CFLAGS+= -DNS_CACHING
|
|
|
|
.endif
|
2007-03-04 12:25:03 +00:00
|
|
|
.if defined(_FREEFALL_CONFIG)
|
|
|
|
CFLAGS+=-D_FREEFALL_CONFIG
|
|
|
|
.endif
|
2002-11-18 09:50:57 +00:00
|
|
|
|
2013-11-25 20:17:55 +00:00
|
|
|
STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
|
|
|
|
|
2014-03-04 02:19:39 +00:00
|
|
|
VERSION_DEF=${LIBC_SRCTOP}/Versions.def
|
2006-03-16 15:16:23 +00:00
|
|
|
SYMBOL_MAPS=${SYM_MAPS}
|
|
|
|
CFLAGS+= -DSYMBOL_VERSIONING
|
|
|
|
|
2002-11-18 09:50:57 +00:00
|
|
|
# If there are no machine dependent sources, append all the
|
|
|
|
# machine-independent sources:
|
|
|
|
.if empty(MDSRCS)
|
|
|
|
SRCS+= ${MISRCS}
|
|
|
|
.else
|
|
|
|
# Append machine-dependent sources, then append machine-independent sources
|
|
|
|
# for which there is no machine-dependent variant.
|
|
|
|
SRCS+= ${MDSRCS}
|
|
|
|
.for _src in ${MISRCS}
|
|
|
|
.if ${MDSRCS:R:M${_src:R}} == ""
|
|
|
|
SRCS+= ${_src}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endif
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
|
|
|
|
lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
|
|
|
|
subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
|
2012-01-03 07:14:01 +00:00
|
|
|
KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
|
|
|
|
strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-08-24 20:54:43 +00:00
|
|
|
libkern: libkern.gen libkern.${LIBC_ARCH}
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
libkern.gen: ${KQSRCS} ${KSRCS}
|
2015-01-16 21:39:08 +00:00
|
|
|
${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-08-24 20:54:43 +00:00
|
|
|
libkern.${LIBC_ARCH}:: ${KMSRCS}
|
1994-05-27 05:00:24 +00:00
|
|
|
.if defined(KMSRCS) && !empty(KMSRCS)
|
2015-01-16 21:39:08 +00:00
|
|
|
${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
|
1994-05-27 05:00:24 +00:00
|
|
|
.endif
|
2010-08-23 15:18:35 +00:00
|
|
|
|
2015-04-27 06:49:27 +00:00
|
|
|
.if ${MK_TESTS} != "no"
|
|
|
|
SUBDIR+= tests
|
|
|
|
.endif
|
2014-11-04 00:56:25 +00:00
|
|
|
|
1994-05-27 05:00:24 +00:00
|
|
|
.include <bsd.lib.mk>
|
2004-01-11 10:42:47 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !defined(_SKIP_BUILD)
|
|
|
|
# We need libutil.h, get it directly to avoid
|
|
|
|
# recording a build dependency
|
2016-01-25 19:11:34 +00:00
|
|
|
CFLAGS+= -I${SRCTOP}/lib/libutil
|
2012-08-22 19:25:57 +00:00
|
|
|
# Same issue with libm
|
2016-01-25 19:11:34 +00:00
|
|
|
MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
|
2012-08-22 19:25:57 +00:00
|
|
|
# unfortunately msun/src contains both private and public headers
|
2016-01-27 00:24:24 +00:00
|
|
|
CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
|
2013-10-13 00:29:14 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
|
2016-01-25 19:11:34 +00:00
|
|
|
CFLAGS+= -I${SRCTOP}/lib/msun/x86
|
2013-10-13 00:29:14 +00:00
|
|
|
.endif
|
2016-01-25 19:11:34 +00:00
|
|
|
CFLAGS+= -I${SRCTOP}/lib/msun/src
|
2013-10-13 00:29:14 +00:00
|
|
|
# and we do not want to record a dependency on msun
|
|
|
|
.if ${.MAKE.LEVEL} > 0
|
|
|
|
GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
|
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2004-01-11 10:42:47 +00:00
|
|
|
# Disable warnings in contributed sources.
|
2010-08-01 12:35:01 +00:00
|
|
|
CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
|
2008-06-25 21:33:28 +00:00
|
|
|
# XXX For now, we don't allow libc to be compiled with
|
|
|
|
# -fstack-protector-all because it breaks rtld. We may want to make a librtld
|
|
|
|
# in the future to circumvent this.
|
|
|
|
SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
|
|
|
|
# Disable stack protection for SSP symbols.
|
|
|
|
SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
|
2010-09-25 01:57:47 +00:00
|
|
|
# Generate stack unwinding tables for cancellation points
|
|
|
|
CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
|