Bug#1094030: RFS: freebasic/1.10.1+ds-1 [ITP] -- Compiler for the FreeBASIC language
Hi Julien,
On 25/01/2025 22:07, Julien Plissonneau Duquène wrote:
Le 2025-01-25 17:02, Ahmad Khalifa a écrit :
Is `fbc` able to successfully cross-compile itself, or do you need to
bootstrap each architecture separately?
It does cross-compile. For the intermediate stage, any fbc compiler can
produce any target. And for the final stage, it knows "some" of the
various cross-gcc compilers (i.e. knows about i686-linux-gnu-gcc and
friends).
However, I haven't tested that too much, I'm sticking with BUILD=HOST.
I have an old version where the build was two stages, I can go back to
that and switch to compiling bootstrap source into bootstrap compiler.
Likely abandoning git as a source and just using 3 orig tarballs:
source + bootstrap source + html docs.
Do you see any issues with that approach?
That's the general idea but it needs to be refined a bit. What I would
do here is first locally regenerate the bootstrap source code using
either a prebuilt compiler (full or bootstrap) from upstream, or a
bootstrap compiler built from the (generated) bootstrap source code from
upstream. You only need to generate that bootstrap code for the linux
targets. Then you check if it's the same (or close enough) as the
bootstrap source code provided by upstream. If no, investigate why. Then
you (still locally) build a full compiler with it, regenerate the
bootstrap source code with that full compiler, and compare it with the
generated sources of the previous step. It should now be exactly
identical. If yes, you can then commit that locally generated source
code and make (as you suggested) a separate third source archive of it.
That's the bootstrap source code, generated by yourself, that will then
be used in the two stage build of the package.
This was very helpful and in hindsight, seems like the better approach.
I kept it all as part of the package build and even though there are
much shorter ways to get to a working compiler, this is much more
reproducible by me or others.
So now it's done in 3 stages using the source + bootstrap source:
1. Using gcc, compile "bootstrap source" -> bootstrap fbc [bs-fbc1]
(This limits it to architectures provided by upstream
but that's more than enough.)
2. Using bs-fbc1, bootstrap "source" -> bootstrap fbc 2 [bs-fbc2]
(this is based on the source that will be used for full compiler)
3. Using bs-fbc2, compile "source" -> full fbc
When I compared "bootstrap source" in stage 1 vs. stage 2, it's
identical except for BUILD_DATE.
When I patch the BUILD_DATE to match upstream, the two fbc binaries are
hash-identical between stage 1 and stage 2 (before patching armhf).
Later, going through the different architectures, I had to patch armhf,
so patching the source, fixes stage2 and stage3 automatically (excellent!)
Credit for all this working out goes to upstream. And the original filer
of the ITP.
And thanks a lot for the review and hints.
A further refinement (you can keep that for later) will be to make that
bootstrap stage optional if there is already a freebasic package that
can be installed and used to rebuild the compiler. There are several
ways to achieve that and I will let you discuss that with your sponsor.
That would be nice. But that's months down the line. I did have a go
from this heads up and added a few make conditions, but I couldn't get
Build-Depends right.
bootstrappable.org looks informative. FreeBASIC doesn't have a new
workaround I believe. They provide the intermediate translated source
as C/asm instead of object files.
Unfortunately having any convenient and suitable bootstrapping procedure
provided by the upstream project is still the exception rather than the
rule. This is why I think this project is worth mentioning.
Upstream did do a great job here, perhaps if I send them a patch, I'll
mention this if they want to get listed.
--
Regards,
Ahmad
Reply to: