[fpc-pascal] Search path order for fpc.cfg

Michael Van Canneyt michael at freepascal.org
Sat Apr 11 13:35:42 CEST 2020

On Sat, 11 Apr 2020, Jonas Maebe wrote:

> On 11/04/2020 08:24, Michael Van Canneyt wrote:
>> it is not done on unices to search in the binary directory for config
>> files. That's a windows thing.
> And the main reason for this is that "the" compiler binary does not
> necessarily exist. The most obvious case is a hard link: in this case, a
> single file exists in multiple locations on the file system. A program
> file can also be moved while it was executing.
> Even if you ignore the above cases and only care about the directory in
> which the binary was found when it was started, then there is still the
> issue that not all Unix systems provide you with that information. E.g.
> on Darwin/macOS, if you just type "ppcx64", then the "full path" to the
> binary that the program gets is "ppcx64" and you have no idea where it's
> located. You can use some heuristics like looking in the path, but this
> is fragile and might possibly even be used for attacks (it is probably
> possible to specify a different PATH environment variable to the child
> process than the one used to originally find it).
> This is also the reason why most Unix programs have there installation
> directory compiled into the binary, and why you often have to specify it
> already when building the program (rather than only when installing it).
> FPC does not do that due to its DOS and OS/2 heritage, but it's not
> something we should extend.

In short: 
the installer should write a 'correct' config file, without tricks
like relative paths.

Many unix programs that can be installed 'anywhere' require you to set
environment variables in order to find where you installed it.


More information about the fpc-pascal mailing list