Recent

Author Topic: Fpc, building from source questions  (Read 12561 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Fpc, building from source questions
« on: September 01, 2015, 04:00:43 pm »
   Hi!. I have a couple of questions regarding building fpc.

1. I want to double check what I've understood reading Programmer's guide, Compiling the compiler. When you build the compiler from source you can add the exiting compiler path as parameter to the "make" utility by using "PP=pathtoexistingcompiler", but you can't pass as parameter the default configuration file of the existing fpc. The reason why you can't pass the default configuration file to "make" is that the compiler doesn't use this file at all when building itself. This means that the configuration file doesn't have any kind of influence in the building process of the compiler. I'm I right or wrong?

2. When building fpc from source, how do I find fpc's executable used by the "make" utility? You can specify the compiler by using the "PP" parameter. Without this parameter, will "make" search only for "fpc${DEFAULTEXECUTABLEEXTENSION}" or it searches for "ppc*${DEFAULTEXECUTABLEEXTENSION}" files too?

3. If I want to build fpc from source, do I need a full installation of a stable release? Is it possible to build fpc from source only by using the compiler executable for that platform, not a complete fpc install?

4. How can I find out if the user that starts an application has administrator/super_user rights? I'm looking for an existing function in one of rtl's units. If there is none, then I'd like some ideas on how to write one that works at least for windows and linux.


5. When building fpc for crosscompiling sometimes you don't need a toolchain. I'd like to know the situations when these files are not needed.
   I'm not sure about the following examples, these are host to target examples:
linux-x86_64 to win32-i386
linux-x86_64 to win64-x86_64
linux-x86_64 to linux-i386
linux-i386 to win32-i386
linux-i386 to win64-x86_64
win64-x86_64 to win32-i386
   Are the above situations the only ones when CROSSBINDIR and BINUTILSPREFIX are completely ignored? I mean situations when the used doesn't need "${BINUTILSPREFIX}{"as","ar","ld"...}" executables.
   I'm not sure about the list presented above, reason why I'd like somebody to check it and explain the situation.

   Thank you!
« Last Edit: September 15, 2015, 09:17:25 pm by lagprogramming »

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Fpc, building from source questions
« Reply #1 on: September 01, 2015, 04:10:05 pm »
   Hi!. I have a couple of questions regarding building fpc.

1. I want to double check what I've understood reading Programmer's guide, Compiling the compiler. When you build the compiler from source you can add the exiting compiler path as parameter to the "make" utility by using "PP=pathtoexistingcompiler", but you can't pass as parameter the default configuration file of the existing fpc. The reason why you can't pass the default configuration file to "make" is that the compiler doesn't use this file at all when building itself. This means that the configuration file doesn't have any kind of influence in the building process of the compiler. I'm I right or wrong?
Correct.

Quote
2. When building fpc from source, how do I find fpc's executable used by the "make" utility? You can specify the compiler by using the "PP" parameter. Without this parameter, will "make" search only for "fpc${DEFAULTEXECUTABLEEXTENSION}" or it searches for "ppc*${DEFAULTEXECUTABLEEXTENSION}" files too?
It will search for the fpc binary, and if it can't find that one, also for ppc386. It does not search for anything else, regardless of your platform.

Quote
3. If I want to build fpc from source, do I need a full installation of a stable release? Is it possible to build fpc from source only by using the compiler executable for that platform, not a complete fpc install?
You need a full installation of the *latest* stable release. It is possible to build with less, but this is not supported and if you run into trouble, you are on your own.

Quote
4. How can I find out if the user that starts an application has administrator/super_user rights? I'm looking for an existing function in one of rtl's units. If there is none, then I'd like some ideas on how to write one that works at least for windows and linux.
There is no such RTL function. On Unix platforms, you probably need FpGeteuid. I have no clue about Windows.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Fpc, building from source questions
« Reply #2 on: September 02, 2015, 09:03:44 am »
3. If I want to build fpc from source, do I need a full installation of a stable release? Is it possible to build fpc from source only by using the compiler executable for that platform, not a complete fpc install?
If you take a look into CodeTyphon installation archive you can find what is minimally needed for a successful FPC source compilation. Subarchive for each supported platform can be found at CodeTyphonIns\installbin\allzips\binfpc.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Fpc, building from source questions
« Reply #3 on: September 02, 2015, 10:11:25 am »

2. When building fpc from source, how do I find fpc's executable used by the "make" utility? You can specify the compiler by using the "PP" parameter. Without this parameter, will "make" search only for "fpc${DEFAULTEXECUTABLEEXTENSION}" or it searches for "ppc*${DEFAULTEXECUTABLEEXTENSION}" files too?

fwiw

make info |grep "FPC\..."  (grep can of course be implemented using tprocess)

Quote
3. If I want to build fpc from source, do I need a full installation of a stable release? Is it possible to build fpc from source only by using the compiler executable for that platform, not a complete fpc install?

In addition to what Jonas said about this, the tricks can also be a bit target dependent and there is also a profound difference between "usually working" and "always working".

e.g. with a fully installed release .inc files are regenerated when needed, while with a partial install a commit that only updates e.g. the ini (but not the .inc) it will suddenly break.

Quote
4. How can I find out if the user that starts an application has administrator/super_user rights? I'm looking for an existing function in one of rtl's units. If there is none, then I'd like some ideas on how to write one that works at least for windows and linux.

Unix will probably be something like (fpgeteuid=0)    and for  Windows winutils.iswindowsadmin

I'm not sure if it really is useful to make this platform independent since nearly everything you do with it (and what "admin"  means) is OS dependent again.
« Last Edit: September 14, 2015, 10:29:49 am by marcov »

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Re: Fpc, building from source questions
« Reply #4 on: September 02, 2015, 03:24:20 pm »
3.
@avra
Quote
If you take a look into CodeTyphon installation archive you can find what is minimally needed for a successful FPC source compilation.
:) Thank you but I'm trying to reinvent the wheel here. If I fail, I'd like to do it in a original style, like no one did it before.


