Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build on ARMhf7 #32

Closed
itshaadi opened this issue Aug 11, 2018 · 17 comments
Closed

build on ARMhf7 #32

itshaadi opened this issue Aug 11, 2018 · 17 comments

Comments

@itshaadi
Copy link
Contributor

both mpv and pepper_49 support ARM. so I tried to build this project with libraries under /pepper_49/lib/glibc_arm although lppapi is missing so I copied the one under linux_host.

and to put everyting together. I used electron 1.8.7 on RaspberryPi 3 (armhf7)
somehow it faild to even load the page. so I used 2.0.7. now it says "couldn't load the plugin". so any advice?

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

so I copied the one under linux_host

This shouldn't work because ISA is different:

$ cd pepper_49/lib 
$ ar p linux_host/Release/libppapi_cpp.a | file - 
/dev/stdin: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
$ ar p glibc_arm/Release/libppapi_cpp.a | file -
/dev/stdin: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), with debug_info, not stripped

Sadly I don't have ARM devices and emulation probably would be slow, so I have some wild guesses instead:

so I used 2.0.7

It doesn't work properly on Linux, see #29, you need 1.x or 3.x. It shouldn't affect the process of plugin loading though and redirecting output to /dev/null might help but you better avoid that issue.

now it says "couldn't load the plugin"

Enable logging and check the logs:

$ ELECTRON_ENABLE_LOGGING=1 MPVJS_TERMINAL=1 MPVJS_VERBOSE=1 npm run example -- --v=1

What's the output of:

$ file build/Release/mpvjs.node
$ ldd build/Release/mpvjs.node 

You also need to:

$ npm run use-system-ffmpeg

on Linux hosts but at least mpv should load (you should see it in the log).

@itshaadi
Copy link
Contributor Author

by lppapi I meant libppapi.a. the original problem was that node-gyp couldn't build the project because this file was missing. so I copied the one under linux_host into glibc_arm and proceeded with no error.

the output of file build/Release/mpvjs.node

build/Release/mpvjs.node: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=4a48d9d94bf9cefb6ad40487850671775f7f0dd1, not stripped

and the noticeable info about ldd build/Release/mpvjs.node is: (see more)

libppapi_cpp.so => not found
libppapi_gles2.so => not found

and logs from electron

