Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 603626

Summary: sys-libs/musl: musl and gcc do not agree on size_t and wchar_t
Product: Gentoo Linux Reporter: Richard Yao (RETIRED) <ryao>
Component: Current packagesAssignee: Anthony Basile <blueness>
Status: RESOLVED FIXED    
Severity: normal CC: herrtimson, rini17, tsmksubc
Priority: Normal Keywords: Bug
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 430702    
Attachments: dev-util/strace-4.13 build.log of failure

Description Richard Yao (RETIRED) gentoo-dev 2016-12-24 01:07:26 UTC
Building dev-util/strace-4.13 (any version really) will fail saying:

In file included from ./defs.h:42:0,
                 from mpers-m32/struct_blk_user_trace_setup.c:29:
/usr/lib/gcc/x86_64-gentoo-linux-musl/4.9.4/include/stddef.h:212:23: error: conflicting types for 'size_t'
 typedef __SIZE_TYPE__ size_t;
                       ^
In file included from /usr/include/sys/types.h:57:0,
                 from ./defs.h:40,
                 from mpers-m32/struct_blk_user_trace_setup.c:29:
/usr/include/bits/alltypes.h:101:24: note: previous declaration of 'size_t' was here
 typedef unsigned _Addr size_t;
                        ^
In file included from ./defs.h:42:0,
                 from mpers-m32/struct_blk_user_trace_setup.c:29:
/usr/lib/gcc/x86_64-gentoo-linux-musl/4.9.4/include/stddef.h:324:24: error: conflicting types for 'wchar_t'
 typedef __WCHAR_TYPE__ wchar_t;
                        ^
In file included from /usr/include/inttypes.h:12:0,
                 from ./defs.h:39,
                 from mpers-m32/struct_blk_user_trace_setup.c:29:
/usr/include/bits/alltypes.h:18:13: note: previous declaration of 'wchar_t' was here
 typedef int wchar_t;
             ^
Comment 1 Richard Yao (RETIRED) gentoo-dev 2016-12-24 01:09:25 UTC
Just to add to this, commenting out the offending lines in GCC's stddef.h lets strace build.
Comment 2 Richard Yao (RETIRED) gentoo-dev 2016-12-24 01:11:32 UTC
Created attachment 457304 [details]
dev-util/strace-4.13 build.log of failure

Just for completeness:

# emerge --info
Portage 2.3.1 (python 2.7.12-final-0, hardened/linux/musl/amd64, gcc-4.9.4, musl-1.1.15-r2, 3.18.25-std470-amd64 x86_64)
=================================================================
System uname: Linux-3.18.25-std470-amd64-x86_64-Intel-R-_Xeon-R-_CPU_E5-1620_0_@_3.60GHz-with-gentoo-2.2
KiB Mem:    65942224 total,  49255280 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Fri, 23 Dec 2016 00:45:01 +0000
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p48-r1::gentoo
dev-lang/perl:            5.22.2::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.22.4::gentoo
sys-apps/sandbox:         2.10-r1::musl
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.9.4-r99::musl
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/musl:            1.1.15-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-gentoo-linux-musl"
CFLAGS="-O2 -mtune=native -ggdb -pipe"
CHOST="x86_64-gentoo-linux-musl"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -mtune=native -ggdb -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles installsources merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="charset.alias"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
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="amd64 bindist cli cracklib crypt cxx dri fortran hardened iconv ipv6 mmx modules ncurses nls nptl openmp pam pax_kernel pcre pic readline seccomp session sse sse2 ssl tcpd unicode xattr zlib" ABI_X86="64" 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="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" 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="php5-6" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21" USERLAND="GNU" VIDEO_CARDS="dummy fbdev 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, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 3 Richard Yao (RETIRED) gentoo-dev 2016-12-24 01:13:25 UTC
This disagreement only occurs on older versions of GCC:

01:10 < smaeul> ryao: ahh, I'm using gcc 5.4.001:10 < smaeul> it has #define __WCHAR_TYPE__ int
01:11 < smaeul> and #define __SIZE_TYPE__ long unsigned int
01:11 < smaeul> which matches musl
01:12 <+ryao> smaeul: Nice, so I just need to switch to a newer GCC... I had been sticking with the stable version.
Comment 4 Anthony Basile gentoo-dev 2016-12-24 01:14:05 UTC
(In reply to Richard Yao from comment #3)
> This disagreement only occurs on older versions of GCC:
> 
> 01:10 < smaeul> ryao: ahh, I'm using gcc 5.4.001:10 < smaeul> it has #define
> __WCHAR_TYPE__ int
> 01:11 < smaeul> and #define __SIZE_TYPE__ long unsigned int
> 01:11 < smaeul> which matches musl
> 01:12 <+ryao> smaeul: Nice, so I just need to switch to a newer GCC... I had
> been sticking with the stable version.

for older versions, add the musl overlay.
Comment 5 Felix Janda 2016-12-24 10:44:21 UTC
The only gcc-4.9 ebuild with the fix for this is gcc-4.9.3-r999.ebuild
from the musl overlay. This ebuild uses the gcc patches also used by
other distributions. There were however some other problems with this
approach.

Let me post the relevant part from the patches:

diff -r fef9a6ed0091 gcc/ginclude/stddef.h
--- a/gcc/ginclude/stddef.h	Sun Jul 26 15:32:09 2015 -0400
+++ b/gcc/ginclude/stddef.h	Sun Jul 26 15:32:11 2015 -0400
@@ -181,6 +181,7 @@
 #ifndef _GCC_SIZE_T
 #ifndef _SIZET_
 #ifndef __size_t
+#ifndef __DEFINED_size_t /* musl */
 #define __size_t__	/* BeOS */
 #define __SIZE_T__	/* Cray Unicos/Mk */
 #define _SIZE_T
@@ -197,6 +198,7 @@
 #define ___int_size_t_h
 #define _GCC_SIZE_T
 #define _SIZET_
+#define __DEFINED_size_t /* musl */
 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
   || defined(__FreeBSD_kernel__)
 /* __size_t is a typedef on FreeBSD 5, must not trash it. */
@@ -214,6 +216,7 @@
 typedef long ssize_t;
 #endif /* __BEOS__ */
 #endif /* !(defined (__GNUG__) && defined (size_t)) */
+#endif /* __DEFINED_size_t */
 #endif /* __size_t */
 #endif /* _SIZET_ */
 #endif /* _GCC_SIZE_T */
Comment 6 Anthony Basile gentoo-dev 2017-01-01 22:39:52 UTC
(In reply to Felix Janda from comment #5)
> The only gcc-4.9 ebuild with the fix for this is gcc-4.9.3-r999.ebuild
> from the musl overlay. This ebuild uses the gcc patches also used by
> other distributions. There were however some other problems with this
> approach.
> 
> Let me post the relevant part from the patches:

Should we forward port this to 4.9.4.  I'm hoping to jump from the overlay to gcc-6 in tree once its stabilized.  That may be a while.
Comment 7 Jory A. Pratt gentoo-dev 2019-06-13 01:12:15 UTC
As we no longer support <sys-devel/gcc-6 we can close this