2.
@marcov
Quote
make info |grep "FPC\..."  (grep can of course be implemented using tprocess)
This is awesome. I didn't knew about the "info" parameter, but this opens new questions. Based on the following lines I'd like somebody to explain or check my statements:
== Package info ==
Package Name..... fpc
Package Version.. 3.1.1

== Configuration info ==

FPC.......... /usr/bin/ppcx64
FPC Version.. 2.6.4


Package Name is a name of the source files.
Package Version is a version of the source files.
FPC is the compiler used to build the source files.
FPC Version is the version of the compiler that will build the source files.


   If the above is right, how do "FPC" and "FPC Version" lines appear when fpc compiler can't be found, will they look like this?
FPC..........
FPC Version..

Notice the empty(like '') values. Or will the lines completely miss from the output?

   In windows, I see there is a full path of the compiler executable, like: "FPC.......... C:/lazarus/fpc/2.6.4/bin/i386-win32/ppc386.exe".
From where did this value came from, is make.exe searching for the compiler in the same directory where make.exe lies, is fpc related data stored within windows registry?


3.
Quote
e.g. with a fully installed release .inc files are regenerated when needed, while with a partial release a commit that only updates e.g. the ini (but not the .inc) will suddenly break.
   Is the installation process of a stable fpc release doing more than the following two steps?
- extract binary and text files to a destination directory;
- configure default configuration file.
   I mean is the installation process also updating the PATH or windows registries, modifying installed text files based on the installation path, or who knows what else might be done?

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Re: Fpc, building from source questions
« Reply #5 on: September 08, 2015, 08:42:06 pm »
   What about building fpc for crosscompiling!?
   Assuming that in the first step I build a development fpc from source using the latest stable fpc release.
   In the second step I'd like to build fpc for crosscompiling. Is there a problem if I use the development version of fpc instead of the stable one? The development version is the one built at first step. The source files remain unchanged between the two steps. I ask because after reading about the 3 steps cycle, I think there shouldn't be problem. If there would have been a problem, the problem would have appeared at first step, when building the "native" compiler, right!? If an error would appear at second step it would appear no matter the compiler used.
   Is the above rationale valid?

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Fpc, building from source questions
« Reply #6 on: September 08, 2015, 09:04:02 pm »
 
Quote
In the second step I'd like to build fpc for crosscompiling. Is there a problem if I use the development version of fpc instead of the stable one?
Last time i tried that failed as it insisted on cross-compiling with the stable release (2.6.4) . But that might have been a small oversight at that time.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Fpc, building from source questions
« Reply #7 on: September 09, 2015, 11:12:49 am »
Is there a problem if I use the development version of fpc instead of the stable one?
Yes, it's not supported and not guaranteed to succeed. If it works, lucky you. If it doesn't, don't complain. Only the latest stable release is supported to build either latest stable release itself or trunk.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Fpc, building from source questions
« Reply #8 on: September 14, 2015, 09:58:02 am »
   What about building fpc for crosscompiling!?
   Assuming that in the first step I build a development fpc from source using the latest stable fpc release.
   In the second step I'd like to build fpc for crosscompiling. Is there a problem if I use the development version of fpc instead of the stable one? The development version is the one built at first step.
Building a development version of FPC using a compiler built from the same sources is indeed ok, also for cross-compiling.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Re: Fpc, building from source questions
« Reply #9 on: September 15, 2015, 09:18:02 pm »
5. When building fpc for crosscompiling sometimes you don't need a toolchain. I'd like to know the situations when these files are not needed.
   I'm not sure about the following examples, these are host to target examples:
linux-x86_64 to win32-i386
linux-x86_64 to win64-x86_64
linux-x86_64 to linux-i386
linux-i386 to win32-i386
linux-i386 to win64-x86_64
win64-x86_64 to win32-i386
   Are the above situations the only ones when CROSSBINDIR and BINUTILSPREFIX are completely ignored? I mean situations when the used doesn't need "${BINUTILSPREFIX}{"as","ar","ld"...}" executables.
   I'm not sure about the list presented above, reason why I'd like somebody to check it and explain the situation.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Fpc, building from source questions
« Reply #10 on: September 15, 2015, 09:20:01 pm »
The only situation where it's not required is when targeting Win32 or Win64.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Re: Fpc, building from source questions
« Reply #11 on: September 15, 2015, 09:30:04 pm »
The only situation where it's not required is when targeting Win32 or Win64.
Do HOSTOS, HOSTCPU and TARGETCPU matter?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Fpc, building from source questions
« Reply #12 on: September 15, 2015, 09:31:28 pm »
Win32 and Win64 are both only supported for a single target cpu architecture. The host is irrelevant.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
Re: Fpc, building from source questions
« Reply #13 on: September 15, 2015, 09:33:40 pm »
What about linux-x86_64 to linux-i386 and linux-i386 to linux-x86_64?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Fpc, building from source questions
« Reply #14 on: September 15, 2015, 09:49:42 pm »
Besides toolchain availability, there is also the need for the extended type for i386, afaik it makes crosscompiling the compiler from hostcpu=anything to targetcpu=i386 is not possible because the i386 part of the compiler cg uses extended?

 

TinyPortal © 2005-2018