Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 861857 - net-proxy/dante-1.4.1-r6 fails to compile (lto): sockd.c:1234:27: error: type of module_redirect_keyv does not match original declaration [-Werror=lto-type-mismatch]
Summary: net-proxy/dante-1.4.1-r6 fails to compile (lto): sockd.c:1234:27: error: type...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Robin Johnson
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-07-29 07:12 UTC by Agostino Sarubbo
Modified: 2024-12-07 00:02 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: Yes


Attachments
build.log (build.log,349.01 KB, text/plain)
2022-07-29 07:12 UTC, Agostino Sarubbo
Details
Proposed fix for dante-1.4.3 lto type mismatch (dante-1.4.3-lto-type-mismatch.patch,799 bytes, patch)
2024-12-07 00:02 UTC, Yuri Sevatz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-07-29 07:12:53 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: net-proxy/dante-1.4.1-r6 fails to compile (lto).
Discovered on: amd64 (internal ref: lto_tinderbox)

NOTE:
This machine uses lto with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Here is a bit of explanation:

-Werror=lto-type-mismatch:
User to find possible runtime issues in packages. It likely means the package is unsafe to build & use with LTO.
For projects using the same identifier but with different types across different files, they must be fixed to be consistent across the codebase.

-Werror=odr:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO. C++ code must comply with the One Definition Rule (ODR) - see https://en.cppreference.com/w/cpp/language/definition#One_Definition_Rule.

-Werror=strict-aliasing:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO.

Workarounds:
- If upstream is friendly and still active, file a bug upstream. For emulators, codecs, games, or multimedia packages, it may be worth just applying a workaround instead, as upstreams sometimes aren't receptive to these bugs (VALID FOR ALL).
- Use the new 'filter-lto' from flag-o-matic.eclass as it's likely to be unsafe with LTO (VALID FOR lto-type-mismatch - odr).
- Fix it yourself if interested, of course (VALID FOR ALL).
- Append-flags -fno-strict-aliasing (VALID FOR strict-aliasing).
- Use memcpy() but a union is sometimes suitable too (VALID FOR strict-aliasing).
- -fstrict-aliasing is implied by -O2, so this must be addressed in some form (VALID FOR strict-aliasing).

See also: https://marc.info/?l=gentoo-dev&m=165639574126280&w=2
Comment 1 Agostino Sarubbo gentoo-dev 2022-07-29 07:12:55 UTC
Created attachment 795377 [details]
build.log

build log and emerge --info
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2024-11-18 04:11:07 UTC
Please retest against dante-1.4.3 due to major changes upstream & in the patch-set.
Comment 3 Eli Schwartz gentoo-dev 2024-11-18 06:06:39 UTC
There were originally 3 different instances of the lto-type-mismatch error. And 1 of them has gone away, but the other 2 remain:



libtool: link: x86_64-pc-linux-gnu-gcc -DSOCKS_SERVER=1 -DSOCKS_CLIENT=0 -DSOCKSLIBRARY_DYNAMIC=1 -DSTANDALONE_UNIT_TEST=0 -pipe -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -g -O2 -ggdb -pipe -Wl,-O1 -Wl,-z -Wl,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o sockd addressmatch.o authneg.o broken.o clientprotocol.o config.o config_parse.o config_scan.o debug.o errorsymbols.o fmt.o fmt_customer.o fmt_protocol.o gssapi.o hostcache.o hostid.o httpproxy.o hw.o iface.o io.o iobuf.o ipv6.o krb5.o log.o method.o parse_util.o protocol.o serr.o showconfig.o sockaddr.o socket.o socketopt.o sockopt.o tcpinfo.o time.o tostring.o udp_util.o upnp.o userio.o util.o in_cksum.o accesscheck.o auth_bsd.o auth_pam.o auth_password.o bandwidth.o bandwidth_key.o checkmodule.o cpu.o cpuaffinity.o cpupolicy.o dante_udp.o fmt_sockd.o getoutaddr.o ldap.o ldap_key.o ldap_util.o math.o method_gssapi.o method_uname.o monitor.o monitor_util.o mother_util.o pac.o pac_key.o privileges.o redirect.o redirect_key.o rule.o serverconfig.o session.o shmem.o shmemconfig.o sockd.o sockd_child.o sockd_icmp.o sockd_io.o sockd_io_misc.o sockd_negotiate.o sockd_protocol.o sockd_request.o sockd_socket.o sockd_tcp.o sockd_udp.o sockd_util.o statistics.o udp_port.o interposition.o setproctitle.o strvis.o  -Wl,--as-needed -lm -lpam -lcrypt
sockd.c:1261:27: error: type of 'module_redirect_keyv' does not match original declaration [-Werror=lto-type-mismatch]
 1261 | extern const licensekey_t module_redirect_keyv[];
      |                           ^
redirect_key.c:13:21: note: 'module_redirect_keyv' was previously declared here
   13 | const licensekey_t *module_redirect_keyv = NULL;
      |                     ^
redirect_key.c:13:21: note: code may be misoptimized unless '-fno-strict-aliasing' is used
sockd.c:1265:27: error: type of 'module_bandwidth_keyv' does not match original declaration [-Werror=lto-type-mismatch]
 1265 | extern const licensekey_t module_bandwidth_keyv[];
      |                           ^
bandwidth_key.c:13:21: note: 'module_bandwidth_keyv' was previously declared here
   13 | const licensekey_t *module_bandwidth_keyv = NULL;
      |                     ^
bandwidth_key.c:13:21: note: code may be misoptimized unless '-fno-strict-aliasing' is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:578: sockd] Error 1
Comment 4 Yuri Sevatz 2024-12-07 00:02:44 UTC
Created attachment 913483 [details, diff]
Proposed fix for dante-1.4.3 lto type mismatch

Managed to create a patch for dante-1.4.3 while attempting my first "system-wide LTO".

Tested with: CFLAGS += "-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing".

Bug was pretty simple, they were referencing an extern array in one translation unit, and declaring a pointer in the other.  2 instance of this appear by default, and 3rd appears to be possible if you compile with LDAP enabled, which I fix in the patch too.