nowrep / obs-vkcapture

OBS Linux Vulkan/OpenGL game capture
GNU General Public License v2.0
519 stars 25 forks source link

ppc64le build fails #109

Closed darkbasic closed 1 year ago

darkbasic commented 1 year ago

I'm trying to build obs-vkcapture-1.2.1 on Gentoo Linux ppc64le on my Raptor CS Talos 2 workstation, but it fails:

[3/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
FAILED: CMakeFiles/obs_glcapture.dir/src/dlsym.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c:20:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:67:4: error: #error neither __elf32 nor __elf64 is defined
   67 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
[4/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dlinux_vkcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build -isystem /usr/include/obs -isystem /usr/lib64/libffi/include  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -DNO_WARN_X86_INTRINSICS-DHAVE_OBSCONFIG_H -mvsx -std=gnu11 -MD -MT CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o -MF CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o.d -o CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build/screencopy_unstable_v1.c
<command-line>: warning: ISO C99 requires whitespace after the macro name
[5/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
FAILED: CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:19:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:67:4: error: #error neither __elf32 nor __elf64 is defined
   67 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:33:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
   33 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next);
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:416:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
  416 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next)
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c: In function ‘eh_set_rela_plt’:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:450:13: warning: implicit declaration of function ‘eh_find_next_dyn’ [-Wimplicit-function-declaration]
  450 |         if (eh_find_next_dyn(obj, DT_PLTRELSZ, p, &relasize))
      |             ^~~~~~~~~~~~~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:454:34: warning: implicit declaration of function ‘ELFW_R_SYM’; did you mean ‘ELF64_R_SYM’? [-Wimplicit-function-declaration]
  454 |                 if (!obj->symtab[ELFW_R_SYM(rela[i].r_info)].st_name)
      |                                  ^~~~~~~~~~
      |                                  ELF64_R_SYM

Full build log: build.log

SimpleScreenRecorder had similar errors and they ended up disabling GLINJECT, which defeats the point of this plugin: https://github.com/MaartenBaert/ssr/issues/533

nowrep commented 1 year ago

Please try this

diff --git a/src/elfhacks.h b/src/elfhacks.h
index 8da3059..54857ca 100644
--- a/src/elfhacks.h
+++ b/src/elfhacks.h
@@ -56,6 +56,13 @@ extern "C" {
 # define __elf32
 #endif

+#ifdef __ppc64__
+# define __elf64
+#endif
+#ifdef __ppc__
+# define __elf32
+#endif
+
 #ifdef __elf64
 # define ELFW_R_SYM ELF64_R_SYM
 # define ElfW_Sword Elf64_Sxword
darkbasic commented 1 year ago
[3/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
FAILED: CMakeFiles/obs_glcapture.dir/src/dlsym.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c:20:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:74:4: error: #error neither __elf32 nor __elf64 is defined
   74 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
[4/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dlinux_vkcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build -isystem /usr/include/obs -isystem /usr/lib64/libffi/include  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -DNO_WARN_X86_INTRINSICS-DHAVE_OBSCONFIG_H -mvsx -std=gnu11 -MD -MT CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o -MF CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o.d -o CMakeFiles/linux-vkcapture.dir/screencopy_unstable_v1.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build/screencopy_unstable_v1.c
<command-line>: warning: ISO C99 requires whitespace after the macro name
[5/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
FAILED: CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:19:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:74:4: error: #error neither __elf32 nor __elf64 is defined
   74 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:33:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
   33 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next);
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:416:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
  416 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next)
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c: In function ‘eh_set_rela_plt’:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:450:13: warning: implicit declaration of function ‘eh_find_next_dyn’ [-Wimplicit-function-declaration]
  450 |         if (eh_find_next_dyn(obj, DT_PLTRELSZ, p, &relasize))
      |             ^~~~~~~~~~~~~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:454:34: warning: implicit declaration of function ‘ELFW_R_SYM’; did you mean ‘ELF64_R_SYM’? [-Wimplicit-function-declaration]
  454 |                 if (!obj->symtab[ELFW_R_SYM(rela[i].r_info)].st_name)
      |                                  ^~~~~~~~~~
      |                                  ELF64_R_SYM

Build log: build.log

nowrep commented 1 year ago
diff --git a/src/elfhacks.h b/src/elfhacks.h
index 8da3059..54857ca 100644
--- a/src/elfhacks.h
+++ b/src/elfhacks.h
@@ -56,6 +56,13 @@ extern "C" {
 # define __elf32
 #endif

+#ifdef __ppc64le__
+# define __elf64
+#endif
+#ifdef __ppc__
+# define __elf32
+#endif
+
 #ifdef __elf64
 # define ELFW_R_SYM ELF64_R_SYM
 # define ElfW_Sword Elf64_Sxword
darkbasic commented 1 year ago
[3/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
FAILED: CMakeFiles/obs_glcapture.dir/src/dlsym.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -MF CMakeFiles/obs_glcapture.dir/src/dlsym.c.o.d -o CMakeFiles/obs_glcapture.dir/src/dlsym.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/dlsym.c:20:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:74:4: error: #error neither __elf32 nor __elf64 is defined
   74 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
[4/15] /usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
FAILED: CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o 
/usr/bin/powerpc64le-unknown-linux-gnu-gcc -DENABLE_WAYLAND=1 -Dobs_glcapture_EXPORTS -I/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1_build  -O2 -pipe -mcpu=power9 -mtune=power9 -fPIC -std=gnu11 -MD -MT CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -MF CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o.d -o CMakeFiles/obs_glcapture.dir/src/elfhacks.c.o -c /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c
In file included from /var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:19:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.h:74:4: error: #error neither __elf32 nor __elf64 is defined
   74 | #  error neither __elf32 nor __elf64 is defined
      |    ^~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:33:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
   33 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next);
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:416:37: error: unknown type name ‘ElfW_Sword’; did you mean ‘Elf64_Sword’?
  416 | int eh_find_next_dyn(eh_obj_t *obj, ElfW_Sword tag, int i, ElfW(Dyn) **next)
      |                                     ^~~~~~~~~~
      |                                     Elf64_Sword
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c: In function ‘eh_set_rela_plt’:
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:450:13: warning: implicit declaration of function ‘eh_find_next_dyn’ [-Wimplicit-function-declaration]
  450 |         if (eh_find_next_dyn(obj, DT_PLTRELSZ, p, &relasize))
      |             ^~~~~~~~~~~~~~~~
/var/tmp/portage/media-video/obs-vkcapture-1.2.1/work/obs-vkcapture-1.2.1/src/elfhacks.c:454:34: warning: implicit declaration of function ‘ELFW_R_SYM’; did you mean ‘ELF64_R_SYM’? [-Wimplicit-function-declaration]
  454 |                 if (!obj->symtab[ELFW_R_SYM(rela[i].r_info)].st_name)
      |                                  ^~~~~~~~~~
      |                                  ELF64_R_SYM

build.log

nowrep commented 1 year ago

Just add # define __elf64 there

darkbasic commented 1 year ago

It compiles and it works!

nowrep commented 1 year ago

Can you figure out what compiler define is there for your architecture? Neither __ppc64__ nor __ppc64le__ seem to work.

darkbasic commented 1 year ago
diff --git a/src/elfhacks.h b/src/elfhacks.h
index 8da3059..54857ca 100644
--- a/src/elfhacks.h
+++ b/src/elfhacks.h
@@ -56,6 +56,13 @@ extern "C" {
 # define __elf32
 #endif

+#ifdef __powerpc64__
+# define __elf64
+#endif
+#ifdef __powerpc__
+# define __elf32
+#endif
+
 #ifdef __elf64
 # define ELFW_R_SYM ELF64_R_SYM
 # define ElfW_Sword Elf64_Sxword

This works.

nowrep commented 1 year ago

Great, can you make a PR?

darkbasic commented 1 year ago

Done