Bug 249527 - graphics/vulkan-loader: Clang 11 crashes on i386 during build: Assertion failed: (Type == RT32_32), function getRelocType32
Summary: graphics/vulkan-loader: Clang 11 crashes on i386 during build: Assertion fail...
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
URL: http://beefy17.nyi.freebsd.org/data/h...
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2020-09-22 15:27 UTC by Jan Beich
Modified: 2020-09-24 17:17 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (greg)


Attachments
loader/gen_defines.asm (generated during build) (1.34 KB, text/plain)
2020-09-22 15:28 UTC, Jan Beich
no flags Details
loader/unknown_ext_chain_gas.S (unmodified) (23.36 KB, text/plain)
2020-09-22 15:30 UTC, Jan Beich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2020-09-22 15:27:53 UTC
FAILED: loader/CMakeFiles/vulkan.dir/unknown_ext_chain_gas.S.o
/usr/bin/cc -DAPI_NAME=\"Vulkan\" -DEXTRASYSCONFDIR=\"/etc\" -DFALLBACK_CONFIG_DIRS=\"/etc/xdg\" -DFALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\" -DHAVE_CET_H -DSYSCONFDIR=\"/usr/local/etc\" -DVK_ENABLE_BETA_EXTENSIONS -DVK_USE_PLATFORM_WAYLAND_KHR -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_XRANDR_EXT -Dvulkan_EXPORTS -I/wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader -I/wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader/generated -Iloader -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -std=c99 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fno-strict-aliasing -fno-builtin-memcmp -fvisibility=hidden -O3 -DNDEBUG -fPIC -MD -MT loader/CMakeFiles/vulkan.dir/unknown_ext_chain_gas.S.o -MF loader/CMakeFiles/vulkan.dir/unknown_ext_chain_gas.S.o.d -o loader/CMakeFiles/vulkan.dir/unknown_ext_chain_gas.S.o -c /wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader/unknown_ext_chain_gas.S
Assertion failed: (Type == RT32_32), function getRelocType32, file /usr/src/contrib/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp, line 260.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/bin/cc -cc1as -triple i386-unknown-freebsd13.0 -filetype obj -main-file-name unknown_ext_chain_gas.S -target-cpu i686 -I /wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader -I /wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader/generated -I loader -fdebug-compilation-dir /wrkdirs/usr/ports/graphics/vulkan-loader/work/.build -dwarf-debug-producer FreeBSD clang version 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc2-0-g414f32a9e86) -I /wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader -I /wrkdirs/usr/ports/graphics/vulkan-loader/work/Vulkan-Loader-sdk-1.2.135.0/loader/generated -I loader -dwarf-version=4 -mrelocation-model pic -o loader/CMakeFiles/vulkan.dir/unknown_ext_chain_gas.S.o /tmp/unknown_ext_chain_gas-debe49.s
#0 0x0426f584 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
#1 0x0426f99e PrintStackTraceSignalHandler(void*) /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:624:3
#2 0x0426d1bd llvm::sys::RunSignalHandlers() /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:67:5
#3 0x0426fcf9 SignalHandler(int) /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
#4 0x255eb179 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:303:3
cc: error: unable to execute command: Abort trap
cc: error: clang integrated assembler command failed due to signal (use -v to see invocation)
FreeBSD clang version 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc2-0-g414f32a9e86)
Target: i386-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
Comment 1 Jan Beich freebsd_committer 2020-09-22 15:28:46 UTC
Created attachment 218180 [details]
loader/gen_defines.asm (generated during build)
Comment 2 Jan Beich freebsd_committer 2020-09-22 15:30:19 UTC
Created attachment 218181 [details]
loader/unknown_ext_chain_gas.S (unmodified)
Comment 3 Jan Beich freebsd_committer 2020-09-22 15:35:04 UTC
Preprocessed source/script generated on crash is unusable:

  $ sh unknown_ext_chain_gas-c095a0.sh 2>&1 | head
  /usr/lib/clang/11.0.0/include/cet.h:45:11: error: expected absolute expression in directive
	  .p2align __PROPERTY_ALIGN
		   ^
  /usr/lib/clang/11.0.0/include/cet.h:53:11: error: expected absolute expression in directive
	  .p2align __PROPERTY_ALIGN
		   ^
  /usr/lib/clang/11.0.0/include/cet.h:54:2: error: unexpected token at start of statement
	  /* GNU_PROPERTY_X86_FEATURE_1_AND.  */
	  ^
  /usr/lib/clang/11.0.0/include/cet.h:61:11: error: expected absolute expression in directive

