Source: llvm-toolchain-21
Version: 1:21.1.8-1
Followup-For: Bug #1116212
X-Debbugs-Cc: [email protected]

I am routingly cross-compiling mesa for i386 and amd64, on amd64 system.

And by routinly I mean weekly for about 5 years.

https://gist.github.com/baryluk/1041204eff4cc4fad6f1508afe67b562

libllvmXY itself can be coinstalled.

The primary issue are header files. These cannot be easily coinstalled
indeed.

However, I found that header files are actually all the same really, and
anything specific to arch is in the headers changed conditionally.

So installing libllvm-XY-dev:amd64 and then pointing i386 to use them
anyway works.

$ dpkg -l|grep -E 'llvm-21|llvm21'
ii  libllvm21:amd64                                          1:21.1.8-1         
                       amd64        Modular compiler and toolchain 
technologies, runtime library
ii  libllvm21:i386                                           1:21.1.8-1         
                       i386         Modular compiler and toolchain 
technologies, runtime library
ii  libllvm21-dbgsym:amd64                                   1:21.1.8-1         
                       amd64        debug symbols for libllvm21
ii  libllvm21-dbgsym:i386                                    1:21.1.8-1         
                       i386         debug symbols for libllvm21
ii  llvm-21                                                  1:21.1.8-1         
                       amd64        Modular compiler and toolchain technologies
ii  llvm-21-dev                                              1:21.1.8-1         
                       amd64        Modular compiler and toolchain 
technologies, libraries and headers
ii  llvm-21-linker-tools                                     1:21.1.8-1         
                       amd64        Modular compiler and toolchain technologies 
- Plugins
ii  llvm-21-runtime                                          1:21.1.8-1         
                       amd64        Modular compiler and toolchain 
technologies, IR interpreter
ii  llvm-21-tools                                            1:21.1.8-1         
                       amd64        Modular compiler and toolchain 
technologies, tools


In meson I do:

meson-cross-i386.ini:

[binaries]
c = '/usr/bin/i686-linux-gnu-gcc-{GCCVERSION}'
cpp = '/usr/bin/i686-linux-gnu-g++-{GCCVERSION}'
ar = '/usr/bin/i686-linux-gnu-gcc-ar-{GCCVERSION}'
strip = '/usr/bin/i686-linux-gnu-strip'
pkg-config = '/usr/bin/i686-linux-gnu-pkg-config'
; We are cheating here. We are using 64-bit llvm-config. But we stars align
; it should work (same compiler and linker flags will be used).
llvm-config = '/usr/bin/llvm-config-{LLVMVERSION}'
; llvm-config = '/usr/lib/llvm-{LLVMVERSION}/bin/llvm-config'
rust_ld = '/usr/bin/i686-linux-gnu-gcc-{GCCVERSION}'
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
; -C linker=gcc -C link-arg=-m32
; set BINDGEN_EXTRA_CLANG_ARGS to either --target=i686-unknown-linux-gnu or 
-target i686-unknown-linux-gnu

[built-in options]
c_args = ['-m32']
c_link_args = ['-m32']
cpp_args = ['-m32']
cpp_link_args = ['-m32']

[host_machine]
system = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'


While this is little hacky - I am using 64-bit llvm-config, but because
it gives same results as 32-bit one, it kind of just works, and I had no
issues ever with this (yet) for years.

Give it a try. No need for containers or chroots.

However, I do agree, that having the -dev packages coinstallable, either
by marking them `Multi-Arch :same` (if possible), or in separate
location, would be nice.

It would be also desirable to put llvm-config and be able to call
different arch ones easily (if it is some script it should just work
modulo some variable changes, alternativly running it via qemu binfmt
handler). I belive I did open a bug about llvm-config and multi-arch
few years ago, but I cannot find it now.


Regards,
Witold


-- System Information:
Debian Release: forky/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.19.0-rc1 (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_CPU_OUT_OF_SPEC, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Reply via email to