Fedora 38 build of clang 16 fails when run under s390x emulation (both system & linux-user)

Host environment

  • Operating system: Fedora 38
  • OS/kernel version: 6.2.12-300.fc38.x86_64
  • Architecture: x86_64
  • QEMU flavor: qemu-s390x
  • QEMU version: 7.2.1

Description of problem

Spawn a Fedora 38 container using s390x linux-user based emulation

$ podman run -it --platform linux/s390x fedora:latest

Install clang inside it

sh-5.2# dnf -y install clang

Try to run clang

sh-5.2# clang --version
clang version 16.0.4 (Fedora 16.0.4-1.fc38)
Target: s390x-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
sh-5.2# clang --help   
clang-16: error: unsupported option '--help'; did you mean '--help'?
clang-16: error: no input files

Notice the nonsense error message when requesting --help. With Fedora 37 build of clang 15 (compiled with gcc 12), under s390x emulation, --help will correctly print the help. In fact all options except for --version appear to be broken:

sh-5.2# echo "void foo(void) {}" > foo.c
sh-5.2# clang -c foo.c
clang-16: error: unknown argument: '-c'

IOW, there appears to be something in the clang 16 (compiled with gcc 13) in Fedora 38 that is tripping up s390x emulation.

It is unclear whether the trigger was from building clang 16 with a newer gcc 13, or whether something changed from clang 15 -> 16.

Originally reported with qemu-user-static-7.2.1-1.fc38.x86_64, but I've reproduced with QEMU upstream 7.1.0 release and QEMU upstream git master (v8.0.0-394-gc2b7158455)

This was originally reported in Fedora at

https://bugzilla.redhat.com/show_bug.cgi?id=2209635

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information