[2485:0811/174855.012375:ERROR:bus.cc(395)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[2485:0811/174900.944129:ERROR:service_manager.cc(156)] Connection InterfaceProviderSpec prevented service: content_plugin from binding interface: memory_instrumentation::mojom::Coordinator exposed by: content_browser
[2552:0811/174900.969760:ERROR:ppapi_thread.cc(312)] Failed to load Pepper module from build/Release/mpvjs.node (error: libppapi_cpp.so: cannot open shared object file: No such file or directory)

I didn't messed with binding.gyp that much, just changed #L31 to $(NACL_SDK_ROOT)/lib/glibc_arm/Release

and electron 3.x is not available for ARM yet. and 1.x has some other problems with starting up regardless of this project so I left that aside for another time. so far 2.0.7 had no warnings or error. maybe #29 is not related to ARM based machines?

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

so I copied the one under linux_host into glibc_arm

Libs in linux_host are compiled for x86-64, in glibc_arm for arm, you can't do that.

Though seems like mpv.js plugin doesn't use any symbols from libppapi, that's why it worked for you (was needed just to make compiler happy about missed -l). I commited fixed binding.gyp, check it out.

libppapi_cpp.so => not found
libppapi_gles2.so => not found

That's the actual problem. They were compiled dynamically. Try to run example with:

export LD_LIBRARY_PATH="$NACL_SDK_ROOT/lib/glibc_arm/Release"

Seems like they're linked statically on x86 Linux because linux_host doesn't contain .so for ppapi_cpp and ppapi_gles. Probably some compiler flag is needed to fix that. In meantime you can just remove .so files from lib/glibc_arm/Release.

@itshaadi
Copy link
Contributor Author

itshaadi commented Aug 11, 2018

with .so files removed node-gyp rebuild failed with -fPIC error.

/usr/bin/ld: /home/pi/nacl_sdk/pepper_49/lib/glibc_arm/Release/libppapi_cpp.a(graphics_3d_arm.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/pi/nacl_sdk/pepper_49/lib/glibc_arm/Release/libppapi_cpp.a: error adding symbols: Bad value

Do I have to build pepper_49 from source files located in /nacl_sdk/pepper_49/src? if so then it's a dead end.
I tried with TOOLCHAIN=glibc NACL_ARCH=arm CHROME_PATH=/usr/bin/chromium-browser make

make -C ppapi_gles2  all
make[1]: Entering directory '/home/pi/nacl_sdk/pepper_49/src/ppapi_gles2'
objdump: /usr/bin/chromium-browser: File format not recognized
  CC   glibc/Release/gl2ext_ppapi_arm.o
/bin/sh: 1: /home/pi/nacl_sdk/pepper_49/toolchain/linux_arm_glibc/bin/arm-nacl-gcc: Exec format error
Makefile:26: recipe for target 'glibc/Release/gl2ext_ppapi_arm.o' failed
make[1]: *** [glibc/Release/gl2ext_ppapi_arm.o] Error 2
make[1]: Leaving directory '/home/pi/nacl_sdk/pepper_49/src/ppapi_gles2'
Makefile:63: recipe for target 'ppapi_gles2_ALL_TARGET' failed
make: *** [ppapi_gles2_ALL_TARGET] Error 2

also ARM libs in alternate pepper archives are the same.

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Do I have to build pepper_49 from source files

Yea, seems like it. Did you try LD_LIBRARY_PATH btw?

Try make TOOLCHAIN=linux instead, to build linux_host ARM binaries.
I tried to build glibc_x86_64 on my x86 machine but it doesn't produce correct PIC libraries either. Probably because it's for NaCl, not the normal host toolchain.

Exec format error

Seems like arm-nacl-gcc is cross compiler, i.e. it should be run on x86 Linux machine, to produce glibc arm binaries.

@itshaadi
Copy link
Contributor Author

Did you try LD_LIBRARY_PATH btw?

yes only this time

libc.so.0.1 => not found
ld-nacl-arm.so.1 => not found

Try make TOOLCHAIN=linux instead, to build linux_host ARM binaries.

I did it

make TOOLCHAIN=linux will build linux_host ARM binaries. but pepper_49/src/nacl_io has some warrnings that are treated as error.

make[1]: Entering directory '/home/pi/nacl_sdk/pepper_49/src/nacl_io'
CHROME_PATH is undefined, and google-chrome not found in PATH, nor /usr/bin/google-chrome.
  CXX  linux/Release/httpfs/http_fs_node.o
httpfs/http_fs_node.cc: In function ‘bool nacl_io::{anonymous}::ParseContentRange(const StringMap_t&, off_t*, off_t*, off_t*)’:
httpfs/http_fs_node.cc:112:41: error: format ‘%lli’ expects argument of type ‘long long int*’, but argument 3 has type ‘off_t* {aka long int*}’ [-Werror=format=]
                       &entity_length_int);
                                         ^
httpfs/http_fs_node.cc:112:41: error: format ‘%lli’ expects argument of type ‘long long int*’, but argument 4 has type ‘off_t* {aka long int*}’ [-Werror=format=]
httpfs/http_fs_node.cc:112:41: error: format ‘%lli’ expects argument of type ‘long long int*’, but argument 5 has type ‘off_t* {aka long int*}’ [-Werror=format=]
httpfs/http_fs_node.cc: In member function ‘nacl_io::Error nacl_io::HttpFsNode::DownloadPartial(const nacl_io::HandleAttr&, void*, off_t, int*)’:
httpfs/http_fs_node.cc:454:33: error: format ‘%lli’ expects argument of type ‘long long int’, but argument 4 has type ‘off_t {aka long int}’ [-Werror=format=]
            attr.offs + count - 1);
                                 ^
httpfs/http_fs_node.cc:454:33: error: format ‘%lli’ expects argument of type ‘long long int’, but argument 5 has type ‘long int’ [-Werror=format=]
cc1plus: all warnings being treated as errors
Makefile:153: recipe for target 'linux/Release/httpfs/http_fs_node.o' failed
make[1]: *** [linux/Release/httpfs/http_fs_node.o] Error 1
make[1]: Leaving directory '/home/pi/nacl_sdk/pepper_49/src/nacl_io'
Makefile:63: recipe for target 'nacl_io_ALL_TARGET' failed
make: *** [nacl_io_ALL_TARGET] Error 2

disable them by changing the CFLAGS in /pepper_49/src/nacl_io/Makefile

CFLAGS += -Wno-error

only now there are some issues with electron.(log file)

.
.
.

