FEX icon indicating copy to clipboard operation
FEX copied to clipboard

Thunks: Update to use the Guest Build System

Open skmp opened this issue 2 years ago • 2 comments

Overview

  • Compiles thunks using the toolchain files created for FLT in #1891
  • Adds support for per-guest arch thunks in the build system, with no actual support in the thunks themselves at this point (inspired/iterated from #1828)
  • Cleanups the thunks cmake files, with the future intention of sharing the cmake code between guest and host.

Builds on top of #1891.

Blocked on #1901 (needs to be rebased on top)

skmp avatar Aug 09 '22 17:08 skmp

This has cryptic build issues with the unreviewed code introduced in #1868.

skmp avatar Aug 15 '22 13:08 skmp

Alright.

Converted thunkgen to a clang++ plugin, instead of a custom tool, so that it picks up the headers correctly.

However,

  • clang++ crashes in x86 and 8.2 runners. That's most likely me using it incorrectly.
  • clang++ does not recognise the -fplugin-arg-XXX arguments in 8.4 (ubu20.04). This is peculiar as it does recognise the -fplugin one. I'll try with lower case.

Finally,

  • 8.0 runner works.
  • generator invocation times are also somehow lower now for generating, for some reason.

Notes

  • The code goes through many hoops to make things depend correctly, loads of TIL.

skmp avatar Aug 17 '22 10:08 skmp

Once you're done fixing the remaining issues you mentioned, could you do a rebase pass over this to split the PR into more easily digestible patches for review?

neobrain avatar Aug 18 '22 08:08 neobrain

@neobrain yes, def. This is rebased on top of #1891 (and needs that revived and merged before it is considered)

skmp avatar Aug 18 '22 08:08 skmp

I cannot reproduce the armv8.4 or x64 errors in my setups. Not sure what is happening here.

skmp avatar Aug 20 '22 09:08 skmp

Needed packages: sudo apt install libc6-dev-i386-cross libc6-dev-i386-cross

skmp avatar Aug 21 '22 13:08 skmp

I'm assuming the duplicate libc6-dev-i386-cross in that command was actually libc6-dev-amd64-cross. All runners already had both packages installed.

Sonicadvance1 avatar Aug 22 '22 03:08 Sonicadvance1

So uh

/usr/lib/llvm-14/bin/clang --target=i386-linux-gnu --sysroot=/lib/i686-linux-gnu --sysroot=/usr/lib/i686-linux-gnu  -fuse-ld=lld -L/usr/i686-linux-gnu/lib -L/usr/lib/i686-linux-gnu test.c -print-search-dirs

programs: =/usr/lib/llvm-14/bin
libraries: =/usr/lib/llvm-14/lib/clang/14.0.0

and

clang --target=i386-linux-gnu --sysroot=/lib/i686-linux-gnu --sysroot=/usr/lib/i686-linux-gnu  -fuse-ld=lld -L/usr/i686-linux-gnu/lib -L/usr/lib/i686-linux-gnu test.c -print-search-dirs

programs: =/usr/bin:/usr/lib/llvm-14/bin:/usr/bin/../lib/gcc-cross/i686-linux-gnu/11/../../../../i686-linux-gnu/bin
libraries: =/usr/lib/llvm-14/lib/clang/14.0.0:/usr/bin/../lib/gcc-cross/i686-linux-gnu/11:/usr/bin/../lib/gcc-cross/i686-linux-gnu/11/../../../../i686-linux-gnu/lib

and

skmp@mangie:~/projects/FEX/build$ which clang
/usr/bin/clang
skmp@mangie:~/projects/FEX/build$ ls -lah /usr/bin/clang
lrwxrwxrwx 1 root root 24 Απρ   1 23:51 /usr/bin/clang -> ../lib/llvm-14/bin/clang

skmp avatar Aug 22 '22 04:08 skmp

Looks like the same executable of clang behaves differently when in /usr/bin/clang and when in /usr/lib/llvm-14/bin/clang

skmp avatar Aug 22 '22 05:08 skmp

@Sonicadvance1 can you check that x64 and ARMv8.2 are using the same libclang as they are using for clang++?

Looks like some progress was made also on ARMv8.4, now just -ldl missing from somewhere

skmp avatar Aug 22 '22 06:08 skmp

(Closing this as there is an ongoing powergrab by @Sonicadvance1, I will migrate my work to https://github.com/skmp/fex-emu-ng.git)

skmp avatar Sep 01 '22 14:09 skmp