Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang 17.0.6 and 18.1.2 fail to build libwebp-1.3.2 and harfbuzz-8.3.0 on ppc32/musl: "clang: error: clang frontend command failed with exit code 139" #86460

Open
ernsteiswuerfel opened this issue Mar 24, 2024 · 12 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form

Comments

@ernsteiswuerfel
Copy link

I get this at building libwebp-1.3.2 on my Talos II (ppc32 chroot, musl) with clang 17.0.6 or 18.1.2:

[...]
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_cost_enc.c  -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_cost_enc.o
/bin/sh ../../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp  -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2  -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe  -c -o libwebpencode_la-backward_references_enc.lo `test -f 'backward_references_enc.c' || echo '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/'`backward_references_enc.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c  -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o
1.	/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:345:3: current parser token 'chain'
2.	/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:262:62: parsing function body 'VP8LHashChainFill'
3.	/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:262:62: in compound statement ('{}')
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.2
Target: powerpc-gentoo-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/18/bin
Configuration file: /etc/clang/powerpc-gentoo-linux-musl-clang.cfg
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/tmp/portage/media-libs/libwebp-1.3.2/temp/backward_references_enc-f8155e.c
clang: note: diagnostic msg: /var/tmp/portage/media-libs/libwebp-1.3.2/temp/backward_references_enc-f8155e.sh
clang: note: diagnostic msg: 

********************
make[2]: *** [Makefile:546: libwebpencode_la-backward_references_enc.lo] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2-.ppc/src/enc'
make[1]: *** [Makefile:602: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2-.ppc/src'
make: *** [Makefile:428: all-recursive] Error 1

I get a similar error (clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)) when building harfbuzz-8.3.0.

I tried to run the relevant command in gdb but that wasn't very conclusive (for me):

 # gdb --args clang "-DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o"
GNU gdb (Gentoo 14.1 vanilla) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc-gentoo-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from clang...
(No debugging symbols found in clang)
(gdb) set follow-fork-mode child
(gdb) run
Starting program: /usr/lib/llvm/18/bin/clang -DHAVE_CONFIG_H\ -I.\ -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc\ -I../../src/webp\ -DNDEBUG\ -I../..\ -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2\ -fvisibility=hidden\ -Wall\ -Wconstant-conversion\ -Wdeclaration-after-statement\ -Wextra\ -Wfloat-conversion\ -Wformat\ -Wformat-nonliteral\ -Wformat\ -Wformat-security\ -Wmissing-declarations\ -Wmissing-prototypes\ -Wold-style-definition\ -Wparentheses-equality\ -Wshadow\ -Wshorten-64-to-32\ -Wundef\ -Wunreachable-code-aggressive\ -Wunreachable-code\ -Wunused-but-set-variable\ -Wunused\ -Wvla\ -O2\ -mcpu=7450\ -mtune=7450\ -pipe\ -c\ /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c\ -fPIC\ -DPIC\ -o\ .libs/libwebpencode_la-backward_references_enc.o
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Attaching after process 5411 vfork to child process 5414]
[New inferior 2 (process 5414)]
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Detaching vfork parent process 5411 after child exec]
[Inferior 1 (process 5411) detached]
process 5414 is executing new program: /usr/lib/llvm/18/bin/ld.lld
[New LWP 5415]
[New LWP 5416]
[New LWP 5417]
[New LWP 5418]
[New LWP 5419]
[New LWP 5420]
[New LWP 5421]
[New LWP 5422]
[New LWP 5423]
[New LWP 5424]
[New LWP 5425]
[New LWP 5426]
ld.lld: error: undefined symbol: main
>>> referenced by /usr/lib/Scrt1.o:(.got2+0x8)
[New LWP 5427]
[New LWP 5428]
[New LWP 5429]
[LWP 5429 exited]
[LWP 5428 exited]
[LWP 5427 exited]
[LWP 5426 exited]
[LWP 5425 exited]
[LWP 5424 exited]
[LWP 5423 exited]
[LWP 5422 exited]
[LWP 5421 exited]
[LWP 5420 exited]
[LWP 5419 exited]
[LWP 5418 exited]
[LWP 5417 exited]
[LWP 5416 exited]
[LWP 5415 exited]
[Inferior 2 (process 5414) exited with code 01]
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I use binutils bfd as linker I get the same "undefined symbol: main".

