Recent

Author Topic: Controlling output file name when omitting linking?  (Read 1583 times)

jamesmp98

  • Newbie
  • Posts: 1
Controlling output file name when omitting linking?
« on: December 14, 2019, 07:28:46 pm »
I have a small Pascal file which I'm compiling without linking (as it is being statically linked to other things later on by hand) and am trying to compile similar to the following:

Code: Bash  [Select][+][-]
  1. fpc -Cn -oabcdef.o lib.pas

I was expecting the output to be named abcdef.o however, it seems that due to the fact that I'm omitting the linking stage the -o flag gets ignored and the resutling binary is always named the same as the source file. Short of hacking a rename into my makefile, is there a way to control the output file name when omitting the linking stage? My compiler version is 3.0.4

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Controlling output file name when omitting linking?
« Reply #1 on: December 14, 2019, 11:36:03 pm »
the resutling binary is always named the same as the source file.

I don't know exactly, but I see a reason for it:
Traditionally, Pascal projects are not relying on make-like project files, instead everything was linked from source's uses sections (as units).
So unit name is bound to source filename, and .o/.ppu should rely on unit name.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Controlling output file name when omitting linking?
« Reply #2 on: December 14, 2019, 11:50:07 pm »
Hi!

I think that @sash is right but you could try

Code: Text  [Select][+][-]
  1. -Un        Do not check where the unit name matches the file name


Winni

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Controlling output file name when omitting linking?
« Reply #3 on: December 15, 2019, 06:39:33 pm »
The -o option applies only to the binary name, not the object name.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Controlling output file name when omitting linking?
« Reply #4 on: December 15, 2019, 07:29:04 pm »
Traditionally, Pascal projects are not relying on make-like project files, instead everything was linked from source's uses sections (as units).
So unit name is bound to source filename, and .o/.ppu should rely on unit name.

With the caveat that the FPC compiler runs through a substantial number of possible file names for each unit name, to try to work round issues related to Pascal being case-insensitive while various OSes and filesystems have different combinations of case sensitivity and case conservation (examine using -vt option).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Controlling output file name when omitting linking?
« Reply #5 on: December 16, 2019, 09:24:01 am »
Traditionally, Pascal projects are not relying on make-like project files, instead everything was linked from source's uses sections (as units).
So unit name is bound to source filename, and .o/.ppu should rely on unit name.

With the caveat that the FPC compiler runs through a substantial number of possible file names for each unit name, to try to work round issues related to Pascal being case-insensitive while various OSes and filesystems have different combinations of case sensitivity and case conservation (examine using -vt option).
FPC uses a directory cache where it scans each directory only once and then uses string comparisons. Compared to the remaining work that FPC has to do (namely compiling the code, optimizing it, linking it) this isn't really that noteworthy.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Controlling output file name when omitting linking?
« Reply #6 on: December 16, 2019, 09:45:14 am »
Traditionally, Pascal projects are not relying on make-like project files, instead everything was linked from source's uses sections (as units).
So unit name is bound to source filename, and .o/.ppu should rely on unit name.

With the caveat that the FPC compiler runs through a substantial number of possible file names for each unit name, to try to work round issues related to Pascal being case-insensitive while various OSes and filesystems have different combinations of case sensitivity and case conservation (examine using -vt option).
FPC uses a directory cache where it scans each directory only once and then uses string comparisons. Compared to the remaining work that FPC has to do (namely compiling the code, optimizing it, linking it) this isn't really that noteworthy.

It might not be noteworthy in terms of processing time and filesystem access, but as I understand it it is noteworthy in that there is not a guaranteed bidirectional conversion between unit name and source filename on disc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018