Commit Graph

33378 Commits

Author SHA1 Message Date
Fangrui Song
a21d58a0dc x86_64: Remove unneeded static PIE check for undefined weak diagnostic
https://sourceware.org/bugzilla/show_bug.cgi?id=21782 dropped an ld
diagnostic for R_X86_64_PC32 referencing an undefined weak symbol in
-pie links.  Arguably keeping the diagnostic like other ports is more
correct, since statically resolving movl foo(%rip), %eax to the
link-time zero address produces a corrupted output.

It turns out that --enable-static-pie builds do not depend on the ld
behavior. GCC generates GOT indirection for weak declarations for
-fPIE/-fPIC, so what ld does with the PC-relative relocation doesn't
really matter.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2021-08-27 17:26:06 -07:00
Wilco Dijkstra
2d20ffe431 [PATCH 7/7] sin/cos slow paths: refactor sincos implementation
Refactor the sincos implementation - rather than rely on odd partial inlining
of preprocessed portions from sin and cos, explicitly write out the cases.
This makes sincos much easier to maintain and provides an additional 16-20%
speedup between 0 and 2^27.  The overall speedup of sincos is 48% over this range.
Between 0 and PI it is 66% faster.

	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Cleanup ifdefs.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sincos): Refactor using the same
	logic as sin and cos.
2021-08-27 17:26:06 -07:00
Wilco Dijkstra
c8aaaf67f6 [PATCH 6/7] sin/cos slow paths: refactor duplicated code into dosin
Refactor duplicated code into do_sin.  Since all calls to do_sin use copysign to
set the sign of the result, move it inside do_sin.  Small inputs use a separate
polynomial, so move this into do_sin as well (the check is based on the more
conservative case when doing large range reduction, but could be relaxed).

	* sysdeps/ieee754/dbl-64/s_sin.c (do_sin): Use TAYLOR_SIN for small
	inputs.  Return correct sign.
	(do_sincos): Remove small input check before do_sin, let do_sin set
	the sign.
	(__sin): Likewise.
	(__cos): Likewise.
2021-08-27 17:26:06 -07:00
Wilco Dijkstra
c015f0cc57 [PATCH 5/7] sin/cos slow paths: remove unused slowpath functions
Remove all unused slowpath functions.

	* sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SLOW): Remove.
	(do_cos_slow): Likewise.
	(do_sin_slow): Likewise.
	(reduce_and_compute): Likewise.
	(slow): Likewise.
	(slow1): Likewise.
	(slow2): Likewise.
	(sloww): Likewise.
	(sloww1): Likewise.
	(sloww2): Likewise.
	(bslow): Likewise.
	(bslow1): Likewise.
	(bslow2): Likewise.
	(cslow2): Likewise.
2021-08-27 17:26:06 -07:00
Wilco Dijkstra
d4d26acd8a [PATCH 4/7] sin/cos slow paths: remove slow paths from huge range reduction
For huge inputs use the improved do_sincos function as well.  Now no cases use
the correction factor returned by do_sin, do_cos and TAYLOR_SIN, so remove it.

	* sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SIN): Remove cor parameter.
	(do_cos): Remove corp parameter and calculations.
	(do_sin): Likewise.
	(do_sincos): Remove cor variable.
	(__sin): Use do_sincos for huge inputs.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
	(reduce_and_compute_sincos): Remove unused function.
2021-08-27 17:26:05 -07:00
Wilco Dijkstra
76f9784421 [PATCH 3/7] sin/cos slow paths: remove slow paths from small range reduction
This patch improves the accuracy of the range reduction.  When the input is
large (2^27) and very close to a multiple of PI/2, using 110 bits of PI is not
enough.  Improve range reduction accuracy to 136 bits.  As a result the special
checks for results close to zero can be removed.  The ULP of the polynomials is
at worst 0.55ULP, so there is no reason for the slow functions, and they can be
removed.

	* sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_1): Rename to
	reduce_sincos, improve accuracy to 136 bits.
	(do_sincos_1): Rename to do_sincos, remove fallbacks to slow functions.
	(__sin): Use improved reduction and simplified do_sincos calculation.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
