Commit Graph

467 Commits

Author SHA1 Message Date
H.J. Lu
c503c2603c Support compiling .S files with additional options
Add $(sysdep-ASFLAGS) $(ASFLAGS-$(<F)) $(ASFLAGS-$(@F)) to compile.S and
COMPILE.S to support compiling .S files with additional options.
2024-02-25 09:22:40 -08:00
H.J. Lu
1eae989cb7 Remove installed header rule on $(..)include/%.h
On x86-64 machine with

[hjl@gnu-cfl-3 x86-glibc]$ ls -l /usr/include/asm/prctl.h sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 hjl  hjl   825 Jan  9 09:41 sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 root root 1170 Nov 27 16:00 /usr/include/asm/prctl.h
[hjl@gnu-cfl-3 x86-glibc]$

glibc configured with --enable-cet build failed:

make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
../Makerules:327: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.stmp
:
../Makeconfig:1216: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.stmp
:
../Makerules:1126: update target '/usr/include/asm/prctl.h' due to:
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
force-install
/usr/bin/install -c -m 644
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
/usr/include/asm/prctl.h
/usr/bin/install: cannot remove '/usr/include/asm/prctl.h': Permission denied
make[2]: *** [../Makerules:1126: /usr/include/asm/prctl.h] Error 1
make[2]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2
make[1]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc'
make: *** [Makefile:9: all] Error 2

This is triggered by the rule in Makerules:

$(inst_includedir)/%.h: $(..)include/%.h $(+force)
  $(do-install)

Since no files under include/ should be installed, remove it from
Makerules.

Tested it on x86-64.  There are no differences in the installed header
files.
2024-01-09 10:35:37 -08:00
Paul Eggert
dff8da6b3e Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Maxim Kuvyrkov
7c507f4473 Fix tests-clean Makefile target (bug 30545)
This patch improves tests-clean Makefile target to reliably clean
test artifacts from a build directory.  Before this patch tests-clean
missed around 3k (out of total 9k) .out and .test-result files.

Signed-off-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-06-26 10:37:25 -03:00
Paul Pluzhnikov
7f0d9e61f4 Fix all the remaining misspellings -- BZ 25337 2023-06-02 01:39:48 +00:00
Adhemerval Zanella Netto
91fc5b9990 Remove --with-default-link configure option
Now that there is no need to use a special linker script to hardening
internal data structures, remove the --with-default-link configure
option and associated definitions.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27 13:57:55 -03:00
Adhemerval Zanella Netto
3020f72618 libio: Remove the usage of __libc_IO_vtables
Instead of using a special ELF section along with a linker script
directive to put the IO vtables within the RELRO section, the libio
vtables are all moved to an array marked as data.relro (so linker
will place in the RELRO segment without the need of extra directives).

To avoid static linking namespace issues and including all vtable
referenced objects, all required function pointers are set to weak alias.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27 13:57:55 -03:00
Adhemerval Zanella Netto
f65ca70dea libio: Do not autogenerate stdio_lim.h
Instead define the required fields in system dependend files.  The only
system dependent definition is FILENAME_MAX, which should match POSIX
PATH_MAX, and it is obtained from either kernel UAPI or mach headers.
Currently set pre-defined value from current kernels.

It avoids a circular dependendy when including stdio.h in
gen-as-const-headers files.

Checked on x86_64-linux-gnu and i686-linux-gnu
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27 13:57:55 -03:00
Adhemerval Zanella Netto
88677348b4 Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functions
They are both used by __libc_freeres to free all library malloc
allocated resources to help tooling like mtrace or valgrind with
memory leak tracking.

The current scheme uses assembly markers and linker script entries
to consolidate the free routine function pointers in the RELRO segment
and to be freed buffers in BSS.

This patch changes it to use specific free functions for
libc_freeres_ptrs buffers and call the function pointer array directly
with call_function_static_weak.

