vsimon / webrtcbuilds

Getting started with WebRTC natively is no easy picnic. The goal of webrtcbuilds is to provide a single standalone WebRTC static library and package.
BSD 3-Clause "New" or "Revised" License
202 stars 164 forks source link

Cross-compiling to ARM64 uses incorrect sysroot - resulting binary invalid #100

Closed eanders-ms closed 4 years ago

eanders-ms commented 4 years ago

Hello. This is probably not a problem with your scripts, but I am unsure where else to turn. My environment is Ubuntu 18.04, cross-compiling to ARM64, my first attempt informs me I must install the sysroot, which is expected, but it specifies the wrong sysroot. It directs me to install the amd64 sysroot, as illustrated:

$ ./build.sh -b branch-heads/71 -t android -c arm64 -n Release
...
Missing sysroot (//build/linux/debian_sid_amd64-sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=amd64

Paths I've taken at this point:

Option 1. Install the amd64 sysroot and let the build complete.

The build succeeds, but the resultant library is not a valid target for Android. Inspecting it, it is clear that it contains a mix of amd64 and arm64 objects. Sysroot objects are in amd64 format:

File: libwebrtc_full.a(cxa_default_handlers.o)
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           Advanced Micro Devices X86-64

Whereas library-level objects in the same file are arm64:

File: libwebrtc_full.a(mediastream.o)
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           AArch64

Option 2. Install the arm64 sysroot (and remote the amd64 sysroot), and try the build.

This sysroot is not accepted and I get the missing sysroot error above.

Can you advise how to engage the correct sysroot when cross compiling to ARM64, or perhaps could direct me to the appropriate channel or forum for this kind of issue? Any help is appreciated.

Thank you!

eanders-ms commented 4 years ago

Or perhaps I can exclude the sysroot objects entirely? Could that be a valid approach?

eanders-ms commented 4 years ago

Oh, looks like I wasn't re-fetching sources for the Android platform (I'd commented that line in the script to expedite rebuilds). I'll try that.

eanders-ms commented 4 years ago

I think the issue is elsewhere. Closing this.