Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 921945 - sys-devel/gcc fails to compile sys-libs/glibc[-multiarch] correctly with -march=native -mtune=native (wcsncat is missing)
Summary: sys-devel/gcc fails to compile sys-libs/glibc[-multiarch] correctly with -mar...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-12 17:38 UTC by Kenton Groombridge
Modified: 2024-04-25 20:55 UTC (History)
5 users (show)

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


Attachments
build.log.xz (build.log.xz,501.43 KB, application/x-xz)
2024-01-12 17:38 UTC, Kenton Groombridge
Details
Expanded native (expanded-native.txt,6.01 KB, text/plain)
2024-01-12 18:11 UTC, Kenton Groombridge
Details
Build log with -march=generic -mtune=generic (build.log.xz,497.52 KB, application/x-xz)
2024-01-12 18:15 UTC, Kenton Groombridge
Details
./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic (config.log,43.98 KB, text/x-log)
2024-01-12 18:19 UTC, Kenton Groombridge
Details
./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic (config.log,43.07 KB, text/x-log)
2024-01-12 18:20 UTC, Kenton Groombridge
Details
./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native (config.log,43.98 KB, text/x-log)
2024-01-12 18:22 UTC, Kenton Groombridge
Details
./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native (config.log,43.07 KB, text/x-log)
2024-01-12 18:22 UTC, Kenton Groombridge
Details
libc.so.6 with -march=native -mtune=native (libc.so.6.xz,629.44 KB, application/x-xz)
2024-01-12 18:25 UTC, Kenton Groombridge
Details
libc.so.6 with -march=generic -mtune=generic (libc.so.6.xz,629.44 KB, application/x-xz)
2024-01-12 18:26 UTC, Kenton Groombridge
Details
Expand -march=native, exact gcc version and other system-specific options (expanded_native,5.92 KB, patch)
2024-04-04 15:24 UTC, Amit Prakash Ambasta
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenton Groombridge 2024-01-12 17:38:23 UTC
When compiling glibc on a AMD_Ryzen 9 7950X system, glibc doesn't contain the symbol for wcsncat.

I have two nearly identical systems and one system with a different processor does include the symbol (with the same CFLAGS), but on this system, when building with 'CFLAGS="-O2 -pipe -march=native -mtune=native"', the symbol wcsncat is not found. If I change to use 'CFLAGS="-O2 -pipe -march=generic -mtune=generic"', then the symbol is created.

Here is the output showing the missing symbol when built with 'CFLAGS="-O2 -pipe -march=native -mtune=native"':

nm -gD /usr/lib64/libc.so.6 | grep wcsn
00000000000a50c0 T __wcsncasecmp_l@@GLIBC_2.2.5
00000000001068b0 T __wcsncat_chk@@GLIBC_2.4
00000000001069d0 T __wcsncpy_chk@@GLIBC_2.4
00000000001069f0 T __wcsnrtombs_chk@@GLIBC_2.4
00000000000a5050 W wcsncasecmp@@GLIBC_2.2.5
00000000000a50c0 W wcsncasecmp_l@@GLIBC_2.3
0000000000144cc0 T wcsncmp@@GLIBC_2.2.5
0000000000145380 W wcsncpy@@GLIBC_2.2.5
0000000000145900 W wcsnlen@@GLIBC_2.2.5
00000000000a5140 W wcsnrtombs@@GLIBC_2.2.5 

Here is the output showing the missing symbol when built with 'CFLAGS="-O2 -pipe -march=generic -mtune=generic"':

 nm -gD /usr/lib64/libc.so.6 | grep wcsn 
00000000000afe50 T __wcsncasecmp_l@@GLIBC_2.2.5
000000000010f5b0 T __wcsncat_chk@@GLIBC_2.4
000000000010f6c0 T __wcsncpy_chk@@GLIBC_2.4
000000000010f6e0 T __wcsnrtombs_chk@@GLIBC_2.4
00000000000afde0 W wcsncasecmp@@GLIBC_2.2.5
00000000000afe50 W wcsncasecmp_l@@GLIBC_2.3
00000000000be1a0 T wcsncat@@GLIBC_2.2.5
00000000000be1f0 T wcsncmp@@GLIBC_2.2.5
00000000000be2d0 W wcsncpy@@GLIBC_2.2.5
00000000000be320 W wcsnlen@@GLIBC_2.2.5
00000000000afed0 W wcsnrtombs@@GLIBC_2.2.5


