[fpc-pascal] fpc in symlinked directory

Michael Van Canneyt michael at freepascal.org
Wed Mar 26 15:19:29 CET 2014



On Wed, 26 Mar 2014, Mattias Gaertner wrote:

> On Wed, 26 Mar 2014 13:37:32 +0100 (CET)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
>> [...]
>> But I am arguing that when passing filenames/paths to other tools
>> (including the compiler), you should always specify full filenames.
>
> The IDE passes all search paths as full file paths, especially no
> '..'. No problem here. Symlinks don't need to be resolved for this.

Euh ? Last time I checked, the paths were full of ../ ?
(admittedly, that was some time ago, I stopped opening files through symlinks...)

>> [...]
>>>> That is why FPC resolves everything.
>>>
>>> Not true.
>>> For example when I leave out the 'cd /tmp/link' and my cwd
>>> is /home/mattias, then fpc creates the debugging info
>>> "../../tmp/link/unit1.pas".
>
> No comment here?

I tested, and indeed:

# include_directories
         .ascii  "../../tmp/link\000"

I think this is an error in FPC, because the linker file contains full paths:

INPUT(
/usr/local/lib/fpc/2.7.1/units/x86_64-linux/rtl/prt0.o
/tmp/link/p.o
/usr/local/lib/fpc/2.7.1/units/x86_64-linux/rtl/system.o
...

The two should at least match; and you will not be surprised to hear that 
I think the linker file is correct :)

>>>> /proc/self/cwd does the same: it resolves the directory.
>>>
>>> This is the physical cwd.
>>
>> Yes. It is the only one that makes sense.
>
> It makes sense for the kernel, because that works on the lower level.

There is only 1 level: the system level.

The rest are mirages.

> Michael, why do use symlinks? Why don't you always specify
> the fully resolved paths? You must see some sense in logical paths.

Stop: There is a difference between symlinks and logical paths.

Did I say I was against symlinks ? No. I use them a lot, and all the time.

They're just typing shortcuts, for convenience.

So, if I open (because it is faster)

/home/michael/lazarus/lazarus.lpi

and then the IDE caption tells me I have actually opened

/home/michael/projects/lazarus/lazarus.lpi

I will only be happy.

Similarly, if I do on the commandline:

cd ~
cd lazarus

and then pwd answers me:

/home/michael/projects/lazarus/

I am not surprised and actually quite happy that the tool correctly figured out the symlink.

By contrast, I am surprised (one might even say worried) that there exist people 
which expect (no, they insist) that pwd reports

/home/michael/lazarus/

In my highly personal opinion, these people do not understand symlinks.

And apparently such people not only exist, they seem to thrive...

The whole dicsussion is about the difference between knowing where 
you are (physical) and how you got there (logical).

The second concept is simply alien to me, because I consider it utterly irrelevant.

>> [...]
>>>> And likewise, I think that Lazarus is still wrong using relative paths.
>>>
>>> AFAIK the only issue with symlinks are the '..', as this works on the
>>> physical parent. There is no problem with a relative path like
>>> 'foo/bar'.
>>
>> Exactly. Lazarus specifies ALL links to required packages as relative paths.
>
> Not here.
> Please create a bug report with an example where Lazarus passes '..' to
> a tool.

No problem. I will test again, and report.

Michael.



More information about the fpc-pascal mailing list