I don't think there is a general problem of clang/lld not working on musl/ppc32 as other packages like lz4 or pigz build just fine with clang and run fine.

Build.log and the 2 files mentioned in the backtrace attached.
libwebp-1.3.2:20240324-224754.log
backward_references.zip
harfbuzz-8.3.0:20240324-230857.log
hb-static.zip

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Mar 24, 2024
@shafik shafik added the needs-reduction Large reproducer that should be reduced into a simpler form label Mar 25, 2024
@Endilll
Copy link
Contributor

Endilll commented May 4, 2024

It doesn't reproduce for me using assertion builds of 17.0.1, 18.1.0, 18.1.2, and 19.0 (trunk).

@Endilll Endilll added the crash Prefer [crash-on-valid] or [crash-on-invalid] label May 4, 2024
@ernsteiswuerfel
Copy link
Author

@Endilll Did you perhaps try to reproduce on a 64bit ppc system?

I don't get this on ppc64 musl either, only on 32bit ppc musl. Just re-tried with clang 18.1.5 and still get the issue. Logs attached.

Building is done on my 64bit Talos II but on a ppc 32bit partition. Some data about the system:

 # emerge --info
Portage 3.0.63 (python 3.12.3-final-0, default/linux/ppc/23.0/musl, gcc-13, musl-1.2.4-r1, 6.8.9-gentoo-P9 ppc64)
=================================================================
System uname: Linux-6.8.9-gentoo-P9-ppc64-POWER9,_altivec_supported-with-libc
KiB Mem:    65657796 total,  62659604 free
KiB Swap:   16777212 total,  16777212 free
Timestamp of repository gentoo: Sat, 04 May 2024 08:50:00 +0000
Head commit of repository gentoo: f356f029ed91494220213d3412dba6f099b3b078
Timestamp of repository musl: Fri, 03 May 2024 11:48:49 +0000
Head commit of repository musl: 2a4c4a49ec79d96456cc6b3362a32a59f7c72533