2021-08-27 17:26:05 -07:00
Wilco Dijkstra
e525ff25df [PATCH 2/7] sin/cos slow paths: remove large range reduction
This patch removes the large range reduction code and defers to the huge range
reduction code.  The first level range reducer supports inputs up to 2^27,
which is way too large given that inputs for sin/cos are typically small
(< 10), and optimizing for a smaller range would give a significant speedup.

Input values above 2^27 are practically never used, so there is no reason for
supporting range reduction between 2^27 and 2^48.  Removing it significantly
simplifies code and enables further speedups.  There is about a 2.3x slowdown
in this range due to __branred being extremely slow  (a better algorithm could
easily more than double performance).

	* sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_2): Remove function.
	(do_sincos_2): Likewise.
	(__sin): Remove middle range reduction case.
	(__cos): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Remove middle range
	reduction case.
2021-08-27 17:26:05 -07:00
Wilco Dijkstra
bc57e68bbb [PATCH 1/7] sin/cos slow paths: avoid slow paths for small inputs
This series of patches removes the slow patchs from sin, cos and sincos.
Besides greatly simplifying the implementation, the new version is also much
faster for inputs up to PI (41% faster) and for large inputs needing range
reduction (27% faster).

ULP is ~0.55 with no errors found after testing 1.6 billion inputs across most
of the range with mpsin and mpcos.  The number of incorrectly rounded results
(ie. ULP >0.5) is at most ~2750 per million inputs between 0.125 and 0.5,
the average is ~850 per million between 0 and PI.

Tested on AArch64 and x86_64 with no regressions.

The first patch removes the slow paths for the cases where the input is small
and doesn't require range reduction.  Update ULP tables for sin, cos and sincos
on AArch64 and x86_64.

	* sysdeps/aarch64/libm-test-ulps: Update ULP for sin, cos, sincos.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove slow paths for small
	inputs.
	(__cos): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sin, cos, sincos.
2021-08-27 17:26:05 -07:00
Lirong Yuan
5e46b24985 locale: Align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32
Otherwise, programs that use character classification macros such as
isspace may observe unaligned pointers.
2021-08-27 17:26:05 -07:00
Nick Lewycky
0ed6ae04d6 Change this offsetof computation to use c89 offsetof. Tested: 2021-08-27 17:26:05 -07:00
Stan Shebs
bd1e10723b Update build process to create libnsl stub 2021-08-27 17:26:05 -07:00
Paul Pluzhnikov
87ac253d00 Forward-port google-nsl-stub 2021-08-27 17:26:04 -07:00
James Y Knight
04938f76dd Fix memory leak in TLS allocation 2021-08-27 17:26:04 -07:00
Stan Shebs
bcc638805a Add a test of TLS support that will fail if leaky 2021-08-27 17:26:04 -07:00
Stan Shebs
d548adb4ef Let time and gettimeofday use vdso by removing old clang workaround 2021-08-27 17:26:04 -07:00
Stan Shebs
e62db8fce4 Use crt*.o files from llvm compiler-rt when building with clang 2021-08-27 17:26:04 -07:00
Stan Shebs
2c9e5207e4 Do not use ppc-specific long double pack/unpack when compiling with clang 2021-08-27 17:26:04 -07:00
Stan Shebs
c3064d5f50 Remove old workaround in power7 logb functions, clang no longer crashes on the inline assembly 2021-08-27 17:26:04 -07:00
Josh Kunz
cb90884046 Additional fixes for llvm-as
Unlike GCC, llvm always uses an integrated assembler, which attempts to
recognized all `asm` statements written in the C code. glibc uses some
syntactically invalid asm statements to emit constants into assembly that
are later extracted with a sed or AWK script.

This change fixes two such invalid `asm` statements by wrapping the
output in a `.ascii` directive.. This does not break the sed/AWK (the same
special sequence is output) but it makes the statement syntactically valid.

