[01/20] Initial empty CPU run-time library for C: libcpu-rt-c

Message ID 20180612221939.19545-2-hjl.tools@gmail.com
State New
Headers show
Series
  • RFC: Add the CPU run-time library for C
Related show

Commit Message

H.J. Lu June 12, 2018, 10:19 p.m.
Add the --enable-cpu-rt configure option to enable the CPU run-time
library for C, libcpu-rt-c.  libcpu-rt-c contains a subset of the C
library with the optimized functions.  The resulting libcpu-rt-c.so
should be binary compatible with older versions of libc.so so that
libcpu-rt-c.so can be used with LD_PRELOAD or linked directly with
applications.

	* Makeconfig (rpath-dirs): Add cpu-rt-c.
	(all-subdirs): Likewise.
	* configure: Regenerated.
	* configure.ac: Add --enable-cpu-rt.
	(build-cpu-rt): New LIBC_CONFIG_VAR.
	* shlib-versions: Add libcpu_rt-c.
	* cpu-rt-c/Makefile: New file.
---
 Makeconfig        |  4 ++--
 configure         | 17 +++++++++++++++++
 configure.ac      | 11 +++++++++++
 cpu-rt-c/Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
 shlib-versions    |  3 +++
 5 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 cpu-rt-c/Makefile

Comments

Joseph Myers June 12, 2018, 11:20 p.m. | #1
Any new configure option needs documentation in install.texi with INSTALL 
regenerated.  Any such new feature needs documenting in NEWS as well.

I'd expect any such new library to have ABI test baselines.  If for some 
reason ABI tests don't get run for this library, that's also a problem; 
you said it can be linked directly with applications, which means it needs 
to be ABI tested to make sure the ABI is properly stable.
H.J. Lu June 13, 2018, 11:21 a.m. | #2
On Tue, Jun 12, 2018 at 4:20 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> Any new configure option needs documentation in install.texi with INSTALL
> regenerated.  Any such new feature needs documenting in NEWS as well.

Here is the patch to document --enable-cpu-rt:

https://github.com/hjl-tools/glibc/commit/2d6391762652a39fb8b64b3a87da4b0d92c53616

> I'd expect any such new library to have ABI test baselines.  If for some
> reason ABI tests don't get run for this library, that's also a problem;
> you said it can be linked directly with applications, which means it needs
> to be ABI tested to make sure the ABI is properly stable.
>

Here is the patch to add ABI test:

https://github.com/hjl-tools/glibc/commit/a14b8035029ffc248fef53772c557483bcb45985

I will collect more feedbacks and submit a new set of patches.

Patch

diff --git a/Makeconfig b/Makeconfig
index 1afe86475c..ed894b7c8f 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -566,7 +566,7 @@  link-libc-printers-tests = $(link-libc-rpath) \
 			   $(link-libc-tests-after-rpath-link)
 
 # This is how to find at build-time things that will be installed there.
-rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec support
+rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec cpu-rt-c support
 rpath-link = \
 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
 else  # build-static
@@ -1206,7 +1206,7 @@  all-subdirs = csu assert ctype locale intl catgets math setjmp signal	    \
 	      grp pwd posix io termios resource misc socket sysvipc gmon    \
 	      gnulib iconv iconvdata wctype manual shadow gshadow po argp   \
 	      crypt localedata timezone rt conform debug mathvec support    \
-	      dlfcn elf
+	      dlfcn elf cpu-rt-c
 
 ifndef avoid-generated
 # sysd-sorted itself will contain rules making the sysd-sorted target
diff --git a/configure b/configure
index 7a8bd3f817..580bebb75d 100755
--- a/configure
+++ b/configure
@@ -788,6 +788,7 @@  enable_nscd
 enable_pt_chown
 enable_tunables
 enable_mathvec
+enable_cpu_rt
 with_cpu
 '
       ac_precious_vars='build_alias
@@ -1461,6 +1462,8 @@  Optional Features:
                           'no' and 'valstring'
   --enable-mathvec        Enable building and installing mathvec [default
                           depends on architecture]
+  --enable-cpu-rt         Enable building and installing CPU run-time library
+                          [default depends on architecture]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -3741,6 +3744,14 @@  else
 fi
 
 
+# Check whether --enable-cpu-rt was given.
+if test "${enable_cpu_rt+set}" = set; then :
+  enableval=$enable_cpu_rt; build_cpu_rt=$enableval
+else
+  build_cpu_rt=notset
+fi
+
+
 # We keep the original values in `$config_*' and never modify them, so we
 # can write them unchanged into config.make.  Everything else uses
 # $machine, $vendor, and $os, and changes them whenever convenient.
@@ -6678,6 +6689,12 @@  fi
 config_vars="$config_vars
 build-mathvec = $build_mathvec"
 
+if test x"$build_cpu_rt" = xnotset; then
+  build_cpu_rt=no
+fi
+config_vars="$config_vars
+build-cpu-rt = $build_cpu_rt"
+
 
 
 
diff --git a/configure.ac b/configure.ac
index ca1282a6b3..a851d958f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -453,6 +453,12 @@  AC_ARG_ENABLE([mathvec],
 	      [build_mathvec=$enableval],
 	      [build_mathvec=notset])
 
+AC_ARG_ENABLE([cpu-rt],
+	      [AS_HELP_STRING([--enable-cpu-rt],
+	      [Enable building and installing CPU run-time library @<:@default depends on architecture@:>@])],
+	      [build_cpu_rt=$enableval],
+	      [build_cpu_rt=notset])
+
 # We keep the original values in `$config_*' and never modify them, so we
 # can write them unchanged into config.make.  Everything else uses
 # $machine, $vendor, and $os, and changes them whenever convenient.
@@ -1737,6 +1743,11 @@  if test x"$build_mathvec" = xnotset; then
 fi
 LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
 
+if test x"$build_cpu_rt" = xnotset; then
+  build_cpu_rt=no
+fi
+LIBC_CONFIG_VAR([build-cpu-rt], [$build_cpu_rt])
+
 AC_SUBST(libc_extra_cflags)
 AC_SUBST(libc_extra_cppflags)
 
diff --git a/cpu-rt-c/Makefile b/cpu-rt-c/Makefile
new file mode 100644
index 0000000000..f138911347
--- /dev/null
+++ b/cpu-rt-c/Makefile
@@ -0,0 +1,42 @@ 
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+# Makefile for the CPU run-time library for C.
+
+subdir		:= cpu-rt-c
+
+include ../Makeconfig
+
+ifeq ($(build-cpu-rt),yes)
+extra-libs	:= libcpu-rt-c
+extra-libs-others = $(extra-libs)
+
+libcpu-rt-c-sysdep_routines += $(cpu-rt-c-routines)
+libcpu-rt-c-tests += $(addprefix test-,$(cpu-rt-c-routines))
+tests += $(libcpu-rt-c-tests)
+endif
+
+include ../Rules
+
+ifeq ($(build-cpu-rt),yes)
+ifeq ($(build-shared),yes)
+libcpu-rt-c = $(objpfx)libcpu-rt-c.so
+else
+libcpu-rt-c = $(objpfx)libcpu-rt-c.a
+endif
+$(addprefix $(objpfx),$(libcpu-rt-c-tests)): $(libcpu-rt-c)
+endif
diff --git a/shlib-versions b/shlib-versions
index b9cb99d2fb..43e4c63f54 100644
--- a/shlib-versions
+++ b/shlib-versions
@@ -75,3 +75,6 @@  libgcc_s=1
 
 # The vector math library
 libmvec=1
+
+# The CPU run-time library for C
+libcpu_rt_c=1