debian crossbuild bacon
Aug 26, 2022 17:20:03 GMT 1
Post by bigbass on Aug 26, 2022 17:20:03 GMT 1
Hello
special note:
this not to interfere in any way with Peter and barryk's work
I understand it is a different situation completely
but it sparked a search
I just wanted to test that idea
but using the raspberry pi3
and see what it would take to do it
if possible using a debian based solution
cross build bacon debian based option
there are a lot of confusing
ways to explain that
but for me simply it means use another compiler
and libs that are NOT part of your native toolchain
and arch to compile something.
lets say you are using a RPI3 with arm
aarch64
there is no way you can compile a x86-64
binary because you are using arm of course!
the "normal way" would be compile on the system that has that
natively 100% is solved
but ... if you still want or have a need to build an x86-64
using a raspberry pi3
we need some more tools to do the job
and some trial and error to sort things out!
1) get the tools list
======================================
=======================================
will give you a list of different compilers
I chose amd64 as my end result binary compiler
=============================================
==============================================
I tried to find the simplest solution
NOT the official way to cross build and produce
an official debian package (maybe later if I find a reason do it with cmake)
I will use an odd folder name "Public" to the build just to
show it all in a clean place
===============================================
# manual pre step
# we get the official bacon.bac from version 4.5.0 source build
# and copy it to Public
# generate the bacon c code in the folder called build
=================================================
#now we redirect the native compier to use a new
#compiler for x86_64 remember we are on a raspberry pi3 still
================================================
bacon: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a733a7d09bb64e2712d6e22b8cd8c8378ad75b4b, for GNU/Linux 3.2.0, stripped
this is the short result *after several failed tries
and it seems to be clean
without any compiler errors or warnings
Joe
++++++++++++++++++++++++++++++++++++++++
that was fun lets try with
crossbuild-essential-i386
file bacon
bacon: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=caeda1fdc54c35df89a71618d0921cef6ecf7d5e, for GNU/Linux 3.2.0, stripped
special note:
this not to interfere in any way with Peter and barryk's work
I understand it is a different situation completely
but it sparked a search
I just wanted to test that idea
but using the raspberry pi3
and see what it would take to do it
if possible using a debian based solution
cross build bacon debian based option
there are a lot of confusing
ways to explain that
but for me simply it means use another compiler
and libs that are NOT part of your native toolchain
and arch to compile something.
lets say you are using a RPI3 with arm
uname -m
aarch64
there is no way you can compile a x86-64
binary because you are using arm of course!
the "normal way" would be compile on the system that has that
natively 100% is solved
but ... if you still want or have a need to build an x86-64
using a raspberry pi3
we need some more tools to do the job
and some trial and error to sort things out!
1) get the tools list
======================================
apt-cache search crossbuild-essential
=======================================
will give you a list of different compilers
I chose amd64 as my end result binary compiler
=============================================
sudo apt-get install crossbuild-essential-amd64
==============================================
I tried to find the simplest solution
NOT the official way to cross build and produce
an official debian package (maybe later if I find a reason do it with cmake)
I will use an odd folder name "Public" to the build just to
show it all in a clean place
===============================================
# manual pre step
# we get the official bacon.bac from version 4.5.0 source build
# and copy it to Public
# generate the bacon c code in the folder called build
cd Public
bacon -np -d build bacon.bac
=================================================
#now we redirect the native compier to use a new
#compiler for x86_64 remember we are on a raspberry pi3 still
cd build
#COMPILE
/usr/bin/x86_64-linux-gnu-gcc-10 -c bacon.bac.c
#BUILD add libm.so from the x86_64 crossbuild
/usr/bin/x86_64-linux-gnu-gcc-10 -o bacon bacon.bac.o /usr/x86_64-linux-gnu/lib/libm.so
#STRIP
/usr/x86_64-linux-gnu/bin/strip bacon
================================================
file bacon
bacon: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a733a7d09bb64e2712d6e22b8cd8c8378ad75b4b, for GNU/Linux 3.2.0, stripped
this is the short result *after several failed tries
and it seems to be clean
without any compiler errors or warnings
Joe
++++++++++++++++++++++++++++++++++++++++
that was fun lets try with
crossbuild-essential-i386
file bacon
bacon: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=caeda1fdc54c35df89a71618d0921cef6ecf7d5e, for GNU/Linux 3.2.0, stripped