mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-14 01:00:07 +00:00
9aa4965cdf
This patch makes the glibc build generate an additional header ldbl-compat-choose.h that defines LONG_DOUBLE_COMPAT_CHOOSE_* macros for each libc and libm symbol, which select one or the other of their arguments based on whether the symbol was added before a change to long double != double. The effect of this is that it is then possible to define a macro maybe_long_double_symbol that automatically acts as either long_double_symbol or weak_alias depending on when the symbol being defined was added. This can be used when building long double functions from type-generic templates. Thus, with this patch ldbl-opt no longer needs special long double implementations of each new libm function added using such a template, and the existing such implementations are removed. This is a step towards being able more generally to use common macros to create all the aliases needed for a libm function, so reducing the amount of special-case code needed in ldbl-opt and ldbl-64-128, and facilitating subsequently adding *f32 / *f64 / *f128 / *f32x / *f64x aliases to existing functions (where the set of aliases that a function should have may depend on the architecture in various ways). Tested with build-many-glibcs.py. Except for on powerpc64le-linux-gnu, installed stripped shared libraries are unchanged by the patch. powerpc64le-linux-gnu is the unique configuration which used ldbl-opt from the start rather than adding a new long double choice after originally only having had long double = double. The effect of the patch there is that various cases that previously used long_double_symbol unconditionally now use weak_alias instead, so .os files contain e.g. a symbol cabsl instead of cabsl@@GLIBC_2.17. The final dynamic symbols and versions in the resulting shared libraries are unchanged (ABI tests pass), as is the disassembly of the shared libraries, but the differences in the .os files still result in different .gnu_hash contents in libm.so; the differences are of no significance and logically using weak_alias is what's most appropriate in those cases. * scripts/versions.awk: Generate ldbl-compat-choose.h. * sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Include <ldbl-compat-choose.h>. (maybe_long_double_symbol): New macro. [!declare_mgen_alias] (declare_mgen_alias): Use maybe_long_double_symbol. * sysdeps/ieee754/ldbl-opt/s_canonicalizel.c: Remove. * sysdeps/ieee754/ldbl-opt/s_fmaxmagl.c: Likewise. * sysdeps/ieee754/ldbl-opt/s_fminmagl.c: Likewise. * sysdeps/ieee754/ldbl-opt/s_nextdownl.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_llogbl.c: Likewise. * Makerules [$(build-shared) = yes && !avoid-generated] (before-compile): Add $(common-objpfx)ldbl-compat-choose.h. [$(build-shared) = yes && !avoid-generated] ($(common-objpfx)ldbl-compat-choose.h): New target.
174 lines
5.0 KiB
Awk
174 lines
5.0 KiB
Awk
# Combine version map fragments into version scripts for our shared objects.
|
|
# Copyright (C) 1998-2017 Free Software Foundation, Inc.
|
|
# Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
|
|
# This script expects the following variables to be defined:
|
|
# defsfile name of Versions.def file
|
|
# buildroot name of build directory with trailing slash
|
|
# move_if_change move-if-change command
|
|
|
|
# Read definitions for the versions.
|
|
BEGIN {
|
|
lossage = 0;
|
|
|
|
nlibs=0;
|
|
while (getline < defsfile) {
|
|
if (/^[a-zA-Z0-9_.]+ \{/) {
|
|
libs[$1] = 1;
|
|
curlib = $1;
|
|
while (getline < defsfile && ! /^}/) {
|
|
if ($2 == "=") {
|
|
renamed[curlib "::" $1] = $3;
|
|
}
|
|
else
|
|
versions[curlib "::" $1] = 1;
|
|
}
|
|
}
|
|
}
|
|
close(defsfile);
|
|
|
|
tmpfile = buildroot "Versions.tmp";
|
|
# POSIX sort needed.
|
|
sort = "sort -t. -k 1,1 -k 2n,2n -k 3 > " tmpfile;
|
|
}
|
|
|
|
# Remove comment lines.
|
|
/^ *#/ {
|
|
next;
|
|
}
|
|
|
|
# This matches the beginning of the version information for a new library.
|
|
/^[a-zA-Z0-9_.]+/ {
|
|
actlib = $1;
|
|
if (!libs[$1]) {
|
|
printf("no versions defined for %s\n", $1) > "/dev/stderr";
|
|
++lossage;
|
|
}
|
|
next;
|
|
}
|
|
|
|
# This matches the beginning of a new version for the current library.
|
|
/^ [A-Za-z_]/ {
|
|
if (renamed[actlib "::" $1])
|
|
actver = renamed[actlib "::" $1];
|
|
else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") {
|
|
printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr";
|
|
++lossage;
|
|
}
|
|
else
|
|
actver = $1;
|
|
next;
|
|
}
|
|
|
|
# This matches lines with names to be added to the current version in the
|
|
# current library. This is the only place where we print something to
|
|
# the intermediate file.
|
|
/^ / {
|
|
sortver=actver
|
|
# Ensure GLIBC_ versions come always first
|
|
sub(/^GLIBC_/," GLIBC_",sortver)
|
|
printf("%s %s %s\n", actlib, sortver, $0) | sort;
|
|
}
|
|
|
|
|
|
function closeversion(name, oldname) {
|
|
if (firstinfile) {
|
|
printf(" local:\n *;\n") > outfile;
|
|
firstinfile = 0;
|
|
}
|
|
# This version inherits from the last one only if they
|
|
# have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z
|
|
# or FOO_x and FOO_y but not GLIBC_x and FOO_y.
|
|
pfx = oldname;
|
|
sub(/[0-9.]+/,".+",pfx);
|
|
if (oldname == "" || name !~ pfx) print "};" > outfile;
|
|
else printf("} %s;\n", oldname) > outfile;
|
|
}
|
|
|
|
function close_and_move(name, real_name) {
|
|
close(name);
|
|
system(move_if_change " " name " " real_name " >&2");
|
|
}
|
|
|
|
# Now print the accumulated information.
|
|
END {
|
|
close(sort);
|
|
|
|
if (lossage) {
|
|
system("rm -f " tmpfile);
|
|
exit 1;
|
|
}
|
|
|
|
oldlib = "";
|
|
oldver = "";
|
|
real_first_ver_header = buildroot "first-versions.h"
|
|
first_ver_header = real_first_ver_header "T"
|
|
printf("#ifndef _FIRST_VERSIONS_H\n") > first_ver_header;
|
|
printf("#define _FIRST_VERSIONS_H\n") > first_ver_header;
|
|
real_ldbl_compat_header = buildroot "ldbl-compat-choose.h"
|
|
ldbl_compat_header = real_ldbl_compat_header "T"
|
|
printf("#ifndef _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header;
|
|
printf("#define _LDBL_COMPAT_CHOOSE_H\n") > ldbl_compat_header;
|
|
printf("#ifndef LONG_DOUBLE_COMPAT\n") > ldbl_compat_header;
|
|
printf("# error LONG_DOUBLE_COMPAT not defined\n") > ldbl_compat_header;
|
|
printf("#endif\n") > ldbl_compat_header;
|
|
printf("version-maps =");
|
|
while (getline < tmpfile) {
|
|
if ($1 != oldlib) {
|
|
if (oldlib != "") {
|
|
closeversion(oldver, veryoldver);
|
|
oldver = "";
|
|
close_and_move(outfile, real_outfile);
|
|
}
|
|
oldlib = $1;
|
|
real_outfile = buildroot oldlib ".map";
|
|
outfile = real_outfile "T";
|
|
firstinfile = 1;
|
|
veryoldver = "";
|
|
printf(" %s.map", oldlib);
|
|
}
|
|
if ($2 != oldver) {
|
|
if (oldver != "") {
|
|
closeversion(oldver, veryoldver);
|
|
veryoldver = oldver;
|
|
}
|
|
printf("%s {\n global:\n", $2) > outfile;
|
|
oldver = $2;
|
|
}
|
|
printf(" ") > outfile;
|
|
for (n = 3; n <= NF; ++n) {
|
|
printf(" %s", $n) > outfile;
|
|
sym = $n;
|
|
sub(";", "", sym);
|
|
first_ver_macro = "FIRST_VERSION_" oldlib "_" sym;
|
|
if (!(first_ver_macro in first_ver_seen) \
|
|
&& oldver ~ "^GLIBC_[0-9]" \
|
|
&& sym ~ "^[A-Za-z0-9_]*$") {
|
|
ver_val = oldver;
|
|
gsub("\\.", "_", ver_val);
|
|
printf("#define %s %s\n", first_ver_macro, ver_val) > first_ver_header;
|
|
first_ver_seen[first_ver_macro] = 1;
|
|
if (oldlib == "libc" || oldlib == "libm") {
|
|
printf("#if LONG_DOUBLE_COMPAT (%s, %s)\n",
|
|
oldlib, ver_val) > ldbl_compat_header;
|
|
printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) a\n",
|
|
oldlib, sym) > ldbl_compat_header;
|
|
printf("#else\n") > ldbl_compat_header;
|
|
printf("# define LONG_DOUBLE_COMPAT_CHOOSE_%s_%s(a, b) b\n",
|
|
oldlib, sym) > ldbl_compat_header;
|
|
printf("#endif\n") > ldbl_compat_header;
|
|
}
|
|
}
|
|
}
|
|
printf("\n") > outfile;
|
|
}
|
|
printf("\n");
|
|
printf("#endif /* first-versions.h */\n") > first_ver_header;
|
|
printf("#endif /* ldbl-compat-choose.h */\n") > ldbl_compat_header;
|
|
closeversion(oldver, veryoldver);
|
|
close_and_move(outfile, real_outfile);
|
|
close_and_move(first_ver_header, real_first_ver_header);
|
|
close_and_move(ldbl_compat_header, real_ldbl_compat_header);
|
|
#system("rm -f " tmpfile);
|
|
}
|