Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 738156 - dev-libs/apr-1.7.0-r1 fails to build on gcc-10 with CFLAGS='-O2 -Wall -Wextra'
Summary: dev-libs/apr-1.7.0-r1 fails to build on gcc-10 with CFLAGS='-O2 -Wall -Wextra'
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Lars Wendler (Polynomial-C) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: werror
  Show dependency tree
 
Reported: 2020-08-20 07:55 UTC by Sergei Trofimovich (RETIRED)
Modified: 2022-06-21 15:01 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2020-08-20 07:55:39 UTC
To reproduce:

"""
# CFLAGS='-O2 -Wall -Wextra' emerge -v1 apr
...
configure: error: could not determine the string function for int64_t

!!! Please attach the following file when seeking support:
!!! /var/tmp/portage/dev-libs/apr-1.7.0-r1/work/apr-1.7.0/config.log
"""

config.log says it's due to extra -Werror during the test where unrelated warnings upset the configure test:

"""
configure:24276: checking whether int64_t and long long use fmt %lld
configure:24308: x86_64-pc-linux-gnu-gcc -c -O2 -Wall -Wextra -pthread  -Werror -DLINUX -D_REENTRANT -D_GNU_SOURCE conftest.c >&5
conftest.c: In function 'main':
conftest.c:169:29: error: initialization of 'long long int *' from incompatible pointer type 'int64_t *' {aka 'long int *'} [-Werror=incompatible-pointer-types]
  169 |     long long chk2, *ptr2 = &chk1;
      |                             ^
conftest.c:170:10: error: assignment to 'int64_t *' {aka 'long int *'} from incompatible pointer type 'long long int *' [-Werror=incompatible-pointer-types]
  170 |     ptr1 = &chk2;
      |          ^
conftest.c:172:16: error: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int64_t' {aka 'long int'} [-Werror=format=]
  172 |     printf("%lld %lld", chk1, chk2);
      |             ~~~^        ~~~~
      |                |        |
      |                |        int64_t {aka long int}
      |                long long int
      |             %ld
conftest.c:166:17: error: unused parameter 'argc' [-Werror=unused-parameter]
  166 |    int main(int argc, const char *const *argv) {
      |             ~~~~^~~~
conftest.c:166:42: error: unused parameter 'argv' [-Werror=unused-parameter]
  166 |    int main(int argc, const char *const *argv) {
      |                       ~~~~~~~~~~~~~~~~~~~^~~~
cc1: all warnings being treated as errors
configure:24308: $? = 1
"""
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2020-08-20 07:56:20 UTC
# emerge --info
Portage 3.0.2 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-10.2.0, glibc-2.31-r6, 5.8.0 x86_64)
=================================================================
System uname: Linux-5.8.0-x86_64-Intel-R-_Core-TM-_i7-2700K_CPU_@_3.50GHz-with-gentoo-2.7
KiB Mem:    31803644 total,   1500880 free
KiB Swap:          0 total,         0 free
sh bash 5.0_p18
ld GNU ld (Gentoo 2.34 p6) 2.34.0
ccache version 3.7.11 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          2.7.18-r1::gentoo, 3.6.11-r1::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo
dev-util/ccache:          3.7.11::gentoo
dev-util/cmake:           3.17.3::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.69-r5::gentoo
sys-devel/automake:       1.16.2::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            8.4.0-r1::gentoo, 10.2.0::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.8::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo
Repositories:

gentoo
    location: /bound/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts:
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes

co
    location: /co
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -fdiagnostics-show-option -frecord-gcc-switches"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/bound/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict stricter unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="ru_RU.UTF-8"
LC_ALL=""
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X acl amd64 berkdb bzip2 cli crypt dot dri fontconfig fortran gdbm iconv ipv6 jpeg libglvnd libtirpc multilib ncurses nls nptl openmp pam pcre pcre16 png readline seccomp split-usr ssl tcpd truetype unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7" RUBY_TARGETS="ruby25" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Thomas Deutschmann (RETIRED) gentoo-dev 2020-08-20 16:24:05 UTC
This is tricky, they do that on purpose:

See build/apr_common.m4 where APR_CHECK_TYPES_FMT_COMPATIBLE() is defined which will use APR_TRY_COMPILE_NO_WARNING() to set -Werror for *this* check.

I mean sure, we could patch this file but...
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2020-08-22 22:30:52 UTC
I have no preference of a specific implementation, but I have a few notes:

1. Default compiler warnings come and go. They should not break feature detection . For example Gentoo enables -Wformat warnings by default forever.  -Werror=${something-very-specific} might be ok-ish. But it is frequently a smell of very indirect way of feature detection.

2. Some toolchains always generate unrelated warnings. They will consistently break any -Werror:
  $ LANG=C avr-gcc -c a.c
  cc1: warning: '-fstack-protector' not supported for this target
  $ LANG=C avr-gcc -c a.c -Werror
  cc1: error: '-fstack-protector' not supported for this target [-Werror]
  cc1: all warnings being treated as errors

  While it's an unclean state it happens for more typical toolchains as well.

3. It's not unreasonable to allow users to enable aggressive warning like clang's -Weverything via CFLAGS to see if code has a specific problematic pattern then program does not work. Overly broad -Werror always get in the way.

I personally use '-Wall -Wextra -Wstack-protector' to find such cases of restrictive -Werror. Specifically -Wstack-protector is super noisy as it complains about many functions that were skipped for stack protection.

If you think it's not worth changing the detection mechanism upstream then there could be a few workarounds:
- filtering out '-W*' warning options in ebuilds (or pass a few -Wno- options to configure test).
- tweaking test to compile without warnings
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2020-08-23 21:30:04 UTC
It's tricky because the whole purpose of APR_TRY_COMPILE_NO_WARNING is to error out on any warning. If we would patch that function (=remove -Werror) we would break whatever upstream expects to happen here.

Looks like 'filter-flags -W*' seems to be the only option left.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2020-11-08 14:55:06 UTC
In bug #750353 macro redeclaration exposes unrelated warnings in autoconf and causes int64 detection to fail.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2020-11-25 18:50:33 UTC
Proposed related upstream as https://github.com/apache/apr/pull/25. It happens to avoid `main()` declaration warnings for me.
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-15 08:01:38 UTC
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7fe608c5ea9b01ae313c87348f6e2bcd8a8286cf is good enough workaround to make it compile for now.
Comment 8 dan 2022-06-21 14:20:01 UTC
We were seeing the `configure: error: could not determine the string function for int64_t` error when trying to build apr on Ubuntu 22.04.

Applying this patch not only did not make that error go away on Ubuntu 22.04 it caused it to happen on Cent 6, Cent 7, Alma 8, and Ubuntu 20.04.

So there must be another element in play :/
Comment 9 dan 2022-06-21 15:01:28 UTC
(In reply to dan from comment #8)
> We were seeing the `configure: error: could not determine the string
> function for int64_t` error when trying to build apr on Ubuntu 22.04.
> 
> Applying this patch not only did not make that error go away on Ubuntu 22.04
> it caused it to happen on Cent 6, Cent 7, Alma 8, and Ubuntu 20.04.
> 
> So there must be another element in play :/

Apologies, there was another element involved, PEBCAK :) It totally fixes it