Reproducible: Always

Steps to Reproduce:
1. Using CFLAGS="-O2 -pipe -march=native -mtune=native", wcsncat symbol is missing.
2. Using CFLAGS="-O2 -pipe -march=generic -mtune=generic" wcsncat symbols is available.
Actual Results:  
Programs that require wcsncat fail to compile/run.

Expected Results:  
Programs that require wcsncat will compile/run.

 emerge --info
Portage 3.0.61 (python 3.11.7-final-0, default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr, gcc-13, glibc-2.38-r9, 6.7.0-gentoo x86_64)
=================================================================
System uname: Linux-6.7.0-gentoo-x86_64-AMD_Ryzen_9_7950X_16-Core_Processor-with-glibc2.38
KiB Mem:    64982604 total,  54763084 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Fri, 12 Jan 2024 00:43:28 +0000
Head commit of repository gentoo: d90dc3047c7ada559449dfd5cc938ed7e2dc27bb

sh bash 5.2_p21-r2
ld GNU ld (Gentoo 2.41 p4) 2.41.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p21-r2::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           3.11.7::gentoo, 3.12.1_p1::gentoo
dev-lang/rust-bin:         1.74.1::gentoo
dev-util/cmake:            3.28.1-r1::gentoo
dev-util/meson:            1.3.1::gentoo
sys-apps/baselayout:       2.14-r1::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-apps/systemd:          255.2-r1::gentoo
sys-devel/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.41-r4::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.6::gentoo
sys-devel/gcc:             13.2.1_p20231216::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r2::gentoo
sys-devel/lld:             17.0.6::gentoo
sys-devel/llvm:            17.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.6::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r9::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo.git
    priority: -1000
    volatile: True

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0
    volatile: True

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://gentoo.osuosl.org/releases/amd64/binpackages/17.1/x86-64

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -mtune=native"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/vmware-installer"
CXXFLAGS="-O2 -pipe -march=native -mtune=native"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE 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 XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://server/ http://mirror.leaseweb.com/gentoo/ http://gentoo.osuosl.org/ http://mirrors.aliyun.com/gentoo/ http://gentoo.mirrors.ovh.net/gentoo-distfiles/"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
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"
SHELL="/bin/bash"
USE="X a52 aac acpi activities afpacket alsa alsa-plugin amd64 amdgpu bluetooth branding bzip2 cairo cdda cdr cli client contribdnn crypt cups dbus declarative dri3 dts dvb dvd dvdr efi efiemu encode evdev exif extra fdk ffmpeg file-inspect flac fortran gdbm gentoo-vm gif git gles2 gpm gstreamer gtk gtk3 gui harfbuzz hex hpcups http2 iconv icu ipv6 java javascript jit jpeg kmod kwallet lcms legacy-systray libnotify libtirpc mad mariadb markdown maxminddb mjpeg mng mp3 mp4 mpeg multilib ncurses networkmanager nfs nfsv41 nls nptl nsplugin nss ntfs ntfsprogs ntp offensive ogg openal opengl openmp opensc openssl pam pango pcre pcre32 pcsc-lite pdf pipewire pipewire-alsa pkcs11 plasma png policykit ppds projectm proprietary-codecs pulseaudio python qemu qml qt5 rar rdp readline redistributable savedconfig scanner scp screencast sdl seccomp secure-delete semantic-desktop sensors shm smartcard sound sound-server spell sqlite ssl startup-notification sudo svg system-mitkrb5 systemd test-rust theora threads tiff touchpad truetype udev udisks unicode usb v4l v4l2 vaapi vdpau vorbis vpx vulkan wayland widevine widgets winbind wma wxwidgets x264 x265 xattr xcb xft xml xnest xorg xv xvid xvmc zip zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio 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="aes avx avx2 avx512f avx512dq avx512cd avx512bw avx512vl avx512vbmi f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en en_US" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" QEMU_SOFTMMU_TARGETS="i386 x86_64" SANE_BACKENDS="epson" VIDEO_CARDS="amdgpu radeon radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Kenton Groombridge 2024-01-12 17:38:57 UTC
Created attachment 882118 [details]
build.log.xz
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-12 17:43:35 UTC
Some initial thoughts:
* You shouldn't need -march *and* -mtune if they're both for =native (-mtune should be obsolete then).