13019:0811/231329.629497:INFO:CONSOLE(0)] "[.PPAPIContext]GL ERROR :GL_INVALID_VALUE : glTexImage2D: invalid internal_format GL_RGBA16_EXT", source: file:///home/pi/mpvjs/example/index.html (0)

/home/pi/mpvjs/node_modules/electron/dist/electron --type=ppapi --no-sandbox --ppapi-flash-args --lang=en-US --v=1 --service-request-channel-token=6AD95F96ECD95D946608506DD8E0F123: symbol lookup error: build/Release/mpvjs.node: undefined symbol: _ZNK2pp3Var8AsStringEv

[13019:0811/231340.958086:VERBOSE1:ppapi_plugin_process_host.cc(496)] PpapiPluginProcessHost::OnChannelError()
[13019:0811/231340.959065:VERBOSE1:ppapi_plugin_process_host.cc(465)] ppapi plugin process crashed.

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

I did it

Nice, so we can provide instructions for arm in readme too, if everything will eventually work.

disable them by changing

You can build only required ppapi_cpp and ppapi_gles2 by passing PROJECTS="ppapi_cpp ppapi_gles2" to make btw.

build/Release/mpvjs.node: undefined symbol: _ZNK2pp3Var8AsStringEv

Show the output of

$ nm -D build/Release/mpvjs.node | grep _ZNK2pp3Var8AsStringEv
$ nm libppapi_cpp.a | grep _ZNK2pp3Var8AsStringEv

@itshaadi
Copy link
Contributor Author

for build/Release/mpvjs.node returned U _ZNK2pp3Var8AsStringEv
and nothing for libppapi_cpp.a

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Can you send me that libppapi_cpp.a?

@itshaadi
Copy link
Contributor Author

libppapi_cpp.zip

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Ah, I get it! It uses C++11 ABI:

$ nm libppapi_cpp.a | grep Var8AsString
         U _ZNK2pp3Var8AsStringB5cxx11Ev
         U _ZNK2pp3Var8AsStringB5cxx11Ev
         U _ZNK2pp3Var8AsStringB5cxx11Ev
00001050 T _ZNK2pp3Var8AsStringB5cxx11Ev

Remove

"defines": ["_GLIBCXX_USE_CXX11_ABI=0"],

line from binding.gyp and rebuild plugin. Or add -D_GLIBCXX_USE_CXX11_ABI=0 to pepper's CFLAGS and rebuild linux_host. It would be more consistent because default linux_host binaries don't use C++11 ABI.

@itshaadi
Copy link
Contributor Author

everything seems to be working as expected. although CPU usage is really high, about 98%. and video playback is super slow. but the main issue is solved. I might have to install Arch or Raspbian Lite and use X to open electron instead of a desktop environment. that will save some resource. also #25 occurred but it's fine I will test everything on 1.8.7 later. no signs of #29 though. we can now add my files to prebuilt binaries. what node version did you use to build it? I am using 10.2.0

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Nice, I'm glad it works for you. Closing, will add readme instructions later.

CPU usage is really high, about 98%. and video playback is super slow

Need to enable hardware decoding (#5) to fix that, but I guess it's not trivial.

also #25 occurred

It should be purely cosmetic.

no signs of #29 though

That's nice.

we can now add my files to prebuilt binaries

Sure, send me .tar.gz prebuild.

what node version did you use to build it?

I have LTS branch right now but it shouldn't matter because plugin doesn't need any node's symbols. I'm using

node_modules/.bin/prebuild -t 1.0.0 --strip

command to build plugin against fixed node version.

@Kagami Kagami closed this as completed Aug 11, 2018
@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

I used electron 1.8.7 on RaspberryPi 3 (armhf7) somehow it faild to even load the page.

It seems to be a known problem btw: electron/electron#12329

@itshaadi
Copy link
Contributor Author

tested on 1.7.9 and 2.0.7
mpv.js-v0.3.0-linux-armhf7.tar.gz

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Nice, thank you, added to 0.3.0 github release. If I understand everything correcty, the name prebuild-install expects should be mpv.js-v0.3.0-node-v42-armv7l-ia32.tar.gz

Could you test npm install in fresh repo clone, would that work?

I probably need to setup ARMv7 VM anyway, in case if I would update code of the plugin often.

@Kagami
Copy link
Owner

Kagami commented Aug 11, 2018

Hm, no, it should be mpv.js-v0.3.0-node-v42-linux-arm.tar.gz. Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants