decaf-emu / decaf-emu

Researching Wii U emulation.
GNU General Public License v3.0
1.25k stars 141 forks source link

Whole bunch of SPIRV-related errors prevent building #616

Open v-fox opened 3 years ago

v-fox commented 3 years ago

I never managed to finish a build successfully. After battling one issue after another, it came down with shower of errors like this:

[  152s] /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_shaderspvbuilder.h:1159:95: error: no matching function for call to 'spv::Builder::If::If(<brace-enclosed initializer list>)'
[  152s]  1159 |             auto eq2block = spv::Builder::If { lopClear, spv::SelectionControlMaskNone, *this };
[  152s]       |                                                                                               ^
[  152s] In file included from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_spvbuilder.h:5,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_shaderspvbuilder.h:4,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_transpiler.h:5,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_cf.cpp:2:
[  152s] /usr/include/SPIRV/SpvBuilder.h:512:9: note: candidate: 'spv::Builder::If::If(const spv::Builder::If&)'
[  152s]   512 |         If(const If&);
[  152s]       |         ^~
[  152s] /usr/include/SPIRV/SpvBuilder.h:512:9: note:   candidate expects 1 argument, 3 provided
[  152s] /usr/include/SPIRV/SpvBuilder.h:505:9: note: candidate: 'spv::Builder::If::If(spv::Id, unsigned int, spv::Builder&)'
[  152s]   505 |         If(Id condition, unsigned int ctrl, Builder& builder);
[  152s]       |         ^~
[  152s] /usr/include/SPIRV/SpvBuilder.h:505:9: note:   conversion of argument 1 would be ill-formed:
[  152s] In file included from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_transpiler.h:5,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_cf.cpp:2:
[  152s] /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_shaderspvbuilder.h:1188:45: error: no matching function for call to 'spirv::ShaderSpvBuilder::createLoad(unsigned int&)'
[  152s]  1188 |             auto needsPremulVal = createLoad(needsPremulPtr);
[  152s]       |                                   ~~~~~~~~~~^~~~~~~~~~~~~~~~
[  152s] In file included from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_spvbuilder.h:5,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_shaderspvbuilder.h:4,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_transpiler.h:5,
[  152s]                  from /home/abuild/rpmbuild/BUILD/decaf-emu-20210413T090500/src/libgpu/src/spirv/spirv_cf.cpp:2:
[  152s] /usr/include/SPIRV/SpvBuilder.h:377:8: note: candidate: 'spv::Id spv::Builder::createLoad(spv::Id, spv::Decoration, spv::MemoryAccessMask, spv::Scope, unsigned int)'
[  152s]   377 |     Id createLoad(Id lValue, spv::Decoration precision,
[  152s]       |        ^~~~~~~~~~
[  152s] /usr/include/SPIRV/SpvBuilder.h:377:8: note:   candidate expects 5 arguments, 1 provided

I suspect that it has something to do with incompatibility with recent spirv versions.

exjam commented 3 years ago

I built with the latest Vulkan SDK 1.282.0 on both Windows with VS2019 and Linux with GCC9 and do not see this issue,

What compiler are you using?

v-fox commented 3 years ago

I built with the latest Vulkan SDK 1.282.0 on both Windows with VS2019 and Linux with GCC9 and do not see this issue,

What kind of SDK are you using ? Because the current latest is 1.2.184 and rolling openSUSE TW uses 1.2.182.

What compiler are you using?

gcc-11.1.1, as you can see in linked-above spec-file and build log. No one on Open Build Service were able to make a build since 2019.

exjam commented 3 years ago

Sorry was a typo, I meant 1.2.182.0. I'll try gcc-11.

Do you know if there is a way for me to reproduce the equivalent of open build service does locally on a VM?

v-fox commented 3 years ago

Do you know if there is a way for me to reproduce the equivalent of open build service does locally on a VM?

I'm sure there is, beforehand there was entire site about making LiveCD spins on OBS for OBS but it was shut down for a while and OBS LiveCD-builded was almost sabotaged by its rewrites and incompatibility-ridden "enhancements", so I'm not so sure now.

Getting official TW installer and installing full OBS toolkit over would be most straightforward way, I assume. What OBS does is: 1) making chroot/container with basic system packages from current repos (openSUSE TW only by default, custom repo sources may be added by user, other distros may be used); 2) adding package build dependencies over basic packages; 3) launching rpm macro-script from spec-file as "build stages" from default user in chroot. 4) either fail on any non-0 exit code or pass and scoop up all files, copied in install "buildroot" dir, as a package.

Of course, openSUSE TW, being rolling, mostly uses the latest release versions of everything, lag in making updates notwithstanding. Just installing it with build dependencies on VM may be enough for your tests.

exjam commented 3 years ago

I was indeed able to reproduce the problem on opensuse.

