Bug 108922

Summary: Meson: crosscompiling with a crossfile fails
Product: Mesa Reporter: Alexandre Demers <alexandre.f.demers>
Component: OtherAssignee: mesa-dev
Status: RESOLVED INVALID QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
i915 platform: i915 features:
Attachments: crossfile

Description Alexandre Demers 2018-12-03 08:04:33 UTC
SI'm not sure it is a bug per se since there is a workaround that I'm suggesting at the end. However, this clearly doesn't follow meson's doc about crosscompilation.

I've been using a script to build mesa easily. I only have to add a few arguments to crosscompile, bisect, etc. Now, I'm in the process of moving this script from autotools to meson. Everything is being configured and is compiling fine when build from x86_64 (build) to x86_64 (host). To follow meson's doc about crosscompilation, I've created a simple crossfile (I'll attach it). That way, meson knows I'm building on a x86_64 build to a x86 host. Adding a bit of debug outputs shows that the build is detected as x86_64 and the host as x86. However, this fails miserably:

[40/2045] Compiling C object 'src/mapi/glapi/src@mapi@glapi@@glapi_static@sta/.._entry.c.o'.
FAILED: src/mapi/glapi/src@mapi@glapi@@glapi_static@sta/.._entry.c.o 
{standard input}: Assembler messages:
{standard input}:8: Error: invalid instruction suffix for `pop'
{standard input}:10: Error: @GOTNTPOFF reloc is not supported with 64-bit output format
{standard input}:10: Error: junk `@GOTNTPOFF' after expression
ninja: build stopped: subcommand failed.
make failed and returned exitcode 1

It happens even if I set (or not) the following:
  export CFLAGS="-m32"
  export CXXFLAGS="-m32"

Now, instead of using the crossfile, if I set the following (which is being used in Archlinux's lib32 mesa package), it will build fine:
  export CC="gcc -m32"
  export CXX="g++ -m32"
This is being detected as an x86 build to an x86 host, which is mostly a workaround than a real fix since we are overcoming the x86_64 build -> x86 host situation.

Am I missing something?
Comment 1 Alexandre Demers 2018-12-03 08:05:57 UTC
Created attachment 142695 [details]

crossfile used to crosscompile mesa from a x86_64 build to a x86 host.
Comment 2 Eric Engestrom 2018-12-03 09:00:58 UTC
You tried adding the compiler `-m32` flag (through CFLAGS), but you were still missing the linker `-m32` flag (LDFLAGS).

Try using the cross file I sent on the mailing list last week:
(we need to discuss something, but then I'll push it and it will be available on https://mesa3d.org/meson.html)

BTW, with meson it is not recommended to use env vars, but to use meson flags and settings, as it handles those better.
Comment 3 Alexandre Demers 2018-12-03 16:52:26 UTC
It seems I missed last week's memo about the cross file. ;) I'll try it and I'll update this bug accordingly in the next few days.

Thank you about the cue on env var VS meson's flags, I'm new to meson and your comment will be helpful.
Comment 4 Alexandre Demers 2018-12-04 06:05:18 UTC
Adding meson's flags instead of setting the environment variables did the trick. I'm closing this bug.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.