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
Created attachment 882118 [details] build.log.xz
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.
Created attachment 882127 [details] Expanded native
Created attachment 882128 [details] Build log with -march=generic -mtune=generic
Created attachment 882129 [details] ./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic
Created attachment 882130 [details] ./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=generic -mtune=generic
Created attachment 882131 [details] ./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Created attachment 882132 [details] ./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Created attachment 882133 [details] libc.so.6 with -march=native -mtune=native
Created attachment 882134 [details] libc.so.6 with -march=generic -mtune=generic
Think I got all you requested. Hopefully provided in a way that is easy to work with.
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.
Does it work fine if you enable USE=multiarch?
(In reply to Ionen Wolkens from comment #13) > Does it work fine if you enable USE=multiarch? Yes it does.
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.
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
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.
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.
Created attachment 892414 [details] ./glibc-2.38-r9/work/build-x86-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Created attachment 892415 [details] ./glibc-2.38-r9/work/build-amd64-x86_64-pc-linux-gnu-nptl/config.log with -march=native -mtune=native
Created attachment 892416 [details] build.log.xz with -march=native -mtune=native
Reattached corrupted files. I have updated glibc and gcc since reporting this: sys-libs/glibc-2.39-r5 sys-devel/gcc-13.2.1_p20240503 I can provide a recent emerge --info if you want. I didn't think it was necessary.
Thanks for the full report! The issue occurs with -march=x86-64-v4 or when -march=native enables all x86-64-v4 features. This is a glibc bug, I've submitted a patch upstream to address the issue: https://inbox.sourceware.org/libc-alpha/20240507182502.3820027-1-gabifalk@gmx.com/T/#u
Thank you Gabi! It's been committed upstream and I've backported it (upstream) to 2.39. Not yet in Gentoo.
commit 1d73ad7501ff2493d151e25f9c1eb1ab2f382f03 Author: Andreas K. Hüttel <dilfridge@gentoo.org> Date: Sun May 12 12:25:12 2024 +0200 sys-libs/glibc: add 2.39 patchlevel 6 (minor but helpful) Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org> commit 3a0ca0d9f58fb198073a8a30469a1e1eab156b08 Author: Andreas K. Hüttel <dilfridge@gentoo.org> Date: Sun May 12 16:27:24 2024 +0200 sys-libs/glibc: keyword 2.39-r6 Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>