[02/18] Use LFS and 64 bit time for installed programs

Message ID 20210617115104.1359598-3-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • More y2038 fixes
Related show

Commit Message

Noah Goldstein via Libc-alpha June 17, 2021, 11:50 a.m.
The installed programs are built with a combination of different
values for MODULE_NAME, as below.  To enable both Long File Support
and 64 bt time, -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 is added for
nonlib, nscd, lddlibc4, ldconfig, locale_programs, and iconvprogs
modules.

  nscd/nscd
    nscd/nscd.o                           MODULE_NAME=nscd
    nscd/connections.o                    MODULE_NAME=nscd
    nscd/pwdcache.o                       MODULE_NAME=nscd
    nscd/getpwnam_r.o                     MODULE_NAME=nscd
    nscd/getpwuid_r.o                     MODULE_NAME=nscd
    nscd/grpcache.o                       MODULE_NAME=nscd
    nscd/getgrnam_r.o                     MODULE_NAME=nscd
    nscd/getgrgid_r.o                     MODULE_NAME=nscd
    nscd/hstcache.o                       MODULE_NAME=nscd
    nscd/gethstbyad_r.o                   MODULE_NAME=nscd
    nscd/gethstbynm3_r.o                  MODULE_NAME=nscd
    nscd/getsrvbynm_r.o                   MODULE_NAME=nscd
    nscd/getsrvbypt_r.o                   MODULE_NAME=nscd
    nscd/servicescache.o                  MODULE_NAME=nscd
    nscd/dbg_log.o                        MODULE_NAME=nscd
    nscd/nscd_conf.o                      MODULE_NAME=nscd
    nscd/nscd_stat.o                      MODULE_NAME=nscd
    nscd/cache.o                          MODULE_NAME=nscd
    nscd/mem.o                            MODULE_NAME=nscd
    nscd/nscd_setup_thread.o              MODULE_NAME=nscd
    nscd/xmalloc.o                        MODULE_NAME=nscd
    nscd/xstrdup.o                        MODULE_NAME=nscd
    nscd/aicache.o                        MODULE_NAME=nscd
    nscd/initgrcache.o                    MODULE_NAME=nscd
    nscd/gai.o                            MODULE_NAME=nscd
    nscd/res_hconf.o                      MODULE_NAME=nscd
    nscd/netgroupcache.o                  MODULE_NAME=nscd
    nscd/cachedumper.o                    MODULE_NAME=nscd
  elf/lddlibc4
    elf/lddlibc4                          MODULE_NAME=lddlibc4
  elf/pldd
    elf/pldd.o                            MODULE_NAME=nonlib
    elf/xmalloc.o                         MODULE_NAME=nonlib
  elf/sln
    elf/sln.o                             MODULE_NAME=nonlib
    elf/static-stubs.o                    MODULE_NAME=nonlib
  elf/sprof                               MODULE_NAME=nonlib
  elf/ldconfig
    elf/ldconfig.o                        MODULE_NAME=ldconfig
    elf/cache.o                           MODULE_NAME=nonlib
    elf/readlib.o                         MODULE_NAME=nonlib
    elf/xmalloc.o                         MODULE_NAME=nonlib
    elf/xstrdup.o                         MODULE_NAME=nonlib
    elf/chroot_canon.o                    MODULE_NAME=nonlib
    elf/static-stubs.o                    MODULE_NAME=nonlib
    elf/stringtable.o                     MODULE_NAME=nonlib
  io/pwd
    io/pwd.o                              MODULE_NAME=nonlib
  locale/locale
    locale/locale.o                       MODULE_NAME=locale_programs
    locale/locale-spec.o                  MODULE_NAME=locale_programs
    locale/charmap-dir.o                  MODULE_NAME=locale_programs
    locale/simple-hash.o                  MODULE_NAME=locale_programs
    locale/xmalloc.o                      MODULE_NAME=locale_programs
    locale/xstrdup.o                      MODULE_NAME=locale_programs
    locale/record-status.o                MODULE_NAME=locale_programs
    locale/xasprintf.o                    MODULE_NAME=locale_programs
  locale/localedef
    locale/localedef.o                    MODULE_NAME=locale_programs
    locale/ld-ctype.o                     MODULE_NAME=locale_programs
    locale/ld-messages.o                  MODULE_NAME=locale_programs
    locale/ld-monetary.o                  MODULE_NAME=locale_programs
    locale/ld-numeric.o                   MODULE_NAME=locale_programs
    locale/ld-time.o                      MODULE_NAME=locale_programs
    locale/ld-paper.o                     MODULE_NAME=locale_programs
    locale/ld-name.o                      MODULE_NAME=locale_programs
    locale/ld-address.o                   MODULE_NAME=locale_programs
    locale/ld-telephone.o                 MODULE_NAME=locale_programs
    locale/ld-measurement.o               MODULE_NAME=locale_programs
    locale/ld-identification.o            MODULE_NAME=locale_programs
    locale/ld-collate.o                   MODULE_NAME=locale_programs
    locale/charmap.o                      MODULE_NAME=locale_programs
    locale/linereader.o                   MODULE_NAME=locale_programs
    locale/locfile.o                      MODULE_NAME=locale_programs
    locale/repertoire.o                   MODULE_NAME=locale_programs
    locale/locarchive.o                   MODULE_NAME=locale_programs
    locale/md5.o                          MODULE_NAME=locale_programs
    locale/charmap-dir.o                  MODULE_NAME=locale_programs
    locale/simple-hash.o                  MODULE_NAME=locale_programs
    locale/xmalloc.o                      MODULE_NAME=locale_programs
    locale/xstrdup.o                      MODULE_NAME=locale_programs
    locale/record-status.o                MODULE_NAME=locale_programs
    locale/xasprintf.o                    MODULE_NAME=locale_programs
  catgets/gencat
    catgets/gencat.o                      MODULE_NAME=nonlib
    catgets/xmalloc.o                     MODULE_NAME=nonlib
  nss/makedb
    nss/makedb.o                          MODULE_NAME=nonlib
    nss/xmalloc.o                         MODULE_NAME=nonlib
    nss/hash-string.o                     MODULE_NAME=nonlib
  nss/getent
    nss/getent.o                          MODULE_NAME=nonlib
  posix/getconf
    posix/getconf.o                       MODULE_NAME=nonlib
  login/utmpdump
    login/utmpdump.o                      MODULE_NAME=nonlib
  debug/pcprofiledump
    debug/pcprofiledump.o                 MODULE_NAME=nonlib
  timezone/zic
    timezone/zic.o                        MODULE_NAME=nonlib
  timezone/zdump
    timezone/zdump.o                      MODULE_NAME=nonlib
  iconv/iconv_prog
    iconv/iconv_prog.o                    MODULE_NAME=nonlib
    iconv/iconv_charmap.o                 MODULE_NAME=iconvprogs
    iconv/charmap.o                       MODULE_NAME=iconvprogs
    iconv/charmap-dir.o                   MODULE_NAME=iconvprogs
    iconv/linereader.o                    MODULE_NAME=iconvprogs
    iconv/dummy-repertoire.o              MODULE_NAME=iconvprogs
    iconv/simple-hash.o                   MODULE_NAME=iconvprogs
    iconv/xstrdup.o                       MODULE_NAME=iconvprogs
    iconv/xmalloc.o                       MODULE_NAME=iconvprogs
    iconv/record-status.o                 MODULE_NAME=iconvprogs
  iconv/iconvconfig
    iconv/iconvconfig.o                   MODULE_NAME=nonlib
    iconv/strtab.o                        MODULE_NAME=iconvprogs
    iconv/xmalloc.o                       MODULE_NAME=iconvprogs
    iconv/hash-string.o                   MODULE_NAME=iconvprogs