* Could you expand what 'native' is on your machine? (https://wiki.gentoo.org/wiki/GCC_ICE_reporting_guide#Expand_-march.3Dnative.2C_exact_gcc_version_and_other_system-specific_options)
** app-misc/resolve-march-native output may also be helpful

* Could you try to grab config.log + build.log from glibc with both good/bad? You can do this using 'ebuild /path/to/glibc-1.2.3.4.ebuild clean configure' and then poking around in the workdir.

* It may also be helpful if you could provide a good and bad binary -- perhaps even if you did 'ebuild .. clean install' (note that this *won't* merge to your live filesystem, as that needs '... merge') and then just tarball the good + bad workdirs, so we can compare the two.
Comment 3 Kenton Groombridge 2024-01-12 18:11:53 UTC
Created attachment 882127 [details]
Expanded native
Comment 4 Kenton Groombridge 2024-01-12 18:15:22 UTC
Created attachment 882128 [details]
Build log with -march=generic -mtune=generic
Comment 5 Kenton Groombridge 2024-01-12 18:19:23 UTC
Created attachment 882129 [details]
./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic
Comment 6 Kenton Groombridge 2024-01-12 18:20:06 UTC
Created attachment 882130 [details]
./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic
Comment 7 Kenton Groombridge 2024-01-12 18:22:21 UTC
Created attachment 882131 [details]
./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Comment 8 Kenton Groombridge 2024-01-12 18:22:52 UTC
Created attachment 882132 [details]
./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Comment 9 Kenton Groombridge 2024-01-12 18:25:14 UTC
Created attachment 882133 [details]
libc.so.6 with -march=native -mtune=native
Comment 10 Kenton Groombridge 2024-01-12 18:26:36 UTC
Created attachment 882134 [details]
libc.so.6 with -march=generic -mtune=generic
Comment 11 Kenton Groombridge 2024-01-12 18:28:27 UTC
Think I got all you requested. Hopefully provided in a way that is easy to work with.
Comment 12 Kenton Groombridge 2024-01-12 18:59:33 UTC
I noticed in my first post, that the second nm command says "showing the missing symbol" as it should read "showing the correct symbol". Just got a little happy with copy/paste.
Comment 13 Ionen Wolkens gentoo-dev 2024-01-12 19:10:03 UTC
Does it work fine if you enable USE=multiarch?
Comment 14 Kenton Groombridge 2024-01-12 19:49:34 UTC
(In reply to Ionen Wolkens from comment #13)
> Does it work fine if you enable USE=multiarch?

Yes it does.
Comment 15 Amit Prakash Ambasta 2024-04-04 15:23:41 UTC
Can reproduce on a 7840U (framework 13) as well.

W/ march=native, gcc throws undefined symbol for wcsncat. However, w/ march=generic or even march=znver4, the issue is resolved.
Comment 16 Amit Prakash Ambasta 2024-04-04 15:24:30 UTC
Created attachment 889409 [details, diff]
Expand -march=native, exact gcc version and other system-specific options

Added output for `for t in param target optimize optimizer; do cmd="gcc -Q --help=$t"; diff -U0 <(LANG=C $cmd) <(LANG=C $cmd -march=native); done` on 7840U
Comment 17 Dylan Simon 2024-04-10 03:52:52 UTC
I'm also seeing this same problem with -march=native on an Intel Xeon Gold 6234 (cascade lake).  It shows up specifically building dev-lang/python-3.10.14.
Comment 18 Gabi Falk 2024-04-25 20:55:34 UTC
Something went wrong with the attachments.

$ for a in 882130 882132 882129 882131 882133 882134; do echo "$a:" "$(curl -L --no-progress-meter "https://bugs.gentoo.org/attachment.cgi?id=$a" | sha1sum)"; done
882130: bffd25325297c5972e045e28e48f6b6ec6eb7723  -
882132: bffd25325297c5972e045e28e48f6b6ec6eb7723  -
882129: 5744525b7d4830212c212b401c11ca40278c8d37  -
882131: 5744525b7d4830212c212b401c11ca40278c8d37  -
882133: f0797dac61a24e3810c2f3a0890c919e88779d1f  -
882134: f0797dac61a24e3810c2f3a0890c919e88779d1f  -

So, unfortunately, all logs and data we currently have here are about -march=generic; there is essentially nothing about -march=native.