Recent

Author Topic: [SOLVED] Getting started building FPC  (Read 629 times)

rushfan

  • Newbie
  • Posts: 4
[SOLVED] Getting started building FPC
« on: September 14, 2024, 06:19:53 pm »
Hi all, I'm new to FPC and trying to get to a point of being able to use FPC to compile to WASM.   THis seems to need a newer version of FPC than the 3.2.2. build, so I'm trying to compile FPC on a couple of platforms (debian x86-64 or macos arm) and have the same problem.

The version displayed for the compiler seems to still be 3.2.2 and I'd expect it to be 3.3 or something newer.

Example:
./compiler/utils/fpc -v
Free Pascal Compiler version 3.2.2+dfsg-20 [2023/03/30] for x86_64

I'm. using this repo: https://gitlab.com/freepascal.org/fpc/source.git and just git pulled today (a685e2aa5a9a37bc09efe484f9f2e2c825b46a3b is the latest commit)

I've looked at the gitlab CI running adn also instructions here (https://wiki.freepascal.org/FPC_recompilation_automation) to see if there's something I'm missing, but I'm not sure what I'm doing wrong.  Any help is appreciated, I'm new to FPC but excited to try to experiment with WASM from it (pascal was my first love of a programming language)

Rushfan
« Last Edit: September 14, 2024, 07:57:37 pm by rushfan »

jamie

  • Hero Member
  • *****
  • Posts: 6550
Re: Getting started building FPC
« Reply #1 on: September 14, 2024, 06:34:36 pm »
From what I know, you need a compiler version older than the one you are building.

So, if you want 3.2.3 you need to use 3.2.2 if that makes sense.

The only true wisdom is knowing you know nothing

rushfan

  • Newbie
  • Posts: 4
Re: Getting started building FPC
« Reply #2 on: September 14, 2024, 07:11:36 pm »
Thanks jamie for the reply, that does make sense and I had previously installed 3.2.2 and seem to be hitting another error.

I just realized I do have a ppcx86 built but when I run fpc it still shows as the same version that is installed.

I think I just figured it out.
Look like my shell was remembering fpc from /usr/bin (which is pointing to the 3.2.2 version).

Using command -V showed me it was hashed (see https://unix.stackexchange.com/questions/251731/what-does-is-hashed-mean-when-using-the-type-command)

Therefore it was not the one from /usr/local/bin and also I needed to add some symlinks into /usr/local/bin (I saw this on here: https://wiki.freepascal.org/Installing_the_Free_Pascal_Compiler#FPC_development_version)

Where should I have looked to follow instructions for building from source, is the latest link (Installing_the_Free_Pascal_Compiler) probably the place I should have started?

Thanks everyone.

TRon

  • Hero Member
  • *****
  • Posts: 3231
Re: Getting started building FPC
« Reply #3 on: September 14, 2024, 08:43:04 pm »
Where should I have looked to follow instructions for building from source, is the latest link (Installing_the_Free_Pascal_Compiler) probably the place I should have started?
The build-faq is the first place to look (but that does not tell you all you need to know only describes the basics). Any wiki entry telling about how to build the compiler should be ok but afaik there is bits and pieces scattered all over. Details come when you put everything together.

The makefile allows you to select a bootstrap compiler using PP=/path/and/name/to/bootstrap/executable or FPC=/path/and/name/to/fpc/executable. make can be run from the source-directory and you need all the basic utils such as make and binutils.
All software is open source (as long as you can read assembler)

rushfan

  • Newbie
  • Posts: 4
Re: [SOLVED] Getting started building FPC
« Reply #4 on: September 14, 2024, 09:11:10 pm »
Thank you for the reply and for the link to the faq.  That looks great.

 I'll check that out to get a better overall understanding of how things fit together, which I'm lacking at the moment.

dbannon

  • Hero Member
  • *****
  • Posts: 3061
    • tomboy-ng, a rewrite of the classic Tomboy
Re: [SOLVED] Getting started building FPC
« Reply #5 on: September 15, 2024, 02:16:27 am »
rushfan, I am unsure of where you are up to here.  But sounds like you have successfully build FPC323 and are struggling as to how to use it instead of the default FPC322 ? Please don't go putting symlinks to the new one in /usr/bin, makes it hard to go back to the old one.

While you could use a compile command that begins with an explicit path to the one to use, the more normal approach is to update your PATH variable.  As long as you are starting fpc from the command line, all that means, on Linux, is an edit of ~/.bashrc. If you have in fact installed FPC in /usr/local/bin then add these two lines to the end of ~/.bashrc

Code: Bash  [Select][+][-]
  1. export OLDPATH="$PATH"
  2. export PATH=/usr/local/bin:"$PATH"

And, run $> source ~/.bashrc so the shell reads it.  Make sure /usr/local/bin/fpc exists too !

If you feel the need to rebuild FPC323 again, you can force you PATH back to the old setting for that session with  -
Code: Bash  [Select][+][-]
  1. $> export PATH="$OLDPATH"

I cannot tell you so clearly how to deal with the Mac, Apple have stopped using bash but I did not follow that and have kept my Mac using bash.  But the principle is the same, ensure the FPC you want to use appears first in your PATH statement.

Some other, less important suggestions -
  • You might be better off using the fixes version of FPC (if it has what you need) rather that the bleeding edge 'main', 'trunk' whatever.
  • If you install fpc323 again, perhaps you would be better off installing it in user space, somewhere like $HOME/bin/FPC - that way, don't need root access to install or modify and its all in one place by itself, very easy to blow it away and start again.


Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

PascalDragon

  • Hero Member
  • *****
  • Posts: 5672
  • Compiler Developer
Re: [SOLVED] Getting started building FPC
« Reply #6 on: September 15, 2024, 09:18:33 pm »
Example:
./compiler/utils/fpc -v
Free Pascal Compiler version 3.2.2+dfsg-20 [2023/03/30] for x86_64

The fpc binary is only a driver binary that selects a suitable ppcXXX-binary relying on the PATH environment variable. So as long as you didn't do a suitably configured make install and then adjusted your PATH the fpc binary will continue to find your pre-installed binaries.

rushfan

  • Newbie
  • Posts: 4
Re: [SOLVED] Getting started building FPC
« Reply #7 on: September 19, 2024, 02:33:39 am »
Thank you both dbannon and PascalDragon, I think I'm good now and the replies are greatly appreciated.

Rushfan

 

TinyPortal © 2005-2018