LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Cross-compile 32bit meson project from multilib'd system (https://www.linuxquestions.org/questions/slackware-14/cross-compile-32bit-meson-project-from-multilibd-system-4175692943/)

av2zeal 04-01-2021 02:48 AM

Cross-compile 32bit meson project from multilib'd system
 
Apologies if I got any terminology wrong.
I run Slackware64-current and have multilib deployed.
I have a program that I'm attempting to build that uses meson/ninja. I found the SBo meson template here. I successfully adapted it and built a 64-bit binary/package. However, I'm not sure what flags or setting that I need to change to build a 32-bit library. I attempted to change the CFLAGS and CXXFLAGS from "-O2 -fPIC" for the 64-bit build to "-O2 -march=i686 -mtune=i686", but it throws an error:
/meson.build:1:0: ERROR: Compiler ccache cc can not compile programs. Followed by:
A full log can be found at /tmp/SBo/MangoHud-0.6.1/build32/meson-logs/meson-log.txt
That log file has the following in it:
Main binary: /usr/bin/python3
Build Options: -Dprefix=/usr -Dinfodir=/usr/info -Dlibdir=/usr/lib -Dlocalstatedir=/var -Dmandir=/usr/man -Dsysconfdir=/etc -Dbuildtype=release
Python system: Linux
The Meson build system
Version: 0.56.2
Source dir: /tmp/SBo/MangoHud-0.6.1
Build dir: /tmp/SBo/MangoHud-0.6.1/build32
Build type: native build
Project name: MangoHud
Project version: v0.6.1
None of 'CC' are defined in the environment, not changing global flags.
Using 'CFLAGS' from environment with value: '-O2 -march=i686 -mtune=i686'
Using 'LDFLAGS' from environment with value: '-L/usr/lib'
None of 'CPPFLAGS' are defined in the environment, not changing global flags.
None of 'CC_LD' are defined in the environment, not changing global flags.
Sanity testing C compiler: ccache cc
Is cross compiler: False.
None of 'CC_LD' are defined in the environment, not changing global flags.
Sanity check compiler command line: ccache cc /tmp/SBo/MangoHud-0.6.1/build32/meson-private/sanitycheckc.c -o /tmp/SBo/MangoHud-0.6.1/build32/meson-private/s>
Sanity check compile stdout:

-----
Sanity check compile stderr:
cc1: error: CPU you selected does not support x86-64 instruction set

-----

../meson.build:1:0: ERROR: Compiler ccache cc can not compile programs.

As far as I can tell, I need to pass cross-compiler=yes and cpu=x86 somehow?
But when searching this, it seems that I need to build a cross-compiler file?
Am I over-complicating this?
Is the solution as simple as some missing flags?

BrunoLafleur 04-01-2021 07:45 AM

The flag that is missing is -m32.

Try to add it to your CFLAGS, CXXFLAGS and LDFLAGS arguments.

av2zeal 04-01-2021 09:37 AM

So simple! I knew I was overlooking something easy. Everything compiled as expected. Thank you Bruno!


All times are GMT -5. The time now is 04:32 PM.