libsys: plumb in to build

libsys provides the FreeBSD kernel interface (auxargs, system calls,
vdso).  It can be linked directly for programs using a non-standard
libc and will later be linked as a filter library to libc providing
the actual system call implementation.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
This commit is contained in:
Brooks Davis 2023-11-15 23:31:57 +00:00
parent 86deddfacb
commit e9d961055a
4 changed files with 89 additions and 0 deletions

View file

@ -19,6 +19,7 @@ SUBDIR_BOOTSTRAP= \
libelf \
libssp \
libssp_nonshared \
libsys \
msun
# The main list; please keep these sorted alphabetically.
@ -137,6 +138,8 @@ SUBDIR_DEPEND_libpjdlog= libutil
SUBDIR_DEPEND_libprocstat= libkvm libutil
SUBDIR_DEPEND_libradius= libmd
SUBDIR_DEPEND_libsmb= libkiconv
# See comment above about libssp_nonshared
SUBDIR_DEPEND_libsys= libcompiler_rt libssp_nonshared
SUBDIR_DEPEND_libtacplus= libmd
SUBDIR_DEPEND_libulog= libmd
SUBDIR_DEPEND_libunbound= ${_libldns}

73
lib/libsys/Makefile Normal file
View file

@ -0,0 +1,73 @@
PACKAGE= clibs
SHLIBDIR?= /lib
.include <src.opts.mk>
LIBC_SRCTOP?= ${.CURDIR}/../libc
LIBSYS_SRCTOP?= ${.CURDIR}
# Pick the current architecture directory for libsys. In general, this is named
# MACHINE_CPUARCH, but some ABIs are different enough to require their own
# libsys, so allow a directory named MACHINE_ARCH to override this (though
# treat powerpc64le and powerpc64 the same).
# Note: This is copied from libc/Makefile
M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
.if exists(${LIBC_SRCTOP}/${M})
LIBC_ARCH=${M}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
LIB=sys
SHLIB_MAJOR= 7
WARNS?= 2
CFLAGS+=-I${LIBSYS_SRCTOP}/include -I${LIBC_SRCTOP}/include
CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH}
CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
CLEANFILES+=tags
INSTALL_PIC_ARCHIVE=
#XXX? BUILD_NOSSP_PIC_ARCHIVE=
PRECIOUSLIB=
# Use a more efficient TLS model for libc since we can reasonably assume that
# it will be loaded during program startup.
CFLAGS+= -ftls-model=initial-exec
#
# Link with static libcompiler_rt.a.
#
LDFLAGS+= -nodefaultlibs
LIBADD+= compiler_rt
.if ${MK_SSP} != "no" && \
(${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
LIBADD+= ssp_nonshared
.endif
#.if ${MK_SSP} != "no" && \
# (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
#LIBADD+= ssp_nonshared
#.endif
# Define (empty) variables so that make doesn't give substitution
# errors if the included makefiles don't change these:
MDASM=
MIASM=
NOASM=
.include "${LIBSYS_SRCTOP}/Makefile.sys"
VERSION_DEF=${LIBC_SRCTOP}/Versions.def
SYMBOL_MAPS=${SYM_MAPS}
# XXX: let libc install the manpages for now
MAN=
MLINKS=
# XXX: move sys tests?
#HAS_TESTS=
#SUBDIR.${MK_TESTS}+= tests
.include <bsd.lib.mk>

View file

@ -158,6 +158,7 @@ ${SPSEUDO}:
printf ${NOTE_GNU_STACK} >>${.TARGET}
printf ${FEATURE_NOTE} >> ${.TARGET}
.if ${LIB} == "sys"
MAN+= abort2.2 \
accept.2 \
access.2 \
@ -541,3 +542,4 @@ MLINKS+=wait.2 wait3.2 \
MLINKS+=write.2 pwrite.2 \
write.2 pwritev.2 \
write.2 writev.2
.endif # ${LIB} == "sys"

View file

@ -202,6 +202,7 @@ _LIBRARIES= \
stats \
stdthreads \
supcplusplus \
sys \
sysdecode \
tacplus \
termcapw \
@ -401,6 +402,13 @@ _DP_c+= ssp_nonshared
.endif
_DP_stats= sbuf pthread
_DP_stdthreads= pthread
_DP_sys= compiler_rt
# Use libssp_nonshared only on i386 and power*. Other archs emit direct calls
# to __stack_chk_fail, not __stack_chk_fail_local provided by libssp_nonshared.
.if ${MK_SSP} != "no" && \
(${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
_DP_sys+= ssp_nonshared
.endif
_DP_tacplus= md pam
_DP_ncursesw= tinfow
_DP_formw= ncursesw
@ -554,6 +562,9 @@ LIBSMDB?= ${LIBSMDBDIR}/libsmdb${PIE_SUFFIX}.a
LIBSMUTILDIR= ${_LIB_OBJTOP}/lib/libsmutil
LIBSMUTIL?= ${LIBSMUTILDIR}/libsmutil${PIE_SUFFIX}.a
LIBSYSDIR= ${_LIB_OBJTOP}/lib/libsys
LIBSYS?= ${LIBSYSDIR}/libsys${PIE_SUFFIX}.a
LIBNETBSDDIR?= ${_LIB_OBJTOP}/lib/libnetbsd
LIBNETBSD?= ${LIBNETBSDDIR}/libnetbsd${PIE_SUFFIX}.a