It allows the removal of both the internal macros and the linker
script sections.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27 13:57:55 -03:00
Joseph Myers
6d7e8eda9b Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
Adhemerval Zanella
5dcd2d0ad0 stdlib: Move _IO_cleanup to call_function_static_weak
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-12-12 09:53:23 -03:00
Fangrui Song
2ae7990542 Makerules: Generate shlib.lds with -fuse-ld=bfd
lld does not dump a linker script with --verbose (it does not use a
linker script driven design and lots of linker processing is not
serializable as a linker script anyway).  With the default
--with-default-link=no build, $@T is empty and makes `test -s $@T` fail.

Just dump the linker script with -fuse-ld=bfd.  lld since 15
(https://reviews.llvm.org/D124656) supports custom RELRO sections in the
GNU ld dumped linker script.

Reviewed-by: Sam James <sam@gentoo.org>
2022-11-08 20:56:59 -08:00
Sergei Trofimovich
2d7ed98add Makerules: fix MAKEFLAGS assignment for upcoming make-4.4 [BZ# 29564]
make-4.4 will add long flags to MAKEFLAGS variable:

    * WARNING: Backward-incompatibility!
      Previously only simple (one-letter) options were added to the MAKEFLAGS
      variable that was visible while parsing makefiles.  Now, all options
      are available in MAKEFLAGS.

This causes locale builds to fail when long options are used:

    $ make --shuffle
    ...
    make  -C localedata install-locales
    make: invalid shuffle mode: '1662724426r'

The change fixes it by passing eash option via whitespace and dashes.
That way option is appended to both single-word form and whitespace
separated form.

While at it fixed --silent mode detection in $(MAKEFLAGS) by filtering
out --long-options. Otherwise options like --shuffle flag enable silent
mode unintentionally. $(silent-make) variable consolidates the checks.

Resolves: BZ# 29564

CC: Paul Smith <psmith@gnu.org>
CC: Siddhesh Poyarekar <siddhesh@gotplt.org>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-13 13:45:32 -04:00
Florian Weimer
89baed0b93 Revert "Detect ld.so and libc.so version inconsistency during startup"
This reverts commit 6f85dbf102.

Once this change hits the release branches, it will require relinking
of all statically linked applications before static dlopen works
again, for the majority of updates on release branches: The NEWS file
is regularly updated with bug references, so the __libc_early_init
suffix changes, and static dlopen cannot find the function anymore.

While this ABI check is still technically correct (we do require
rebuilding & relinking after glibc updates to keep static dlopen
working), it is too drastic for stable release branches.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-08-25 18:46:43 +02:00
Florian Weimer
6f85dbf102 Detect ld.so and libc.so version inconsistency during startup
The files NEWS, include/link.h, and sysdeps/generic/ldsodefs.h
contribute to the version fingerprint used for detection.  The
fingerprint can be further refined using the --with-extra-version-id
configure argument.

_dl_call_libc_early_init is replaced with _dl_lookup_libc_early_init.
The new function is used store a pointer to libc.so's
__libc_early_init function in the libc_map_early_init member of the
ld.so namespace structure.  This function pointer can then be called
directly, so the separate invocation function is no longer needed.

The versioned symbol lookup needs the symbol versioning data
structures, so the initialization of libc_map and libc_map_early_init
is now done from _dl_check_map_versions, after this information
becomes available.  (_dl_map_object_from_fd does not set this up
in time, so the initialization code had to be moved from there.)
This means that the separate initialization code can be removed from
dl_main because _dl_check_map_versions covers all maps, including
the initial executable loaded by the kernel.  The lookup still happens
before relocation and the invocation of IFUNC resolvers, so IFUNC
resolvers are protected from ABI mismatch.

The __libc_early_init function pointer is not protected because
so little code runs between the pointer write and the invocation
(only dynamic linker code and IFUNC resolvers).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-08-24 17:35:57 +02:00
Fangrui Song
dbb0f06cc0 Makerules: Remove no-op -Wl,-d when linking libc_pic.os
In GNU ld, -d assigns space to common symbols for -r (i.e. change common
symbols to STB_GLOBAL definitions).  This option was added in commit
da2d1bc5ad (1998) perhaps because ld at
that time had a bug that common symbols did not override shared object
definitions.  -d has been long unneeded and more so since -fno-common
was added to +cflags.
2022-06-26 15:31:19 -07:00
H.J. Lu
2d5ec6692f Enable DT_RELR in glibc shared libraries and PIEs automatically
Enable DT_RELR in glibc shared libraries and position independent
executables (PIE) automatically if linker supports -z pack-relative-relocs.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-05-18 13:04:13 -07:00
Florian Weimer
e47de5cb2d Do not use --hash-style=both for building glibc shared objects
The comment indicates that --hash-style=both was used to maintain
compatibility with static dlopen, but we had many internal ABI
changes since then, so this compatiblity does not add value anymore.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-04-29 16:37:51 +02:00
H.J. Lu
1fe00d3eb6 build: Properly generate .d dependency files [BZ #28922]
1. Also generate .d dependency files for $(tests-container) and
$(tests-printers).
2. elf: Add tst-auditmod17.os to extra-test-objs.
3. iconv: Add tst-gconv-init-failure-mod.os to extra-test-objs.
4. malloc: Rename extra-tests-objs to extra-test-objs.
5. linux: Add tst-sysconf-iov_max-uapi.o to extra-test-objs.
6. x86_64: Add tst-x86_64mod-1.o, tst-platformmod-2.o, test-libmvec.o,
test-libmvec-avx.o, test-libmvec-avx2.o and test-libmvec-avx512f.o to
extra-test-objs.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-02-25 10:35:45 -08:00
H.J. Lu
114d07fd9a Add and use link-test-modules-rpath-link [BZ #28455]
DT_RUNPATH is only used to find the immediate dependencies of the
executable or shared object containing the DT_RUNPATH entry:

1. Define link-test-modules-rpath-link if $(build-hardcoded-path-in-tests)
is yes.
2. Use $(link-test-modules-rpath-link) in build-module-helper so that
test modules can dlopen modules with DT_RUNPATH.
3. Add a test to show why link-test-modules-rpath-link is needed.

This partially fixes BZ #28455.
2022-01-24 05:11:36 -08:00
Siddhesh Poyarekar
db27f1251b debug: Autogenerate _FORTIFY_SOURCE tests
Rename debug/tst-chk1.c to debug/tst-fortify.c and add make hackery to
autogenerate tests with different macros enabled to build and run the
same test with different configurations as well as different
fortification levels.

The change also ends up expanding the -lfs tests to include
_FORTIFY_SOURCE=3.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-01-12 23:34:23 +05:30
Paul Eggert
581c785bf3 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 7061 files FOO.

I then removed trailing white space from math/tgmath.h,
support/tst-support-open-dev-null-range.c, and
sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following
obscure pre-commit check failure diagnostics from Savannah.  I don't
know why I run into these diagnostics whereas others evidently do not.

remote: *** 912-#endif
remote: *** 913:
remote: *** 914-
remote: *** error: lines with trailing whitespace found
...
remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2022-01-01 11:40:24 -08:00
Adhemerval Zanella
a6d2f948b7 Use LFS and 64 bit time for installed programs (BZ #15333)
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
nonlibi, nscd, lddlibc4, libresolv, ldconfig, locale_programs,
iconvprogs, libnss_files, libnss_compat, libnss_db, libnss_hesiod,
libutil, libpcprofile, and libSegFault.

  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
  nss/libnss_files.so                     MODULE_NAME=libnss_files
  nss/libnss_compat.so.2                  MODULE_NAME=libnss_compat
  nss/libnss_db.so                        MODULE_NAME=libnss_db
  hesiod/libnss_hesiod.so                 MODULE_NAME=libnss_hesiod
  login/libutil.so                        MODULE_NAME=libutil
  debug/libpcprofile.so                   MODULE_NAME=libpcprofile
  debug/libSegFault.so                    MODULE_NAME=libSegFault

Also, to avoid adding 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.

Reviewed-by: DJ Delorie <dj@redhat.com>
2021-12-15 09:01:01 -03:00
H.J. Lu
0bd356df1a Remove the unused +mkdep/+make-deps/s-proto.S/s-proto-cancel.S
Since

commit d73f5331ce
Author: Roland McGrath <roland@gnu.org>
Date:   Fri May 2 02:20:45 2003 +0000

    2003-05-01  Roland McGrath  <roland@redhat.com>

dependency is generated by passing -MD -MF to compiler.  Remove the unused
+mkdep, +make-deps, s-proto.S and s-proto-cancel.S.

This fixes BZ #28554.
2021-11-10 04:54:18 -08:00
H.J. Lu
d465e5e0da Remove the last trace of generate-md5 [BZ #28554]
generate-md5 was removed by

commit d73f5331ce
Author: Roland McGrath <roland@gnu.org>
Date:   Fri May 2 02:20:45 2003 +0000

    2003-05-01  Roland McGrath  <roland@redhat.com>

Remove its last trace.  This fixes BZ #28554.
2021-11-06 06:21:44 -07:00
Florian Weimer
8208be389b Install shared objects under their ABI names
Previously, the installed objects were named like libc-2.33.so,
and the ABI soname libc.so.6 was just a symbolic link.

The Makefile targets to install these symbolic links are no longer
needed after this, so they are removed with this commit.  The more
general $(make-link) command (which invokes scripts/rellns-sh) is
retained because other symbolic links are still needed.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@rehdat.com>
2021-06-28 08:33:57 +02:00
Florian Weimer
b89d5de250 Makerules: Remove lib-version, $(subdir-version)
Also clarify that the "versioned" term refers to the soname, not the glibc
version (which also ends up in the installed file name).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-06-28 08:33:57 +02:00
Adhemerval Zanella
088d3291ef y2038: Add test coverage
It is enabled through a new rule, tests-y2038, which is built only
when the ABI supports the comapt 64-bit time_t (defined by the
header time64-compat.h, which also enables the creation of the
symbol Version for Linux).  It means the tests are not built
for ABI which already provide default 64-bit time_t.

The new rule already adds the required LFS and 64-bit time_t
compiler flags.

The current coverage is:

  * libc:
    - adjtime                       tst-adjtime-time64
    - adjtimex                      tst-adjtimex-time64
    - clock_adjtime                 tst-clock_adjtime-time64
    - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
    - clock_gettime                 tst-clock-time64, tst-clock2-time64,
				    tst-cpuclock1-time64
    - clock_nanosleep               tst-clock_nanosleep-time64,
				    tst-cpuclock1-time64
    - clock_settime                 tst-clock2-time64
    - cnd_timedwait                 tst-cnd-timedwait-time64
    - ctime                         tst-ctime-time64
    - ctime_r                       tst-ctime-time64
    - difftime                      tst-difftime-time64
    - fstat                         tst-stat-time64
    - fstatat                       tst-stat-time64
    - futimens                      tst-futimens-time64
    - futimes                       tst-futimes-time64
    - futimesat                     tst-futimesat-time64
    - fts_*                         tst-fts-time64
    - getitimer                     tst-itimer-timer64
    - getrusage
    - gettimeofday                  tst-clock_nanosleep-time64
    - glob / globfree               tst-gnuglob64-time64
    - gmtime                        tst-gmtime-time64
    - gmtime_r                      tst-gmtime-time64
    - lstat                         tst-stat-time64
    - localtime                     tst-y2039-time64
    - localtime_t                   tst-y2039-time64
    - lutimes                       tst-lutimes-time64
    - mktime                        tst-mktime4-time64
    - mq_timedreceive               tst-mqueue{1248}-time64
    - mq_timedsend                  tst-mqueue{1248}-time64
    - msgctl                        test-sysvmsg-time64
    - mtx_timedlock                 tst-mtx-timedlock-time64
    - nanosleep                     tst-cpuclock{12}-time64,
				    tst-mqueue8-time64, tst-clock-time64
    - nftw / ftw                    ftwtest-time64
    - ntp_adjtime                   tst-ntp_adjtime-time64
    - ntp_gettime                   tst-ntp_gettime-time64
    - ntp_gettimex                  tst-ntp_gettimex-time64
    - ppoll                         tst-ppoll-time64
    - pselect                       tst-pselect-time64
    - pthread_clockjoin_np          tst-join14-time64
    - pthread_cond_clockwait        tst-cond11-time64
    - pthread_cond_timedwait        tst-abstime-time64
    - pthread_mutex_clocklock       tst-abstime-time64
    - pthread_mutex_timedlock       tst-abstime-time64
    - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_timedjoin_np          tst-join14-time64
    - recvmmsg                      tst-cancel4_2-time64
    - sched_rr_get_interval         tst-sched_rr_get_interval-time64
    - select                        tst-select-time64
    - sem_clockwait                 tst-sem5-time64
    - sem_timedwait                 tst-sem5-time64
    - semctl                        test-sysvsem-time64
    - semtimedop                    test-sysvsem-time64
    - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
    - settimeofday                  tst-settimeofday-time64
    - shmctl                        test-sysvshm-time64
    - sigtimedwait                  tst-sigtimedwait-time64
    - stat                          tst-stat-time64
    - thrd_sleep                    tst-thrd-sleep-time64
    - time                          tst-mqueue{1248}-time64
    - timegm                        tst-timegm-time64
    - timer_gettime                 tst-timer4-time64
    - timer_settime                 tst-timer4-time64
    - timerfd_gettime               tst-timerfd-time64
    - timerfd_settime               tst-timerfd-time64
    - timespec_get                  tst-timespec_get-time64
    - timespec_getres               tst-timespec_getres-time64
    - utime                         tst-utime-time64
    - utimensat                     tst-utimensat-time64
    - utimes                        tst-utimes-time64
    - wait3                         tst-wait3-time64
    - wait4                         tst-wait4-time64

  * librt:
    - aio_suspend                   tst-aio6-time64
    - mq_timedreceive               tst-mqueue{1248}-time64
    - mq_timedsend                  tst-mqueue{1248}-time64
    - timer_gettime                 tst-timer4-time64
    - timer_settime                 tst-timer4-time64

  * libanl:
    - gai_suspend

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-06-15 10:42:11 -03:00
Florian Weimer
0400f92833 Makerules: Do not require startup files for format.lds probe object
During statically linked bootstrap, the compiler does not have
the required startup files, so do a smaller dummy link to obtain
the output format information.

Fixes commit 87d583c6e8 ("install:
Replace scripts/output-format.sed with objdump -f [BZ #26559]").
2021-01-12 12:22:47 +01:00
Fangrui Song
87d583c6e8 install: Replace scripts/output-format.sed with objdump -f [BZ #26559]
GNU ld and gold have supported --print-output-format since 2011. glibc
requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
assume the option is supported.

lld is by default a cross linker supporting multiple targets. It auto
detects the file format and does not need OUTPUT_FORMAT. It does not
support --print-output-format.

By parsing objdump -f, we can support all the three linkers.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-01-11 12:03:36 -08:00
Paul Eggert
2b778ceb40 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
2021-01-02 12:17:34 -08:00
Alan Modra
bd7a8e038a Don't mix linker error messages into edited scripts
* Makerules (shlib.lds): Discard linker warning output.
	(format.lds): Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-08-04 19:52:56 -04:00
Florian Weimer
ce12fc7113 Remove NO_CTORS_DTORS_SECTIONS macro
This was originally added to support binutils older than version
2.22:

  <https://sourceware.org/ml/libc-alpha/2010-12/msg00051.html>

Since 2.22 is older than the minimum required binutils version
for building glibc, we no longer need this.  (The changes do
not impact the statically linked startup code.)
2020-05-18 15:39:34 +02:00
Joseph Myers
d614a75396 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
Florian Weimer
8b196ac4b8 Expand $(as-needed) and $(no-as-needed) throughout the build system
Since commit a3cc4f48e9 ("Remove
--as-needed configure test."), --as-needed support is no longer
optional.

The macros are not much shorter and do not provide documentary
value, either, so this commit removes them.
2019-12-03 21:37:50 +01:00
Paul Eggert
5a82c74822 Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 02:43:31 -07:00
Joseph Myers
04277e02d7 Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2019-01-01 00:11:28 +00:00
Andreas Schwab
c2c082c10f Remove support for abilist-pattern 2018-12-11 15:33:27 +01:00
Joseph Myers
cb7be1590e Use gen-as-const.py to process .pysym files.
This patch eliminates the gen-py-const.awk variant of gen-as-const,
switching to use of gnu-as-const.py (with a new --python option) to
process .pysym files (i.e., to generate nptl_lock_constants.py), as
the syntax of those files is identical to that of .sym files.

Note that the generated nptl_lock_constants.py is *not* identical to
the version generated by the awk script.  Apart from the trivial
changes (comment referencing the new script, and output being sorted),
the constant FUTEX_WAITERS, PTHREAD_MUTEXATTR_FLAG_BITS,
PTHREAD_MUTEXATTR_FLAG_PSHARED and PTHREAD_MUTEX_PRIO_CEILING_MASK are
now output as positive rather than negative constants (on x86_64
anyway; maybe not necessarily on 32-bit systems):

< FUTEX_WAITERS = -2147483648
---
> FUTEX_WAITERS = 2147483648

< PTHREAD_MUTEXATTR_FLAG_BITS = -251662336
< PTHREAD_MUTEXATTR_FLAG_PSHARED = -2147483648
---
> PTHREAD_MUTEXATTR_FLAG_BITS = 4043304960
> PTHREAD_MUTEXATTR_FLAG_PSHARED = 2147483648

< PTHREAD_MUTEX_PRIO_CEILING_MASK = -524288
---
> PTHREAD_MUTEX_PRIO_CEILING_MASK = 4294443008

This is because gen-as-const has a cast of the constant value to long
int, which gen-py-const lacks.

I think the positive values are more logically correct, since the
constants in question are in fact unsigned in C.  But to reliably
produce gen-as-const.py output for constants that always (in C and
Python) reflects the signedness of values with the high bit of "long
int" set would mean more complicated logic needs to be used in
computing values.

The more correct positive values by themselves produce a failure of
nptl/test-mutexattr-printers, because masking with
~PTHREAD_MUTEXATTR_FLAG_BITS & ~PTHREAD_MUTEX_NO_ELISION_NP now leaves
a bit -1 << 32 in the Python value, resulting in a KeyError exception.
To avoid that, places masking with ~ of one of the constants in
question are changed to mask with 0xffffffff as well (this reflects
how ~ in Python applies to an infinite-precision integer whereas ~ in
C does not do any promotions beyond the width of int).

Tested for x86_64.

	* scripts/gen-as-const.py (main): Handle --python option.
	* scripts/gen-py-const.awk: Remove.
	* Makerules (py-const-script): Use gen-as-const.py.
	($(py-const)): Likewise.
	* nptl/nptl-printers.py (MutexPrinter.read_status_no_robust): Mask
	with 0xffffffff together with ~(PTHREAD_MUTEX_PRIO_CEILING_MASK).
	(MutexAttributesPrinter.read_values): Mask with 0xffffffff
	together with ~PTHREAD_MUTEXATTR_FLAG_BITS and
	~PTHREAD_MUTEX_NO_ELISION_NP.
	* manual/README.pretty-printers: Update reference to
	gen-py-const.awk.
2018-12-10 22:56:59 +00:00
Joseph Myers
7e1d42400c Replace gen-as-const.awk by gen-as-const.py.
This patch replaces gen-as-const.awk, and some fragments of the
Makefile code that used it, by a Python script.  The point is not such
much that awk is problematic for this particular script, as that I'd
like to build up a general Python infrastructure for extracting
information from C headers, for use in writing tests of such headers.
Thus, although this patch does not set up such infrastructure, the
compute_c_consts function in gen-as-const.py might be moved to a
separate Python module in a subsequent patch as a starting point for
such infrastructure.

The general idea of the code is the same as in the awk version, but no
attempt is made to make the output files textually identical.  When
generating a header, a dict of constant names and values is generated
internally then defines are printed in sorted order (rather than the
order in the .sym file, which would have been used before).  When
generating a test that the values computed match those from a normal
header inclusion, the test code is made into a compilation test using
_Static_assert, where previously the comparisons were done only when
the test was executed.  One fragment of test generation (converting
the previously generated header to use asconst_* prefixes on its macro
names) is still in awk code in the makefiles; only the .sym processing
and subsequent execution of the compiler to extract constants have
moved to the Python script.

Tested for x86_64, and with build-many-glibcs.py.

	* scripts/gen-as-const.py: New file.
	* scripts/gen-as-const.awk: Remove.
	* Makerules ($(common-objpfx)%.h $(common-objpfx)%.h.d): Use
	gen-as-const.py.
	($(objpfx)test-as-const-%.c): Likewise.
2018-11-30 15:20:41 +00:00
Andreas Schwab
462d348caa Don't build libnsl for new ABIs
For architectures and ABIs that are added in version 2.29 or later the
option --enable-obsolete-nsl is no longer available, and no libnsl
compatibility library is built.
2018-09-24 10:23:10 +02:00
DJ Delorie
561b0bec44 Add test-in-container infrastructure.
* Makefile (testroot.pristine): New rules to initialize the
test-in-container "testroot".
* Makerules (all-testsuite): Add tests-container.
* Rules (tests-expected): Add tests-container.
(binaries-all-tests): Likewise.
(tests-container): New, run these tests in the testroot container.
* support/Makefile (others): Add *-container, support_paths.c,
xmkdirp, and links-dso-program.
* support/links-dso-program-c.c: New.
* support/links-dso-program.cc: New.
* support/test-container.c: New.
* support/shell-container.c: New.
* support/echo-container.c: New.
* support/true-container.c: New.
* support/xmkdirp.c: New.
* support/xsymlink.c: New.
* support/support_paths.c: New.
* support/support.h: Add support paths prototypes.
* support/xunistd.h: Add xmkdirp () and xsymlink ().

* nss/tst-nss-test3.c: Convert to test-in-container.
* nss/tst-nss-test3.root/: New.
2018-08-22 21:20:37 -04:00
Florian Weimer
124e025864 Run thread shutdown functions in an explicit order
This removes the __libc_thread_subfreeres hook in favor of explict
calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-06-26 15:27:12 +02:00
H.J. Lu
f5d1f629c6 Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792]
Glibc build generates header files to define constants from special .sym
files.  If a .sym file includes the same header file which it generates,
it leads to circular dependency which may lead to build hang on a
many-core machine.  Define GEN_AS_CONST_HEADERS when generating header
files to avoid circular dependency.

<tcb-offsets.h> is needed for i686 and it isn't needed for x86-64 at
least since glibc 2.23.

Tested on i686 and x86-64.

	[BZ #22792]
	* Makerules ($(common-objpfx)%.h): Pass -DGEN_AS_CONST_HEADERS
	to $(CC).
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h: Include
	<tcb-offsets.h> only if GEN_AS_CONST_HEADERS isn't defined.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Don't include
	<tcb-offsets.h>.
2018-02-23 11:29:39 -08:00
Palmer Dabbelt
0050553251 Allow make-link-multidir to make subdirectories
The RISC-V Linux ABI doesn't define any libraries that go directly in
lib, instead they go into lib32/ilp32 or lib64/lp64.  This casuse
make-link-multidir to fail when attempting to make library directories
when building a static libc on multilib RISC-V systems.

This patch uses scripts/mkinstalldirs to make the base directory of the
target symlink of make-link-multidir.

2018-01-06  Palmer Dabbelt  <palmer@sifive.com>

       * Makerules (make-link-multidir): Make directories before linking into
       them.
2018-01-06 23:35:46 -08:00
Joseph Myers
688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
H.J. Lu
abcb584d0e Use newly built crt*.o files to build shared objects [BZ #22362]
When multi-lib GCC is used to build glibc, the search order of GCC driver
for crt*.o is -B*/`gcc -print-multi-directory`, the installed diretory,
-B*/.  This patch adds multi-lib support to csu/Makefile so that
-B/glibc-build-directory/csu/ will pick up the newly built crt*.o.

Tested on x86-64 for i686 and x32.

	[BZ #22362]
	* Makerules (make-link-multidir): New.
	* config.make.in (multidir): New.
	* configure.ac (libc_cv_multidir): New.  AC_SUBST.
	* configure: Regenerated.
	* csu/Makefile [$(multidir) != .](multilib-extra-objs): New.
	[$(multidir) != .](extra-objs): Add $(multilib-extra-objs).
	[$(multidir) != .]($(addprefix $(objpfx)$(multidir)/, $(install-lib))):
	New target.
2017-11-06 08:29:57 -08:00
H.J. Lu
ecd0747df3 Place $(elf-objpfx)sofini.os last [BZ #22051]
Since sofini.os terminates .eh_frame section, it should be placed last.

	[BZ #22051]
	* Makerules (build-module-helper-objlist): Filter out
	$(elf-objpfx)sofini.os.
	(build-shlib-objlist): Append $(elf-objpfx)sofini.os if it is
	needed.
2017-08-31 06:28:46 -07:00
H.J. Lu
7b3ce39538 Don't compile non-lib modules as lib modules [BZ #21864]
Some programs have more than one source files.  These non-lib modules
should not be compiled with -DMODULE_NAME=libc.  This patch puts these
non-lib modules in $(others-extras) and adds $(others-extras) to
all-nonlib.

	[BZ #21864]
	* Makerules (all-nonlib): Add $(others-extras).
	* catgets/Makefile (others-extras): New.
	* elf/Makefile (others-extras): Likewise.
	* nss/Makefile (others-extras): Likewise.
2017-08-21 05:34:54 -07:00
Zack Weinberg
37f802f864 Remove __need_IOV_MAX and __need_FOPEN_MAX.
__need_FOPEN_MAX wasn't being used anywhere.  __need_IOV_MAX was more
complicated; the basic deal is that sys/uio.h wants to define a
constant named UIO_MAXIOV and bits/xopen_lim.h wants to define a
constant named IOV_MAX, with the same meaning.  For no apparent reason
this was being handled via bits/stdio_lim.h -- stdio.h is NOT supposed
to define IOV_MAX -- and some mess in Makerules.  Also, bits/uio.h on
Linux was being used as a dumping ground for extension functions.

So now we have bits/uio_lim.h, which defines __IOV_MAX.
bits/xopen_lim.h and sys/uio.h use that to define their respective
constants.  We also now have bits/uio-ext.h, which is the official
Proper Home for extensions to sys/uio.h.  bits/uio.h is removed, and
stdio_lim.h doesn't define IOV_MAX at all.

	* bits/uio_lim.h, sysdeps/unix/sysv/linux/bits/uio_lim.h
	* bits/uio-ext.h, sysdeps/unix/sysv/linux/bits/uio-ext.h: New file.
	* bits/uio.h, sysdeps/unix/sysv/linux/bits/uio.h: Delete file.

	* include/bits/xopen_lim.h: Use bits/uio_lim.h to get the value
	for IOV_MAX.
	* misc/Makefile: Install bits/uio-ext.h and bits/uio_lim.h.
	Don't install bits/uio.h.
	* misc/sys/uio.h: Don't include bits/uio.h.  Do include
	bits/types/struct_iovec.h and bits/uio_lim.h.  Set UIO_MAXIOV
	based on __IOV_MAX. Under __USE_GNU, also include bits/uio-ext.h.

	* stdio-common/stdio_lim.h.in: Remove logic for __need_FOPEN_MAX
	and __need_IOV_MAX.  Don't define IOV_MAX at all.
	* Makerules (stdio_lim.h): Remove logic for setting IOV_MAX.

	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h:
	Include bits/types/struct_iovec.h, not bits/uio.h.
	Use __ssize_t, not ssize_t, in function prototypes.
	Don't use hard TAB for double space after period in comments.
2017-06-14 07:51:30 -04:00