sh dash 0.5.12
ld GNU ld (Gentoo 2.42 p3) 2.42.0
distcc 3.4 powerpc-unknown-linux-musl [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.1_p16-r6::gentoo
dev-build/autoconf:        2.71-r7::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.28.3::gentoo
dev-build/libtool:         2.4.7-r4::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.4.0-r1::gentoo
dev-lang/perl:             5.38.2-r2::gentoo
dev-lang/python:           3.11.9::gentoo, 3.12.3::gentoo
sys-apps/baselayout:       2.15::gentoo
sys-apps/openrc:           0.54::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           18.1.5::gentoo
sys-devel/gcc:             13.2.1_p20240210::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             18.1.5::gentoo
sys-devel/llvm:            17.0.6::gentoo, 18.1.5::gentoo
sys-kernel/linux-headers:  6.6-r1::gentoo (virtual/os-headers)
sys-libs/musl:             1.2.4-r1::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://yea/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-jobs: 2
    sync-rsync-extra-opts: --cc=xxhash --zc=lz4
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-metamanifest: no

localrepo
    location: /var/db/repos/localrepo
    masters: gentoo
    volatile: False

musl
    location: /var/db/repos/musl
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/musl.git
    masters: gentoo
    volatile: False

ACCEPT_KEYWORDS="ppc"
ACCEPT_LICENSE="*"
CBUILD="powerpc-unknown-linux-musl"
CFLAGS="-O2 -pipe -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec"
CHOST="powerpc-unknown-linux-musl"
CONFIG_PROTECT="/etc /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"
CXXFLAGS="-O2 -pipe -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec"
DISTDIR="/var/cache/distfiles"
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 -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec"
GENTOO_MIRRORS="https://mirror.kumi.systems/gentoo/ https://ftp.uni-stuttgart.de/gentoo-distfiles/"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="reflex"
LINGUAS="de en de_DE"
MAKEOPTS="-j16 -l18"
PKGDIR="/var/cache/binpkgs"
PORTAGE_BINHOST="http://packages.gentooexperimental.org/packages/amd64-stable"
PORTAGE_BZIP2_COMMAND="pbzip2"
PORTAGE_COMPRESS="bzip2"
PORTAGE_COMPRESS_FLAGS="-4"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--cc=xxhash --zc=lz4"
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"
RUSTFLAGS="-C opt-level=2 -C target-cpu=7450 -C codegen-units=4"
SHELL="/bin/bash"
USE="X acl alsa big-endian brotli bzip2 cairo caja cdda colord crypt cryptsetup css cups dav1d dbus dvd elogind exif flac gles2 gnutls gstreamer gtk gui iconv icu introspection ipv6 jpeg keyring lcms libnotify lm-sensors mp3 mtp ncurses nettle nls opengl openmp opus pam pcre pdf pic pipewire png policykit ppc pulseaudio qt5 raw readline seccomp spell ssl svg system-icu system-png system-sqlite threads tiff truetype udev udisks unicode upower usb vorbis vpx webp xattr xml xmp xxhash zlib zstd" ADA_TARGET="gcc_12" 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_PPC="altivec" CURL_SSL="gnutls" ELIBC="musl" 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="ieee1275" INPUT_DEVICES="libinput" KERNEL="linux" L10N="de en" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LLVM_TARGETS="PowerPC" LUA_SINGLE_TARGET="lua5-4" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_11 python3_12" RUBY_TARGETS="ruby31" SANE_BACKENDS="genesys" VIDEO_CARDS="r300 r600 radeon" 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, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BUNZIP2_COMMAND, PYTHONPATH, RANLIB, READELF, SIZE, STRINGS, STRIP, YACC, YFLAGS

For building a package with clang I use these settings on a per package basis:

COMMON_FLAGS="-O2 -mcpu=7450 -mtune=7450 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"

CC="clang"
CPP="clang-cpp"
CXX="clang++"
AR="llvm-ar"
NM="llvm-nm"
RANLIB="llvm-ranlib"

libwebp-1.3.2:20240504-223843.log
backward_references.zip

@Endilll
Copy link
Contributor

Endilll commented May 6, 2024

What I tried was basically a cross-compilation from x86-64 with glibc, using the triple from your reproducer script.

@ernsteiswuerfel
Copy link
Author

Had some spare time, made myself familiar with cvise and got a reduced test case out of it:

[...]
Runtime: 203 seconds
Reduced test-cases:

--- /home/ef/backward_references_enc-45b826.c ---
BackwardReferencesLz77() {
  int pix_count;
  for (; pix_count) {
    int j const j_max = 0;
    j <= j_max

The script I used with cvise was:

#!/bin/sh
clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -Wall -c backward_references_enc-45b826.c 2>&1 | grep 'error: clang frontend command failed with exit code 139 (use -v to see invocation'

Also found out when I build the (non-reduced) pre-processed binary without -Wall the build succeeds an I get a resulting object file.

Building was done with llvm/clang 18.1.6.

backward_references_enc-45b826.o.gz

@Endilll
Copy link
Contributor

Endilll commented May 20, 2024

Thank you! I'm tried to make a CE reproducer out of it, but it doesn't reproduce: https://godbolt.org/z/49s15bx1b
Do you have an idea what I might be missing?

@ernsteiswuerfel
Copy link
Author

Probably you forgot -Wall as parameter?

Without it you only get the whole bunch of errors regarding the obviously missing ;, ] and int type specifiers.

Fixing the obvious errors I get:

 $ cat reduced01.c 
int BackwardReferencesLz77() {
  int pix_count;
  for (; pix_count;) {
    int j; const int j_max = 0;
    j <= j_max;
  }
}

Which still provokes the issue on my ppc32 musl system:

 $ clang -Wall -c reduced01.c 
reduced01.c:5:7: warning: relational comparison result unused [-Wunused-comparison]
    5 |     j <= j_max;
      |     ~~^~~~~~~~
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: clang -Wall -c reduced01.c
1.	<eof> parser at end of file
2.	reduced01.c:1:30: parsing function body 'BackwardReferencesLz77'
3.	reduced01.c:1:30: in compound statement ('{}')
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 18.1.6
Target: powerpc-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/18/bin
Configuration file: /etc/clang/powerpc-unknown-linux-musl-clang.cfg
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/reduced01-e8c635.c
clang: note: diagnostic msg: /tmp/reduced01-e8c635.sh
clang: note: diagnostic msg: 

********************

Without -Wall clang -c reduced01.c actually produces a binary.

Hopefully this is helpful to you in some way. I am new at this cvise/godbolt stuff. 😳

@ernsteiswuerfel
Copy link
Author

Got a hint on gentoo-powerpc IRC to check out specific diagnostic flags.

Found out the specific diagnostic flag triggering the issue is -Wfor-loop-analysis. The other flags included in -Wmost had no influence.

@Endilll
Copy link
Contributor

Endilll commented May 21, 2024

I added -Wfor-loop-analysis, but still no crash: https://godbolt.org/z/q6377Yaj3

Hopefully this is helpful to you in some way. I am new at this cvise/godbolt stuff. 😳

Thank you for your cooperation! To be clear, I'm pushing for CE reproducer, because that eliminates aspects of it that are related to your particular setup. Otherwise we can't reproduce it on our machines and fix it.

If that's not possible, you should do a debug build of Clang, and post here how it crashes. It should contain more helpful information. I think at the moment we don't have neither a failed assertion nor a stack trace, so we can only guess what went wrong.

@matoro
Copy link

matoro commented May 21, 2024

Hey, I was able to reproduce this upon request. I'm having trouble doing a native debug build of LLVM due to exhausting the 32-bit virtual address space. From what I saw in the trace without debug symbols, it's entirely contained in LLVM, so I doubt the libc has anything to do with it (will check glibc to confirm).

In the meantime I will try and get a cross-compiled build with debug symbols going to provide a proper stack trace.

@matoro
Copy link

matoro commented May 22, 2024

Okay, the least-optimized build I was able to get where the debug symbols would still fit inside the 4G virtual memory limit was -Oz -g. Hope that doesn't optimize out too much of the good stuff.

Shockingly, this actually indeed does not reproduce under ppc glibc. Musl does seem to be required to trigger it. Additionally it does not seem to trip any assertions (this is with checking enabled for both LLVM & clang).

Here is the traceback summary:

Starting program: /usr/lib/llvm/18/bin/clang -Wall -c test.c
test.c:5:7: warning: relational comparison result unused [-Wunused-comparison]
    5 |     j <= j_max;
      |     ~~^~~~~~~~

Program received signal SIGSEGV, Segmentation fault.
llvm::dyn_cast<clang::BinaryOperator, clang::Stmt> (Val=0xffffffff) at /usr/lib/llvm/18/include/llvm/Support/Casting.h:663
663       return CastInfo<To, From *>::doCastIfPossible(Val);
(gdb) bt
#0  llvm::dyn_cast<clang::BinaryOperator, clang::Stmt> (Val=0xffffffff) at /usr/lib/llvm/18/include/llvm/Support/Casting.h:663
#1  0xf5c63ebc in clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::DeclMatcher, void>::Visit (this=0xfffeb974, S=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/include/clang/AST/StmtVisitor.h:47
#2  0xf5c68188 in clang::EvaluatedExprVisitorBase<std::add_pointer, (anonymous namespace)::DeclMatcher>::VisitStmt (this=0xfffeb974, S=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/include/clang/AST/EvaluatedExprVisitor.h:106
#3  0xf5c68188 in clang::EvaluatedExprVisitorBase<std::add_pointer, (anonymous namespace)::DeclMatcher>::VisitStmt (this=0xfffeb974, S=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/include/clang/AST/EvaluatedExprVisitor.h:106
#4  0xf5c74684 in (anonymous namespace)::DeclMatcher::DeclMatcher (S=..., Statement=0xf7fe4018, Decls=..., this=0xfffeb974) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Sema/SemaStmt.cpp:1840
#5  (anonymous namespace)::CheckForLoopConditionalStatement (Body=0xf7fe4018, Third=0x0, Second=0xf7fe3e58, S=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Sema/SemaStmt.cpp:1936
#6  clang::Sema::ActOnForStmt (this=0xee5f33a0, ForLoc=..., LParenLoc=..., First=First@entry=0x0, Second=..., third=..., RParenLoc=..., Body=Body@entry=0xf7fe4018) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Sema/SemaStmt.cpp:2181
#7  0xf4f17dc0 in clang::Parser::ParseForStatement (this=0xf7ec0f10, TrailingElseLoc=0x0) at /usr/src/debug/sys-devel/clang-18.1.6/clang/include/clang/Parse/RAIIObjectsForParser.h:463
#8  0xf4f135a0 in clang::Parser::ParseStatementOrDeclarationAfterAttributes (this=0xf7ec0f10, Stmts=..., StmtCtx=clang::Parser::ParsedStmtContext::AllowStandaloneOpenMPDirectives, TrailingElseLoc=0x0, CXX11Attrs=..., GNUAttrs=...)
    at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseStmt.cpp:311
#9  0xf4f142a0 in clang::Parser::ParseStatementOrDeclaration (this=0xf7ec0f10, Stmts=..., StmtCtx=clang::Parser::ParsedStmtContext::AllowStandaloneOpenMPDirectives, TrailingElseLoc=0x0) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseStmt.cpp:118
#10 0xf4f14a54 in clang::Parser::ParseCompoundStatementBody (this=0xf7ec0f10, isStmtExpr=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseStmt.cpp:1236
#11 0xf4f150a4 in clang::Parser::ParseFunctionStatementBody (this=this@entry=0xf7ec0f10, Decl=Decl@entry=0xf7fe3d38, BodyScope=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseStmt.cpp:2514
#12 0xf4f349fc in clang::Parser::ParseFunctionDefinition (this=this@entry=0xf7ec0f10, D=..., TemplateInfo=..., LateParsedAttrs=LateParsedAttrs@entry=0xfffec58c) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:1516
#13 0xf4e8bc7c in clang::Parser::ParseDeclGroup (this=this@entry=0xf7ec0f10, DS=..., Context=Context@entry=clang::DeclaratorContext::File, Attrs=..., DeclEnd=DeclEnd@entry=0x0, FRI=FRI@entry=0x0) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseDecl.cpp:2272
#14 0xf4f31dd0 in clang::Parser::ParseDeclOrFunctionDefInternal (this=0xf7ec0f10, Attrs=..., DeclSpecAttrs=..., DS=..., AS=clang::AS_none) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:1244
#15 0xf4f321f8 in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0xf7ec0f10, Attrs=..., DeclSpecAttrs=..., DS=<optimized out>, AS=clang::AS_none) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:1266
#16 0xf4f32454 in clang::Parser::ParseExternalDeclaration (this=0xf7ec0f10, Attrs=..., DeclSpecAttrs=..., DS=0x0) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:1070
#17 0xf4f33584 in clang::Parser::ParseTopLevelDecl (this=0xf7ec0f10, Result=..., ImportState=@0xfffed48c: clang::Sema::ModuleImportState::FirstDecl) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:760
#18 0xf4f336d8 in clang::Parser::ParseFirstTopLevelDecl (this=this@entry=0xf7ec0f10, Result=..., ImportState=@0xfffed48c: clang::Sema::ModuleImportState::FirstDecl) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/Parser.cpp:607
#19 0xf4e74d80 in clang::ParseAST (S=..., PrintStats=<optimized out>, SkipFunctionBodies=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Parse/ParseAST.cpp:162
#20 0xf6994d4c in clang::ASTFrontendAction::ExecuteAction (this=this@entry=0xee7caa80) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Frontend/FrontendAction.cpp:1183
#21 0xf61d68bc in clang::CodeGenAction::ExecuteAction (this=0xee7caa80) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/CodeGen/CodeGenAction.cpp:1153
#22 0xf69982ec in clang::FrontendAction::Execute (this=this@entry=0xee7caa80) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Frontend/FrontendAction.cpp:1069
#23 0xf693cc48 in clang::CompilerInstance::ExecuteAction (this=this@entry=0x44f4b0, Act=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Frontend/CompilerInstance.cpp:1057
#24 0xf69f2854 in clang::ExecuteCompilerInvocation (Clang=Clang@entry=0x44f4b0) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:272
#25 0x00416b5c in cc1_main (Argv=..., Argv0=<optimized out>, MainAddr=MainAddr@entry=0x411c50 <GetExecutablePath[abi:cxx11](char const*, bool)>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/tools/driver/cc1_main.cpp:294
#26 0x0040fdc4 in ExecuteCC1Tool (ArgV=..., ToolContext=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/tools/driver/driver.cpp:365
#27 0xf66b20cc in llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const (params#0=..., this=<optimized out>) at /usr/lib/llvm/18/include/llvm/ADT/STLFunctionalExtras.h:68
#28 operator() (__closure=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Driver/Job.cpp:440
#29 llvm::function_ref<void()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef> >, std::string*, bool*) const::<lambda()> >(intptr_t) (callable=<optimized out>) at /usr/lib/llvm/18/include/llvm/ADT/STLFunctionalExtras.h:45
#30 0xef4a8e1c in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) () from /usr/lib/llvm/18/bin/../lib/libLLVM.so.18.1
#31 0xf66b3ac8 in clang::driver::CC1Command::Execute (this=0xf7fedea0, Redirects=..., ErrMsg=<optimized out>, ExecutionFailed=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Driver/Job.cpp:440
#32 0xf6689d78 in clang::driver::Compilation::ExecuteCommand (this=0xf7fedd60, C=..., FailingCommand=@0xfffee2c0: 0x0, LogOnly=false) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Driver/Compilation.cpp:199
#33 0xf668a10c in clang::driver::Compilation::ExecuteJobs (this=this@entry=0xf7fedd60, Jobs=..., FailingCommands=..., LogOnly=LogOnly@entry=false) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Driver/Compilation.cpp:253
#34 0xf66a2270 in clang::driver::Driver::ExecuteCompilation (this=this@entry=0xfffee580, C=..., FailingCommands=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/lib/Driver/Driver.cpp:1918
#35 0x004138a4 in clang_main (Argc=<optimized out>, Argv=<optimized out>, ToolContext=...) at /usr/src/debug/sys-devel/clang-18.1.6/clang/tools/driver/driver.cpp:540
#36 0x0040e978 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/sys-devel/clang-18.1.6/x/y/clang-.ppc/tools/driver/clang-driver.cpp:17

I also happened to notice my dmesg kernel log would generate the following when running:

clang[30570]: User access of kernel address (ffffffff) - exploit attempt? (uid: 0)

Finally, here is a complete backtrace with code snippets and locals, which I generated from the following gdb script:

set trace-commands on
set logging enabled on
set pagination off
run
set i=0
while ($i<37)
  frame $i
  list
  info locals
  set $i=$i+1
end

gdb.txt

@Endilll
Copy link
Contributor

Endilll commented Jun 3, 2024

@matoro Thank you! Stack trace is helpful to have.

@Endilll Endilll added clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party and removed clang Clang issues not falling into any other category labels Jun 3, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 3, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (ernsteiswuerfel)

I get this at building libwebp-1.3.2 on my Talos II (ppc32 chroot, musl) with clang 17.0.6 or 18.1.2: ``` [...] libtool: compile: clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_cost_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_cost_enc.o /bin/sh ../../libtool --tag=CC --mode=compile clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c -o libwebpencode_la-backward_references_enc.lo `test -f 'backward_references_enc.c' || echo '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/'`backward_references_enc.c libtool: compile: clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o 1. /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:345:3: current parser token 'chain' 2. /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:262:62: parsing function body 'VP8LHashChainFill' 3. /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c:262:62: in compound statement ('{}') clang: error: clang frontend command failed with exit code 139 (use -v to see invocation) clang version 18.1.2 Target: powerpc-gentoo-linux-musl Thread model: posix InstalledDir: /usr/lib/llvm/18/bin Configuration file: /etc/clang/powerpc-gentoo-linux-musl-clang.cfg clang: note: diagnostic msg: ********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/tmp/portage/media-libs/libwebp-1.3.2/temp/backward_references_enc-f8155e.c
clang: note: diagnostic msg: /var/tmp/portage/media-libs/libwebp-1.3.2/temp/backward_references_enc-f8155e.sh
clang: note: diagnostic msg:


make[2]: *** [Makefile:546: libwebpencode_la-backward_references_enc.lo] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2-.ppc/src/enc'
make[1]: *** [Makefile:602: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2-.ppc/src'
make: *** [Makefile:428: all-recursive] Error 1

I get a similar error (`clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)`) when building harfbuzz-8.3.0.

I tried to run the relevant command in gdb but that wasn't very conclusive (for me):

gdb --args clang "-DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc -I../../src/webp -DNDEBUG -I../.. -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2 -fvisibility=hidden -Wall -Wconstant-conversion -Wdeclaration-after-statement -Wextra -Wfloat-conversion -Wformat -Wformat-nonliteral -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wparentheses-equality -Wshadow -Wshorten-64-to-32 -Wundef -Wunreachable-code-aggressive -Wunreachable-code -Wunused-but-set-variable -Wunused -Wvla -O2 -mcpu=7450 -mtune=7450 -pipe -c /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c -fPIC -DPIC -o .libs/libwebpencode_la-backward_references_enc.o"

GNU gdb (Gentoo 14.1 vanilla) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc-gentoo-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from clang...
(No debugging symbols found in clang)
(gdb) set follow-fork-mode child
(gdb) run
Starting program: /usr/lib/llvm/18/bin/clang -DHAVE_CONFIG_H\ -I.\ -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc\ -I../../src/webp\ -DNDEBUG\ -I../..\ -I/var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2\ -fvisibility=hidden\ -Wall\ -Wconstant-conversion\ -Wdeclaration-after-statement\ -Wextra\ -Wfloat-conversion\ -Wformat\ -Wformat-nonliteral\ -Wformat\ -Wformat-security\ -Wmissing-declarations\ -Wmissing-prototypes\ -Wold-style-definition\ -Wparentheses-equality\ -Wshadow\ -Wshorten-64-to-32\ -Wundef\ -Wunreachable-code-aggressive\ -Wunreachable-code\ -Wunused-but-set-variable\ -Wunused\ -Wvla\ -O2\ -mcpu=7450\ -mtune=7450\ -pipe\ -c\ /var/tmp/portage/media-libs/libwebp-1.3.2/work/libwebp-1.3.2/src/enc/backward_references_enc.c\ -fPIC\ -DPIC\ -o\ .libs/libwebpencode_la-backward_references_enc.o
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Attaching after process 5411 vfork to child process 5414]
[New inferior 2 (process 5414)]
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[Detaching vfork parent process 5411 after child exec]
[Inferior 1 (process 5411) detached]
process 5414 is executing new program: /usr/lib/llvm/18/bin/ld.lld
[New LWP 5415]
[New LWP 5416]
[New LWP 5417]
[New LWP 5418]
[New LWP 5419]
[New LWP 5420]
[New LWP 5421]
[New LWP 5422]
[New LWP 5423]
[New LWP 5424]
[New LWP 5425]
[New LWP 5426]
ld.lld: error: undefined symbol: main
>>> referenced by /usr/lib/Scrt1.o:(.got2+0x8)
[New LWP 5427]
[New LWP 5428]
[New LWP 5429]
[LWP 5429 exited]
[LWP 5428 exited]
[LWP 5427 exited]
[LWP 5426 exited]
[LWP 5425 exited]
[LWP 5424 exited]
[LWP 5423 exited]
[LWP 5422 exited]
[LWP 5421 exited]
[LWP 5420 exited]
[LWP 5419 exited]
[LWP 5418 exited]
[LWP 5417 exited]
[LWP 5416 exited]
[LWP 5415 exited]
[Inferior 2 (process 5414) exited with code 01]
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I use binutils bfd as linker I get the same "undefined symbol: main".

I don't think there is a general problem of clang/lld not working on musl/ppc32 as other packages like lz4 or pigz build just fine with clang and run fine.

Build.log and the 2 files mentioned in the backtrace attached.
[libwebp-1.3.2:20240324-224754.log](https://github.com/llvm/llvm-project/files/14737151/libwebp-1.3.2.20240324-224754.log)
[backward_references.zip](https://github.com/llvm/llvm-project/files/14737152/backward_references.zip)
[harfbuzz-8.3.0:20240324-230857.log](https://github.com/llvm/llvm-project/files/14737156/harfbuzz-8.3.0.20240324-230857.log)
[hb-static.zip](https://github.com/llvm/llvm-project/files/14737167/hb-static.zip)

</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] needs-reduction Large reproducer that should be reduced into a simpler form
Projects
None yet
Development

No branches or pull requests

5 participants