View Issue Details

IDProjectCategoryView StatusLast Update
0030053FPCDocumentationpublic2016-10-09 17:51
ReporterMartin SchreiberAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86OSLinuxOS Version
Product Version3.0.0Product Build 
Target Version3.0.2Fixed in Version3.1.1 
Summary0030053: Wrong unit search path order
DescriptionFPC uses the first found unit in -Fu commandline items instead of the last.
Steps To ReproduceCompile attached project:
"
mse@linuxmse:~/proj/msegui/testcase/fpc/fixes_3_0/searchorder> fpc -Fu./test -Fu./test1 searchorder
Free Pascal Compiler version 3.0.0rc2 [2015/10/14] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling searchorder.pas
Compiling ./test/testunit.pas
Linking searchorder
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
14 lines compiled, 0.3 sec
"
mse@linuxmse:~/proj/msegui/testcase/fpc/fixes_3_0/searchorder> fpc -Fu./test1 -Fu./test searchorder
Free Pascal Compiler version 3.0.0rc2 [2015/10/14] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling searchorder.pas
Compiling ./test1/testunit.pas
searchorder.pas(5,2) Error: Identifier not found "testunit0"
searchorder.pas(7) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode
"
TagsNo tags attached.
Fixed in Revision1359
FPCOldBugId
FPCTarget
Attached Files

Activities

Martin Schreiber

2016-04-24 09:08

reporter  

searchorder.tar.gz (638 bytes)

Florian

2016-04-24 20:53

administrator   ~0092185

Last edited: 2016-04-24 20:54

View 2 revisions

This is done apparently on purpose (from compiler/options.pas):

...
                 'u' :
                   begin
                     if ispara then
                       ParaUnitPath.AddPath(More,false)
                     else
                       unitsearchpath.AddPath(More,true);
                   end;
...

And it had been changed last time in 2002, so I think we should leave at it is.

Edit: the purpose of the boolean parameter is if the entry should be inserted at the first position.

Martin Schreiber

2016-04-25 06:49

reporter   ~0092191

Last edited: 2016-04-25 07:48

View 2 revisions

How behaves Delphi?

Thaddy de Koning

2016-04-25 08:53

reporter   ~0092193

Last edited: 2016-04-25 12:02

View 6 revisions

D7 uses always the first file on the path with -I<paths>, -O<paths> and -U<paths>
So the behavior is Delphi compatible. And imo also logical order in the sense that it has the same semantics as the Windows environment path.

Btw: you are using an old linker.(hence the -T warning)

Edit: if -LU is specified for a package, the unit in the package has preference. Note that may be important in this case.

Edit2: note these are Delphi - not FPC - options and are still valid in XE2+

Martin Schreiber

2016-04-25 19:53

reporter   ~0092221

Then probably the documentation should be changed:
http://www.freepascal.org/docs-html/current/user/usersu7.html#x21-280003.1.2
"
You can add a directory to the unit search path with the (-Fu (see page 100))
option. Every occurrence of one of these options will insert a directory to
the unit search path. i.e. the last path on the command line will be searched
first.
"

Thaddy de Koning

2016-04-26 07:43

reporter   ~0092229

Last edited: 2016-04-26 07:48

View 3 revisions

It is a bit ambiguous in the sense that the option is inserted temporary to the OS path and on top of the OS path (or global option) for the purpose of the compiler. Specifiyng a path with one of the options takes precedence over the OS path and is read first. The order in which multiple paths are read by the specified paths options, however, are evaluated left to right.

I see now why you were lead to believe otherwise. The documentation is correct however. [edit] is indeed wrong...

Martin Schreiber

2016-04-26 19:00

reporter   ~0092237

Searching order in uses section also is last to first and sometimes one has standard paths in a macro and adds overrides at end of commandline so the documented order probably has been chosen intentionally.

Michael Van Canneyt

2016-10-09 17:51

administrator   ~0095059

There is indeed a difference on how units are added to the search path, depending on whether they are added from a config file or not. I documented this.

Issue History

Date Modified Username Field Change
2016-04-24 09:08 Martin Schreiber New Issue
2016-04-24 09:08 Martin Schreiber File Added: searchorder.tar.gz
2016-04-24 20:53 Florian Note Added: 0092185
2016-04-24 20:54 Florian Note Edited: 0092185 View Revisions
2016-04-25 06:49 Martin Schreiber Note Added: 0092191
2016-04-25 07:48 Martin Schreiber Note Edited: 0092191 View Revisions
2016-04-25 08:53 Thaddy de Koning Note Added: 0092193
2016-04-25 08:56 Thaddy de Koning Note Edited: 0092193 View Revisions
2016-04-25 09:00 Thaddy de Koning Note Edited: 0092193 View Revisions
2016-04-25 09:02 Thaddy de Koning Note Edited: 0092193 View Revisions
2016-04-25 09:04 Thaddy de Koning Note Edited: 0092193 View Revisions
2016-04-25 12:02 Thaddy de Koning Note Edited: 0092193 View Revisions
2016-04-25 19:53 Martin Schreiber Note Added: 0092221
2016-04-26 07:43 Thaddy de Koning Note Added: 0092229
2016-04-26 07:45 Thaddy de Koning Note Edited: 0092229 View Revisions
2016-04-26 07:48 Thaddy de Koning Note Edited: 0092229 View Revisions
2016-04-26 19:00 Martin Schreiber Note Added: 0092237
2016-10-02 13:37 Jonas Maebe Category Compiler => Documentation
2016-10-02 13:37 Jonas Maebe Assigned To => Michael Van Canneyt
2016-10-02 13:37 Jonas Maebe Status new => assigned
2016-10-09 17:51 Michael Van Canneyt Fixed in Revision => 1359
2016-10-09 17:51 Michael Van Canneyt Note Added: 0095059
2016-10-09 17:51 Michael Van Canneyt Status assigned => resolved
2016-10-09 17:51 Michael Van Canneyt Fixed in Version => 3.1.1
2016-10-09 17:51 Michael Van Canneyt Resolution open => fixed
2016-10-09 17:51 Michael Van Canneyt Target Version => 3.0.2