Then I realised spirv builder does not come from Vulkan SDK it actually comes from glslang, which decaf-emu has as a git submodule and is currently using version 7.12.3352 and the newest is 11.5.0.

So basically we need to update decaf-emu to work with newer glslang, or on OBS build with the older version that decaf uses (if thats even possible).

exjam commented 3 years ago

Seems like the main change was that many functions were changed to take spv::Decoration precision, i think passing in spv::NoPrecision should hopefully be sufficient in those cases. Run out of time to test today, I will try this another day.

v-fox commented 3 years ago

So basically we need to update decaf-emu to work with newer glslang, or on OBS build with the older version that decaf uses (if thats even possible).

Pretty sure that keeping multiple version of the same shared binary library, with the same so-name no less, is a no-go for OBS. Note that I also use few patches to get rid of bundled libs and git dependency which is a necessity for any distro build & packaging system. So apps are always expected to build with newest versions of their dependencies, otherwise they are purged from repos.

Here, of course, most blame lies on Khronos & buddies, as they don't version their libraries properly while not caring about compatibility.

exjam commented 3 years ago

I updated glslang and fixed the errors in https://github.com/decaf-emu/decaf-emu/commit/b2af3a2f32242b4544f03e7695ec2d0c440caf7e

v-fox commented 3 years ago

I updated glslang and fixed the errors in b2af3a2

Thanks ! Those errors seem to be gone.

Still can't build though, now with:

src/libdecaf/src/cafe/libraries/h264/h264_decode_ffmpeg.cpp:22:10: fatal error: libavcodec/avcodec.h: No such file or directory

Even though all ffmpeg-4-4.4 devel files should be pulled fine.

When forcing ffmpeg off with -DDECAF_FFMPEG=OFF, it first failed with src/decaf-qt/src/renderwidget.cpp:20:10: fatal error: qpa/qplatformnativeinterface.h: No such file or directory, alleviated by installing libqt5-qtbase-private-headers-devel even though using private headers is against best practice, but then final linking failed with:

/tmp/ccUNXgCM.ltrans98.ltrans.o:<artificial>:typeinfo for spirv::SpvBuilder: error: undefined reference to 'typeinfo for spv::Builder'

And also have bunch of warnings of:

src/./libcpu/be2_struct.h:53:8: note: type 'struct be2_struct' itself violates the C++ One Definition Rule

Happens with both gold and ld:

/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/cc2Yu32N.ltrans98.ltrans.o:(.data.rel.ro+0x28): undefined reference to `typeinfo for spv::Builder'

Without LTO is says:

../../obj/liblibgpu.a(spirv_transpiler.cpp.o):spirv_transpiler.cpp:typeinfo for spirv::SpvBuilder: error: undefined reference to 'typeinfo for spv::Builder'
dracc commented 3 years ago

Even though all ffmpeg-4-4.4 devel files should be pulled fine.

From my experience most distributions have libavcodec-dev as a separate package from ffmpeg.

v-fox commented 3 years ago

From my experience most distributions have libavcodec-dev as a separate package from ffmpeg.

Which is why, if you open the first link and look into my spec-file, you will see BuildRequires: pkgconfig(libavcodec). As well as these in build-log:

[   18s] [449/523] cumulate libavcodec58_134-4.4-281.3
[   18s] [459/523] cumulate ffmpeg-4-libavcodec-devel-4.4-281.3

Pretty sure that decaf's ffmpeg code was unbuildable for years. Without 3rd-party FindFFmpeg.cmake it fails on configuration step altogether. And with ffmpeg disabled, it's still unbuildable.

exjam commented 3 years ago

For me to work on this further I need a bit more help with the osc workflow.

What I did to try building your package is:

 osc checkout home:X0F:branches:Emulators/decaf-emu
 cd home:X0F:branches:Emulators/decaf-emu
 osc build

However this is not ideal for an actual development workflow as it uses the .tar.xz of the decaf repo from home:X0F:branches:Emulators/decaf-emu. Is there a way for me to have a local git checkout of decaf that I can do local changes to trivially and then build from using the build script from your osc repo?

v-fox commented 3 years ago

Is there a way for me to have a local git checkout of decaf that I can do local changes to trivially and then build from using the build script from your osc repo?

What I do to build particular snapshots is:

cd home:X0F:branches:Emulators/decaf-emu
# make shallow clone
git clone --depth 100 https://github.com/decaf-emu/decaf-emu.git
# fill it up
cd decaf-emu
git pull -f --recurse-submodules=yes -t -a --progress
cd ..

Then put target branch, tag or revision into <param name="revision">master</param> tag under service name="tar_scm" in _service. After, make new snapshot by osc service disabledrun. If it's currently altered branch in that repo then it will snapshot it with uncommited changes. There is obs_scm alternative to tar_scm that avoids compression of snapshot. Using run or localrun (depending on directive in _service) instead of doing manual disabledrun could include snapshotting into build stage but I newer tried that.