Also, to avoid addinf both LFS and 64 bit time support on internal
tests they are moved to a newer 'testsuite-internal' module.  It
should be similar to 'nonlib' regarding internal definition and
linking namespace.

This patch also enables LFS and 64 bit support of libsupport container
programs (echo-container, test-container, shell-container, and
true-container).

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 Makeconfig          |  8 ++++++--
 Makerules           | 12 ++++++++++--
 locale/localeinfo.h |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)

-- 
2.30.2

Comments

Andreas Schwab June 17, 2021, 12:19 p.m. | #1
On Jun 17 2021, Adhemerval Zanella via Libc-alpha wrote:

> diff --git a/Makeconfig b/Makeconfig

> index 6482a43025..de30ba3fa6 100644

> --- a/Makeconfig

> +++ b/Makeconfig

> @@ -851,6 +851,10 @@ endif

>  # -fno-math-errno.

>  +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)

>  

> +# Use 64 bit time_t support for installed programs

> ++extra-time-flags = $(if $(filter nonlib nscd lddlibc4 ldconfig locale_programs iconvprogs,\


I'd suggest to put the list of module names in a variable, to make it
easier to shorten the line.

> diff --git a/Makerules b/Makerules

> index 12f1a5cb50..770a573134 100644

> --- a/Makerules

> +++ b/Makerules

> @@ -1313,14 +1313,22 @@ lib := testsuite

>  include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))