However, reproducing outside of ports (cross-compiling from amd64) is trivial:

 $ fetch -o "gen_defines.asm" "https://bugs.freebsd.org/bugzilla/attachment.cgi?id=218180"
 $ fetch -o "unknown_ext_chain_gas.S" "https://bugs.freebsd.org/bugzilla/attachment.cgi?id=218181"
 $ clang -m32 -c "unknown_ext_chain_gas.S"
 Assertion failed: (Type == RT32_32), function getRelocType32, file /usr/src/contrib/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp, line 260.
 [...]
Comment 4 Jan Beich freebsd_committer 2020-09-22 15:42:38 UTC
Clang 10 is not affected while Clang 9 and older don't support such assembly constructs.

$ clang10 -m32 -c "unknown_ext_chain_gas.S"
$ clang90 -m32 -c "unknown_ext_chain_gas.S"
<instantiation>:14:17: error: cannot use more than one symbol in memory operand
    push offset termin_error_string@GOT # Push the error string (fourth arg)
                ^
unknown_ext_chain_gas.S:385:5: note: while in macro instantiation
    PhysDevExtTermin 0
    ^
[...]
Comment 5 Dimitry Andric freebsd_committer 2020-09-22 17:53:03 UTC
This was reported upstream some time ago, as:
https://bugs.llvm.org/show_bug.cgi?id=47348

It chokes on a GOT relocation:

.intel_syntax noprefix
push offset termin_error_string@GOT

Obviously assertions don't trigger if they're disabled, so the clang10 port with its defaults won't crash, but maybe the resulting assembly is bogus. I haven't checked.
Comment 6 Jan Beich freebsd_committer 2020-09-22 19:56:18 UTC
(In reply to Dimitry Andric from comment #5)
> Obviously assertions don't trigger if they're disabled

Are Clang assertions disabled on /stable/11 ? I can't reproduce on 11.4 i386.

$ cc --version
FreeBSD clang version 10.0.0 (git@github.com:llvm/llvm-project.git llvmorg-10.0.0-0-gd32170dbd5b)
Target: i386-unknown-freebsd11.4
Thread model: posix
InstalledDir: /usr/bin
Comment 7 Dimitry Andric freebsd_committer 2020-09-22 20:10:13 UTC
(In reply to Jan Beich from comment #6)
> Are Clang assertions disabled on /stable/11 ? I can't reproduce on 11.4 i386.

Yes, all stable and releng branches have assertions disabled by default. It would be interesting to know whether the object files that come out are sensible, though. In particular the parts that use GOT references.
Comment 8 commit-hook freebsd_committer 2020-09-24 00:58:20 UTC
A commit references this bug:

Author: jbeich
Date: Thu Sep 24 00:57:13 UTC 2020
New revision: 549872
URL: https://svnweb.freebsd.org/changeset/ports/549872

Log:
  graphics/vulkan-loader: unbreak on -CURRENT on i386 by using GCC

  Assertion failed: (Type == RT32_32), function getRelocType32, file llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp, line 260.

  PR:		249527
  Reported by:	pkg-fallout

Changes:
  head/graphics/vulkan-loader/Makefile
Comment 9 Jan Beich freebsd_committer 2020-09-24 17:17:04 UTC
(In reply to Dimitry Andric from comment #7)
I'm not sure about the impact but before comment 8 (or ports r549872) many consumers still worked fine inside 11.4 i386 jail:
- devel/vulkan-tools: vkcube-wayland, vkcube-xcb
- emulators/ppsspp: uses dlopen(3), Settings->Backend->Vulkan + Homebrew & Demos -> Download -> Cave Story
- games/vkquake
- graphics/mesa-devel: newer drivers, "export VK_INSTANCE_LAYERS=VK_LAYER_MESA_overlay"
- graphics/waifu2x-ncnn-vulkan
- multimedia/mpv: --gpu-api=vulkan

No clue about emulators/wine* (native vulkan, vkd3d, dxvk).