git: e9d961055aa2 - main - libsys: plumb in to build
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 05 Feb 2024 20:38:44 UTC
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=e9d961055aa2502f4915611e8fb2e9f9f9c86719 commit e9d961055aa2502f4915611e8fb2e9f9f9c86719 Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2023-11-15 23:31:57 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2024-02-05 20:34:56 +0000 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 --- lib/Makefile | 3 ++ lib/libsys/Makefile | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/libsys/Makefile.sys | 2 ++ share/mk/src.libnames.mk | 11 ++++++++ 4 files changed, 89 insertions(+) diff --git a/lib/Makefile b/lib/Makefile index 4b1bda780b2d..db07883e2b10 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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} diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile new file mode 100644 index 000000000000..45d3fec14300 --- /dev/null +++ b/lib/libsys/Makefile @@ -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> diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index c2373b972bb1..f88a107f9eb8 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -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" diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index 33b8507a9eb9..5a6932614b29 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -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