>  endif

>  

> -all-nonlib := $(strip $(tests-internal) $(test-internal-extras) \

> -		      $(others) $(others-extras))

> +all-nonlib := $(strip $(others) $(others-extras))

>  ifneq (,$(all-nonlib))

>  cpp-srcs-left = $(all-nonlib)

>  lib := nonlib

>  include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))

>  endif

>  

> +# All internal tests use testsuite-internal module since for 64 bit time

> +# support is set as default for MODULE_NAME=nonlib (which include some

> +# installed programs.


Missing close paren.

> diff --git a/locale/localeinfo.h b/locale/localeinfo.h

> index b3d4da0185..9e53681829 100644

> --- a/locale/localeinfo.h

> +++ b/locale/localeinfo.h

> @@ -50,7 +50,7 @@ struct __locale_data

>  {

>    const char *name;

>    const char *filedata;		/* Region mapping the file data.  */

> -  off_t filesize;		/* Size of the file (and the region).  */

> +  __off_t filesize;		/* Size of the file (and the region).  */


Why is that needed?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Joseph Myers June 17, 2021, 8:49 p.m. | #2
On Thu, 17 Jun 2021, Adhemerval Zanella via Libc-alpha wrote:

> The installed programs are built with a combination of different

> values for MODULE_NAME, as below.  To enable both Long File Support

> and 64 bt time, -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 is added for

> nonlib, nscd, lddlibc4, ldconfig, locale_programs, and iconvprogs

> modules.


Using 64-bit filesystem interfaces in installed programs is bug 15333.

Does this patch fix all instances where an installed program, on a 32-bit 
system, might end up using 32-bit filesystem or time interfaces (including 
any cases where APIs used in the programs need to change to fix things, 
e.g. any uses of fseek/ftell that need to become fseeko / ftello with use 
of off_t instead of long), or are there further cases left to be fixed?

-- 
Joseph S. Myers
joseph@codesourcery.com
Noah Goldstein via Libc-alpha June 18, 2021, 6:14 p.m. | #3
On 17/06/2021 17:49, Joseph Myers wrote:
> On Thu, 17 Jun 2021, Adhemerval Zanella via Libc-alpha wrote:

> 

>> The installed programs are built with a combination of different

>> values for MODULE_NAME, as below.  To enable both Long File Support

>> and 64 bt time, -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 is added for

>> nonlib, nscd, lddlibc4, ldconfig, locale_programs, and iconvprogs

>> modules.

> 

> Using 64-bit filesystem interfaces in installed programs is bug 15333.

> 

> Does this patch fix all instances where an installed program, on a 32-bit 

> system, might end up using 32-bit filesystem or time interfaces (including 

> any cases where APIs used in the programs need to change to fix things, 

> e.g. any uses of fseek/ftell that need to become fseeko / ftello with use 

> of off_t instead of long), or are there further cases left to be fixed?

> 


It seems that this patch still misses some non LFS usages:

time32:  : /lib/libmemusage.so: setitimer
non-lfs: : /lib/libnss_files-2.33.9000.so: fsetpos
non-lfs: : /lib/libnss_files-2.33.9000.so: fgetpos
non-lfs: : /lib/libutil-2.33.9000.so: open
non-lfs: : /lib/libmemusage.so: mmap
non-lfs: : /lib/libmemusage.so: lseek
non-lfs: : /lib/libnss_compat-2.33.9000.so: fsetpos
non-lfs: : /lib/libnss_compat-2.33.9000.so: fgetpos
non-lfs: : /lib/libSegFault.so: open
non-lfs: : /lib/libnss_db-2.33.9000.so: mmap
non-lfs: : /lib/libpcprofile.so: open
non-lfs: : /lib/libnss_hesiod-2.33.9000.so: fopen
non-lfs: : /lib/libresolv-2.33.9000.so: fopen
non-lfs: : /usr/lib/audit/sotruss-lib.so: fcntl
non-lfs: : /usr/lib/audit/sotruss-lib.so: open

I will send an updated version.
Noah Goldstein via Libc-alpha June 18, 2021, 6:50 p.m. | #4
On 17/06/2021 09:19, Andreas Schwab wrote:
> On Jun 17 2021, Adhemerval Zanella via Libc-alpha wrote:

> 

>> diff --git a/Makeconfig b/Makeconfig

>> index 6482a43025..de30ba3fa6 100644

>> --- a/Makeconfig

>> +++ b/Makeconfig

>> @@ -851,6 +851,10 @@ endif

>>  # -fno-math-errno.

>>  +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)