See cf8e3f8757 for a previous fix for the same issue.
2021-08-27 17:26:04 -07:00
Stan Shebs
144448d566 Add workaround for infinite looping in ppc vsyscall for sched_getcpu. 2021-08-27 17:26:03 -07:00
Stan Shebs
1ba3eb044d Add -Wno-incomplete-setjmp-declaration to prevent clang from unhelpfully complaining about __sigsetjmp, both in library build and testsuite runs. 2021-08-27 17:26:03 -07:00
Stan Shebs
86079708ee Update passwd.borg handling to use passwd.borg.real 2021-08-27 17:26:03 -07:00
Stan Shebs
d0d7b3d2b3 Add a case to async-signal-safe TLS to set static TLS instead of waiting for a dlopen that may not actually be happening. 2021-08-27 17:26:03 -07:00
Stan Shebs
6a12504329 Add an LD_DEBUG=tls option to help debug thread-local storage handling in ld.so 2021-08-27 17:26:03 -07:00
Stan Shebs
396a77d48e Remove an unneeded local refactor in _dl_update_slotinfo 2021-08-27 17:26:03 -07:00
Joseph Myers
7d7724e795 Fix year 2039 bug for localtime with 64-bit time_t (bug 22639).
Bug 22639 reports localtime failing to handle time offset transitions
correctly in 2039 and later on platforms with 64-bit time_t.

The problem is the use of SECSPERDAY (constant 86400) in calculations
such as

    t = ((year - 1970) * 365
	 + /* Compute the number of leapdays between 1970 and YEAR
	      (exclusive).  There is a leapday every 4th year ...  */
	 + ((year - 1) / 4 - 1970 / 4)
	 /* ... except every 100th year ... */
	 - ((year - 1) / 100 - 1970 / 100)
	 /* ... but still every 400th year.  */
	 + ((year - 1) / 400 - 1970 / 400)) * SECSPERDAY;

where t is of type time_t and year is of type int.  Before my commit
92bd70fb85 (an update from tzcode,
included in 2.26 and later releases), SECSPERDAY was obtained from a
file imported from tzcode, where the value included a cast to
int_fast32_t.  On 64-bit platforms, glibc defines int_fast32_t to be
long int, so 64-bit, but my patch resulted in it changing to int.
(The bug would probably have existed even before my patch for x32,
which has 64-bit time_t but 32-bit int_fast32_t, but I haven't
verified that.)

This patch fixes the problem by including a cast to time_t in the
definition of SECSPERDAY.  (64-bit time support for 32-bit systems
should move such code that isn't a public interface to using the
internal 64-bit version of time_t throughout.)

