-- Support script for Fedora C99 port. Grab logged errors from
-- /usr/lib/gcc/errors and report them (with some post-processing).
-- List of functions which are permitted to be undeclared (because
-- we do not implement them at all).
local good = {
"CloseSocket",
"EVP_CIPHER_CTX_cleanup",
"IoctlSocket",
"MIN",
"MessageBox",
"NSLookupAndBindSymbol",
"QueryPerformanceCounter",
"QueryPerformanceFrequency",
"SSL_is_quic",
"SSL_set_quic_early_data_context",
"SSLv2_client_method",
"SetCommState",
"Sleep",
"_BitScanReverse",
"_BitScanReverse64",
"_NSGetEnviron",
"__assume",
"__builtin___bnd_chk_ptr_bounds",
"__builtin___bnd_null_ptr_bounds",
"__builtin___bnd_set_ptr_bounds",
"__builtin_available",
"__builtin_bitreverse16",
"__builtin_bitreverse32",
"__builtin_bitreverse64",
"__builtin_bitreverse8",
"__builtin_nontemporal_load",
"__builtin_nontemporal_store",
"__c11_atomic_add_fetch",
"__c11_atomic_fetch_add",
"__cpu_to_le16",
"__cpu_to_le32",
"__cpu_to_le64",
"__sync_swap",
"_alloca",
"_byteswap_uint64",
"_byteswap_ulong",
"_byteswap_ushort",
"_controlfp",
"_controlfp_s",
"_dup",
"_fdopen",
"_fileno",
"_fpclass",
"_fseeki64",
"_isatty",
"_logb",
"_mkgmtime",
"_mm_atan2_ps",
"_mm_cos_ps",
"_mm_sin_ps",
"_mulx_u32",
"_rtc",
"_scprintf",
"_snprintf",
"_spin_lock_try",
"_spin_unlock",
"_strdup",
"_syscall0",
"_wstat64",
"acl",
"acl_get_perm_np",
"alignof",
"arc4random_push",
"atomic_add_32",
"atomic_fetch_add",
"chflags",
"closesocket",
"cpu_to_le16",
"cpu_to_le32",
"cpu_to_le64",
"cpuset_create",
"cpuset_destroy",
"directio",
"drand",
"fpclass",
"fpsetmask",
"gethrtime",
"getmntinfo",
"getpass_r",
"getthrid",
"getvfsbyname",
"htonll",
"htonlll",
"iconvlist",
"inconvlist",
"ioctlsocket",
"issetugid",
"krb5_principal_get_realm",
"lchflags",
"libiconv_open",
"mach_absolute_time",
"major",
"makedev",
"malloc_get_state",
"malloc_set_state",
"mbschr",
"mbsrchr",
"memicmp",
"memset_s",
"msem_init",
"msem_lock",
"msem_unlock",
"pathfind",
"pledge",
"posix_close",
"pthread_cond_timedwait_monotonic_np",
"pthread_get_name_np", -- Variant spelling of pthread_getname_np.
"pthread_set_name_np", -- Variant spelling of pthread_setname_np.
"pthread_threadid_np",
"recallocarray",
"res_getservers",
"res_ndestroy",
"sendfilev",
"setproctitle",
"srand_deterministic",
"statacl",
"static_assert",
"strtonum",
"swapctl",
"sysctl",
"sysctlbyname",
"tcgetwinsize",
"typeof",
"unreachable",
"unw_backtrace_skip",
"utimets",
"wcstonum",
"xmlSecCryptoAppKeyLoadEx",
}
local rpm_package_name = os.getenv("RPM_PACKAGE_NAME")
local function register_package_exception(pkg, exceptions)
if pkg == rpm_package_name then
table.move(exceptions, 1, #exceptions, #good + 1, good)
end
end
-- The Linux backend does not use these LFS variants.
register_package_exception("zabbix", {"statfs64", "statvfs64"})
-- This is used for _LARGEFILE64_SOURCE probing. The implicit declaration
-- does not alter the test result. Common with TCL-related packages.
register_package_exception("environment-modules", {"stat64"})
register_package_exception("expect", {"stat64"})
register_package_exception("iaxclient", {"stat64"})
register_package_exception("itcl", {"stat64"})
register_package_exception("itk", {"stat64"})
register_package_exception("memchan", {"stat64"})
register_package_exception("tcl", {"stat64"})
register_package_exception("tcl-mysqltcl", {"stat64"})
register_package_exception("tcl-pgtcl", {"stat64"})
register_package_exception("tcl-tcludp", {"stat64"})
register_package_exception("tcl-tclvfs", {"stat64"})
register_package_exception("tcl-tclxml", {"stat64"})
register_package_exception("tcl-thread", {"stat64"})
register_package_exception("tcl-tileqt", {"stat64"})
register_package_exception("tcl-tkpng", {"stat64"})
register_package_exception("tcl-tktreectrl", {"stat64"})
register_package_exception("tcl-togl", {"stat64"})
register_package_exception("tcl-trf", {"stat64"})
register_package_exception("tcl-zlib", {"stat64"})
register_package_exception("tclx", {"stat64"})
register_package_exception("tdom", {"stat64"})
register_package_exception("tix", {"stat64"})
register_package_exception("tk", {"stat64"})
register_package_exception("tkdnd", {"stat64"})
register_package_exception("tkimg", {"stat64"})
register_package_exception("tktray", {"stat64"})
-- These curses functions are not actually implemented.
register_package_exception("perl-Curses", {"flusok", "getcap", "touchoverlap"})
-- Linux sendfile is correctly detected. The error comes from a
-- FreeBSD-specific configure check.
register_package_exception("mono", {"sendfile"})
register_package_exception("pure-ftpd", {"sendfile"})
register_package_exception("wine-mono", {"sendfile"})
-- The Fedora tor build does not use the system nacl package, so an
-- error occurs during configure probing.
register_package_exception("tor", {"crypto_scalarmult_curve25519"})
-- These are not actually implemented (the ENGINE_load_* functions are
-- not part of OpenSSL 3). They are relevant to ruby for now.
register_package_exception("ruby", {
"ENGINE_load_4758cca",
"ENGINE_load_aep",
"ENGINE_load_atalla",
"ENGINE_load_capi",
"ENGINE_load_chil",
"ENGINE_load_cswift",
"ENGINE_load_gmp",
"ENGINE_load_gost",
"ENGINE_load_nuron",
"ENGINE_load_padlock",
"ENGINE_load_sureware",
"ENGINE_load_ubsec",
"RAND_egd",
"freehostent",
"getipnodebyname",
"getpeerucred",
"t_open",
})
-- The autoconf-style logic probes incomplete header sets first, but
-- it eventually selects <sys/sysctl.h> and <unistd.h> as the headers
-- to include for these functions.
register_package_exception("pcb-rnd", {"ioctl", "gethostname"})
-- These functions are probed during the configure phase of the build.
-- _GNU_SOURCE is automatically activated as needed. The resulting
-- config.h is the same.
register_package_exception("mandoc", {
"getprogname",
"strcasestr",
"strptime",
"vasprintf",
"wcwidth",
})
-- fstatfs in <sys/vfs.h> is found, but a BSD header is probed first.
register_package_exception("mpv", {"fstatfs"})
-- The configure script uses wcwidth to probe for _GNU_SOURCE support.
-- Note that an upstream patch (773f15d53348d417fe50d52cfe49f042df4a32ad)
-- is still need to fix the build, but even with this patch, the probing
-- tickles an implicit function declaration error.
register_package_exception("nmh", {"wcwidth"})
-- This package also uses wcwidth to probe for _GNU_SOURCE support.
register_package_exception("pick", {"wcwidth"})
-- This package uses setresgid, setresuid to probe for _GNU_SOURCE support.
register_package_exception("ldns", {"setresgid", "setresuid"})
-- These functions are legimiately not implemented on GNU/Linux.
register_package_exception("bsd-games", {"fgetln", "getprogname"})
-- These are really unimplemented in current glibc (stime was
-- obsoleted/turned into a compat symbol).
register_package_exception("stress-ng", {
"faccessat2",
"getexecname",
"mquery",
"quotactl_fd",
"stime",
})
-- These functions do not exist on GNU/Linux.
register_package_exception("gtk-gnutella", {
"getprogname",
"locale_charset",
"setprogname",
})
-- There is a BSD sendfile configure-style check which is expected to fail.
register_package_exception("libowfat", {"sendfile"})
-- The statfs check is actually for statfs.f_mntfromname, which is not
-- available on GNU/Linux.
register_package_exception("dovecot", {"sendfile", "statfs"})
-- Just some functions that pgbouncer probes for, and we do not
-- actually provide.
register_package_exception("pgbouncer", {
"be16dec",
"be16enc",
"be32dec",
"be32enc",
"be64dec",
"be64enc",
"le16dec",
"le16enc",
"le32dec",
"le32enc",
"le64dec",
"le64enc",
})
-- A declaration of XmGetDestination is found in the end during
-- configure probing, so the initial failure does not matter.
register_package_exception("dx", {"XmGetDestination"})
-- Fedora does not build pcre, pcre2 with libbz2 support. The
-- configure.ac check looks correct (it uses the header file if
-- available).
register_package_exception("pcre", {"BZ2_bzopen"})
register_package_exception("pcre2", {"BZ2_bzopen"})
-- The result of the configure check appears to be unused, and the
-- check results in a linker failure anyway with OpenSSL 3.
register_package_exception("bacula", {"FIPS_mode_set"})
-- The package does not build-depend on freeglut, so the headers are
-- missing, and there is no DSO to link to, either.
register_package_exception("DevIL", {"glutMainLoop"})
-- The first two MySQL-related functions are not found even with
-- implicit function declarations supported (but both mysql_init and
-- mysql_options are found). The statfs function is mentioned in a
-- check for an Ultrix variant, and that check is expected to fail on
-- GNU/Linux.
register_package_exception("net-snmp", {
"MY_INIT",
"my_load_defaults",
"statfs"
})
-- The configure check for statfs is for OSF/1 and uses a
-- three-argument form, so it is expected to fail on GNU/Linux (with
-- or without an implicit function declaration).
register_package_exception("nordugrid-arc", {"statfs"})
-- This is just used as a test whether to link with -lrt. The outcome
-- of the test does not matter for Fedora, so suppress the failure.
-- See <https://github.com/zeromq/pyzmq/issues/1825>.
register_package_exception("python-zmq", {"timer_create"})
-- The package is already built with -Werror=implicit-function-declare,
-- even during the CMake checks, so the missing __fxstat prototype does
-- not alter the check outcome.
register_package_exception("rdma-core", {"__fxstat"})
-- There is an implicit function declaration, but it does not alter
-- the outcome of the configure check (signal is used instead).
register_package_exception("tkgate", {"sigset"})
-- fesetprec is not implemented by GCC/glibc.
register_package_exception("sympow", {"fesetprec"})
-- gconvert shows up during perl feature probing for reason. We do
-- not implement it (and apparently no one else does?).
register_package_exception("perl", {"gconvert"})
-- GNU/Linux does not implement the getprid function.
register_package_exception("calc", {"getprid"})
-- gmtime_s is not provided by glibc.
register_package_exception("fluent-bit", {"gmtime_s"})
-- The gets configure check is expected to fail. We do not implement
-- ibv_get_devices (although the check appears faulty).
register_package_exception("orangefs", {"gets", "ibv_get_devices"})
-- These functions are from obsolete versions of Berkeley DB.
register_package_exception("redland", {"dbopen", "db_open"})
-- The package uses strptime to probe whether _XOPEN_SOURCE etc. need
-- to be defined.
register_package_exception("collectd", {"strptime"})
register_package_exception("nsd", {"strptime"})
register_package_exception("opendnssec", {"strptime"})
-- libtiff has a configure check that will add #error no gl.h to the top
-- of the test snippet if the gl.h header is not found. This makes the
-- following implicit definition error not relevant, since the snippet has
-- already failed to compile.
register_package_exception("libtiff", {"glBegin", "glutMainLoop"})
-- cgnslib builds against multiple MPI implementations. Some of them
-- do not support these functions. Others do, and this is correctly
-- detected during the package build even without implicit function
-- declaration support in the compiler.
register_package_exception("cgnslib", {
"H5Pset_all_coll_metadata_ops",
"H5Pset_coll_metadata_write",
})
-- Likewise, petsc builds with multiple MPI implementations, and not
-- all of them have all features. There is a failing sysinfo test
-- which includes the wrong header, but sysinfo in general is detected
-- correctly. Discussion: <https://gitlab.com/petsc/petsc/-/issues/1290>
register_package_exception("petsc", {
"sysinfo",
"MPI_Irecv_c",
"MPI_Isend_c",
"MPI_Recv_c",
"MPI_Recv_init_c",
"MPI_Send_c",
"MPI_Send_init_c",
})
-- These functions are called during the (non-autoconf) build system
-- probing stage. They are not implemented in the libraries used,
-- and they are not detected in the baseline build, either.
register_package_exception("dhcpcd", {
"SHA256Init",
"SHA256_Init",
"consttime_memequal",
"hmac",
"strtoi",
})
-- These OpenBSD functions are not implemented on GNU/Linux.
register_package_exception("opendoas", {
"errc",
"setprogname",
"verrc",
})
-- Used in tests. There is an issue with cffi.FFI.cdef() and implicit
-- function declarations, but at least the current implementation
-- prints a very annoying warning.
register_package_exception("python-cffi", {"some_completely_unknown_function"})
-- The automake package uses the subfoo function in its testsuite.
-- Implicit declarations are expected.
register_package_exception("automake", {"subfoo"})
-- These functions are not available on GNU/Linux, but are used
-- elsewhere in Fedora, so make the exception package-specific.
register_package_exception("Coin2", {"_splitpath", "timeGetTime"})
-- The “%union name syncline“ test has a cascading error after an
-- expected compilation error in the definition of yydestruct, and
-- this triggers an implicit function declaration later on, when this
-- function is called.
register_package_exception("bison", {"yydestruct"})
-- Historic configure check that also fails at the linking stage.
register_package_exception("ncrack", {"SSLeay_add_all_algorithms"})
-- These functions are not part of GNU/Linux.
register_package_exception("tarantool", {
"pthread_attr_get_np",
"pthread_get_stackaddr_np",
"pthread_get_stacksize_np",
})
-- The configure script uses seteuid_is_broken as an #error replacement,
-- and fdwalk is not implemented on Linux.
register_package_exception("screen", {
"seteuid_is_broken",
"fdwalk",
})
-- glibc does not implement this BSD function.
register_package_exception("ocaml-lwt", {"getpeereid"})
register_package_exception("ocaml-ocamlnet", {"getpeereid"})
-- These are Hurd functions, but the check still looks incorrect:
-- CL_MACH_VM configure check will fail with future compilers
-- <https://sourceforge.net/p/clisp/bugs/749/>
-- But this problem does not concern Fedora, so adding an exception.
register_package_exception("clisp", {
"task_self",
"vm_allocate",
})
-- The configure script correctly detects that -D_GNU_SOURCE is required
-- to obtain a declaration of secure_getenv.
register_package_exception("WindowMaker", {"secure_getenv"})
-- These autoconf probes for the bunded PAM agent integration are
-- expected to fail.
register_package_exception("openssh", {
"SSLeay",
"SSLeay_add_all_algorithms",
})
-- Fedora does not provide the LibreSSL function
-- SSLeay_add_all_algorithms.
register_package_exception("opensmtpd", {"SSLeay_add_all_algorithms"})
-- These functions are not available for linking in Fedora.
register_package_exception("perl-PDL", {
"cMODl",
"cSPACEl",
"catan2l",
"infinity",
"quiet_nan",
})
-- strnstr is a BSD function that is not part of glibc.
register_package_exception("qstat", {"strnstr"})
-- Check for OSF/1-style statfs, which Fedora does not have.
register_package_exception("dc3dd", {"statfs"})
-- These functions are not available for linking in Fedora.
register_package_exception("heimdal", {
"bswap16",
"bswap32",
"bswap64",
"dbopen",
"dns_search",
"door_create",
"pidfile",
})
-- Not part of glibc or the usual libraries, so it's expected to fail
-- at link time.
register_package_exception("asterisk", {"ntohll"})
-- These functions are not implemented on Fedora.
register_package_exception("openldap", {
"UuidCreate",
"UuidToStringA",
})
-- _stat does not exist on GNU/Linux.
register_package_exception("freealut", {"_stat"})
-- setmode is not implemented on GNU/Linux.
register_package_exception("curl", {"setmode"})
-- Broken configure test, unclear how to fix. Fails also without
-- instrumentation: <https://github.com/Singular/Singular/issues/1174>
register_package_exception("Singular", {
"omBackTrace_2_RetInfo",
"omInitRet_2_Info",
})
-- statvfs is found instead (which is okay on 64-bit).
register_package_exception("rdesktop", {"statvfs64"})
-- These packages builds without X11 development libraries installed,
-- so this broken configure check is not important. (config.log is
-- unchanged.) It does not seem to trigger during regular Firefox
-- builds.
register_package_exception("mozjs78", {"XtMalloc"})
register_package_exception("mozjs91", {"XtMalloc"})
-- Use to detect the version of libqrencode. Fedora does not define
-- QRcode_encodeStringCase at all.
register_package_exception("perl-Text-QRCode", {"QRcode_encodeStringCase"})
-- These functions are not implemented by Fedora.
register_package_exception("testdisk", {
"libewf_get_bytes_per_sector",
"libewf_get_media_size",
})
-- The iconvctl function is not available on Fedora.
register_package_exception("suricata", {"iconvctl"})
-- One of the subprojects uses fseeko to probe for the right
-- _LARGEFILE_SOURCE macro definition. There are no differences in
-- the generated files with and without the instrumented compiler.
register_package_exception("x3270", {"fseeko"})
-- These functions are eventually found by the configure script, after
-- defining _GNU_SOURCE.
register_package_exception("scorep", {
"dl_iterate_phdr",
"dlmopen",
"la_objopen",
})
-- The g_chown function is not available on Fedora (anymore?).
register_package_exception("libgsf", {"g_chown"})
-- On Fedora, localtime_s is not available in the usual libraries.
register_package_exception("libexif", {"localtime_s"})
-- BIO_f_zlib is available on Fedora, but the configure check is not
-- relevant with dynamic linking. SSLeay_add_all_algorithms no longer
-- exists in current OpenSSL. aclcheck is from Solaris.
-- authenticate, loginfailed, loginsuccess are for AIX.
-- idna_to_ascii_8z is not used in Fedora builds, which are
-- libidn2-based (failure moves to linking stage). The
-- *scrambled_password* functions are not found even in builds with
-- implicit function declaration support.
register_package_exception("proftpd", {
"BIO_f_zlib",
"SSLeay_add_all_algorithms",
"aclcheck",
"authenticate",
"idna_to_ascii_8z",
"loginfailed",
"loginsuccess",
"make_scrambled_password",
"make_scrambled_password_323",
"my_make_scrambled_password",
"my_make_scrambled_password_323",
})
-- Only defined in dcmtk, which gdal does not have in its buildroot.
register_package_exception("gdal", {"jpeg12_read_scanlines"})
-- These functions are not detected even with old compilers, probably
-- due to incomplete BuildRequires:.
register_package_exception("tkimg", {
"glBegin",
"glutMainLoop",
})
-- No definition of strlwr is in the buildroot.
register_package_exception("nut", {"strlwr"})
-- Translate to associative array.
good = (function(list)
local dict = {}
for i=1, #list do
dict[list[i]] = true
end
return dict
end)(good)
-- Compute full pathnames and order by modification time.
local logdir = "/usr/lib/gcc/errors"
files = {}
for fname in assert(posix.files(logdir)) do
if string.match(fname, "^gcc") then
local fullpath = logdir .. "/" .. fname
local mtime = assert(posix.stat(fullpath)).mtime
files[#files + 1] = {fullpath, mtime}
end
end
table.sort(files, function(left, right) return left[2] < right[2] end)
-- Report errors. Filter out known-good implicit declarations.
local problem = false
for i = 1,#files do
local p = files[i][1]
for line in io.lines(p) do
local match = string.match(line, "implicit%-function%-declaration: (%g+)$")
if (not match) or not (good[match]) then
if not problem then
print("*** GCC errors begin ***\n")
end
problem = true
print(line .. "\n")
end
end
end
if problem then
print("*** GCC errors end ***\n")
end