>>  

>> +# Use 64 bit time_t support for installed programs

>> ++extra-time-flags = $(if $(filter nonlib nscd lddlibc4 ldconfig locale_programs iconvprogs,\

> 

> I'd suggest to put the list of module names in a variable, to make it

> easier to shorten the line.


I will add it.

> 

>> diff --git a/Makerules b/Makerules

>> index 12f1a5cb50..770a573134 100644

>> --- a/Makerules

>> +++ b/Makerules

>> @@ -1313,14 +1313,22 @@ lib := testsuite

>>  include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))

>>  endif

>>  

>> -all-nonlib := $(strip $(tests-internal) $(test-internal-extras) \

>> -		      $(others) $(others-extras))

>> +all-nonlib := $(strip $(others) $(others-extras))

>>  ifneq (,$(all-nonlib))

>>  cpp-srcs-left = $(all-nonlib)

>>  lib := nonlib

>>  include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))

>>  endif

>>  

>> +# All internal tests use testsuite-internal module since for 64 bit time

>> +# support is set as default for MODULE_NAME=nonlib (which include some

>> +# installed programs.

> 

> Missing close paren.


Ack.

> 

>> diff --git a/locale/localeinfo.h b/locale/localeinfo.h

>> index b3d4da0185..9e53681829 100644

>> --- a/locale/localeinfo.h

>> +++ b/locale/localeinfo.h

>> @@ -50,7 +50,7 @@ struct __locale_data

>>  {

>>    const char *name;

>>    const char *filedata;		/* Region mapping the file data.  */

>> -  off_t filesize;		/* Size of the file (and the region).  */

>> +  __off_t filesize;		/* Size of the file (and the region).  */

> 

> Why is that needed?


It is a leftover from development, I will remove it.

Patch

diff --git a/Makeconfig b/Makeconfig
index 6482a43025..de30ba3fa6 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -851,6 +851,10 @@  endif
 # -fno-math-errno.
 +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
 
+# Use 64 bit time_t support for installed programs
++extra-time-flags = $(if $(filter nonlib nscd lddlibc4 ldconfig locale_programs iconvprogs,\
+                           $(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
+
 # We might want to compile with some stack-protection flag.
 ifneq ($(stack-protector),)
 +stack-protector=$(stack-protector)
@@ -951,7 +955,7 @@  libio-include = -I$(..)libio
 built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
 		libSegFault libpcprofile librpcsvc locale-programs \
 		memusagestat nonlib nscd extramodules libnldbl libsupport \
-		testsuite
+		testsuite testsuite-internal
 
 in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
 				    $(libof-$(<F)) \
@@ -991,7 +995,7 @@  endif
 
 override CFLAGS	= -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
 		  $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
-		  $(+extra-math-flags) \
+		  $(+extra-math-flags) $(+extra-time-flags) \
 		  $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
 		  $(CFLAGS-$(@F)) $(tls-model) \
 		  $(foreach lib,$(libof-$(basename $(@F))) \
diff --git a/Makerules b/Makerules
index 12f1a5cb50..770a573134 100644
--- a/Makerules
+++ b/Makerules
@@ -1313,14 +1313,22 @@  lib := testsuite
 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
 endif
 
-all-nonlib := $(strip $(tests-internal) $(test-internal-extras) \
-		      $(others) $(others-extras))
+all-nonlib := $(strip $(others) $(others-extras))
 ifneq (,$(all-nonlib))
 cpp-srcs-left = $(all-nonlib)
 lib := nonlib
 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
 endif
 
+# All internal tests use testsuite-internal module since for 64 bit time
+# support is set as default for MODULE_NAME=nonlib (which include some
+# installed programs.
+all-testsuite-internal := $(strip $(tests-internal) $(test-internal-extras))
+ifneq (,$(all-testsuite-internal))
+cpp-srcs-left = $(all-testsuite-internal)
+lib := testsuite-internal
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
 
 ifeq ($(build-shared),yes)
 # Generate normalized lists of symbols, versions, and data sizes.
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index b3d4da0185..9e53681829 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -50,7 +50,7 @@  struct __locale_data
 {
   const char *name;
   const char *filedata;		/* Region mapping the file data.  */
-  off_t filesize;		/* Size of the file (and the region).  */
+  __off_t filesize;		/* Size of the file (and the region).  */
   enum				/* Flavor of storage used for those.  */
   {
     ld_malloced,		/* Both are malloc'd.  */