Tested for x86_64 and x86.

	[BZ #22639]
	* time/tzset.c (SECSPERDAY): Cast to time_t.
	* time/tst-y2039.c: New file.
	* time/Makefile (tests): Add tst-y2039.
2021-08-27 17:26:03 -07:00
Stan Shebs
3a84f426fd Reduce __MAX_ALLOCA_CUTOFF to 8192 2021-08-27 17:26:02 -07:00
Stan Shebs
c4d57c29b5 Make multi-arch ifunc support work with clang 2021-08-27 17:26:02 -07:00
Stan Shebs
66c8103bdf Revert clang workaround for _begin that is no longer needed 2021-08-27 17:26:02 -07:00
Ambrose Feinstein
af63681769 Redesign the fastload support for additional performance 2021-08-27 17:26:02 -07:00
Josh Kunz
6733782381 Add comments explaining the diff from cf8e3f8757
These comments should make it easier to see the (small) diff introduced
in cf8e3f8757. Without these comments, the diff may get list on a future
upstream merge.
2021-08-27 17:26:02 -07:00
Josh Kunz
ad41eacfb7 Make gen-XX-const scripts work with llvm-as
The gen-as-const and gen-py-const scripts are used to generate integer constant
definitions from a list of constant C-expressions. This is achieved by
generating a C program with inline `asm` statements, that depend on
these constant expressions. During compilation, the constant expressions
are evaluated, and included in the inline asm. The build process
generates only the assembly, and then used `sed` to extract the values
from the assembly text.

This is clever. It allows the build process to extract the value of C
statements built under the target architecture. The implementation is a
bit fragile, but it is not immediately obvious to me how it could be
improved.

This change slightly modifies `gen-as-const` and `gen-py-const` to emit
valid assembly directives instead of invalid directives that were
previously emitted. Since the values are extracted via string parsing,
this has no effect on the values extracted. This is needed because the
LLVM assembler validates all statements before emitting them, whereas it
appears GCC will literally emit any `asm` directives without validation
or recognition.
2021-08-27 17:26:02 -07:00
Stan Shebs
8d141ab782 Fix sense of a test in the static-linking version of ppc get_clockfreq 2021-08-27 17:26:02 -07:00
Shu-Chun Weng
e1c6d2b0f4 Makes it compile for AArch64
De-nesting fix in 83c02e85 changed function signature but AArch64 was untested.
2021-08-27 17:26:01 -07:00
Shu-Chun Weng
83bede0cfc Makes AArch64 assembly acceptable to clang
According to ARMv8 architecture reference manual section C7.2.188, SIMD MOV (to
general) instruction format is

  MOV <Xd>, <Vn>.D[<index>]

gas appears to accept "<Vn>.2D[<index>]" as well, but clang's assembler does
not. C.f. https://community.arm.com/developer/ip-products/processors/f/cortex-a-forum/5214/aarch64-assembly-syntax-for-armclang
2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
038be62f96 Include STATIC_PIE_BOOTSTRAP with !NESTING in powerpc64/dl-machine.h 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
6676d4161d Actuall use LLVM_OBJCOPY if available. 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
059f0081cf Use llvm-objcopy, if available, to remove the .llvm_addrsig sections. 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
738baca865 Enable relaxed relocations when building certain object files for x86_64. 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
0337af1396 Un-nest an include in dl-reloc-static-pie.c.
A corresponding adjustment in sysdeps/x86_64/dl-machine.h has also been
made.
2021-08-27 17:26:01 -07:00
Stan Shebs
43afb70033 Disable -mfloat128 for clang, lets power9 insns into power8 executables 2021-08-27 17:26:00 -07:00
Stan Shebs
895947a3ca Also work around clang bctrl issue in get_clockfreq.c 2021-08-27 17:26:00 -07:00
Zack Weinberg
b930ad424b [BZ #19239] Don't include sys/sysmacros.h from sys/types.h.
This completes the deprecation and removal of this inclusion, which
was begun in the 2.25 release.

	* posix/sys/types.h: Don't include sys/sysmacros.h.
	* misc/sys/sysmacros.h: Remove the conditional deprecation
	warnings for the macros defined by this header.
2021-08-27 17:26:00 -07:00
Stan Shebs
c4c787ff1b Remove .llvm_addrsig sections from crt.o files 2021-08-27 17:26:00 -07:00
Brooks Moses
b1ecb7cf85 Forward-port cl/42676407 to disable link-time warning about mktemp, tempnam and tmpnam. 2021-08-27 17:23:15 -07:00
Raman Tenneti
9e8081d123 Changes to compile glibc-2.27 on PPC (Power8) with clang.
+ Use DOT_MACHINE macro instead of ".machine" instruction.
+ Use __isinf and __isinff instead of builtin versions.
+ In s_logb, s_logbf and s_logbl functions, used float versions to
  calculate "ret = x & 0x7f800000;" expression.
2021-08-27 17:23:15 -07:00
Stan Shebs
91da896a3e Add a note about passwd.borg.base organization 2021-08-27 17:23:15 -07:00
Stan Shebs
c51bab1714 Fix mistaken order of arguments to open_path 2021-08-27 17:23:15 -07:00
Stan Shebs
b2d0b20ae6 Update build notes 2021-08-27 17:23:15 -07:00
Raman Tenneti
bb9e16c6ea Undid the dl_enable_fastload environment variable changes. 2021-08-27 17:23:15 -07:00