View Issue Details

IDProjectCategoryView StatusLast Update
0037095FPCCompilerpublic2020-05-17 23:28
ReporterKirinn Assigned ToJonas Maebe  
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037095: $UNITPATH directive misinterprets relative paths
DescriptionThe $UNITPATH compiler directive is supposed to be equivalent to the commandline switch -Fu, but on 3.2.0 RC1 it seems the directive is always implicitly prefixed with a slash, causing an incorrect unit path to be added. That is, "unitdir" is treated as "/unitdir". Using "-Fuunitdir" on the commandline still works as expected.

In the below test case, attempting to use both {$UNITPATH unitdir} and {$UNITPATH ./unitdir} produces this in verbose compiler output (fpc --vva test.pas):
[0.265] Compiling test.pas
[0.265] Searching file test.pas... found
2 137/1.056 Kb Used
[0.265] test.pas (3,2) Handling switch "$UNITPATH"
[0.265] Path "F:\unitdir\" not found
[0.437] (TEST) Registering new unit TESTUNIT
[0.437] (TEST) Load from TEST (implementation) unit TESTUNIT
[0.437] (TESTUNIT) Loading unit TESTUNIT
[0.437] Unitsearch: testunit.ppu
[2.059] test.pas(5,6) Fatal: Can't find unit testunit used by test
[2.059] Fatal: Compilation aborted
Steps To ReproduceThe minimal test files for reproduction are in the attached zip for convenience. These are the file contents:

- test.pas:
program test;
{$UNITPATH unitdir}
uses testunit;
  writeln('Say hello, unit!');

- unitdir/testunit.pas
unit testunit;
  procedure UnitHello;
  procedure UnitHello;
    writeln('"Hello, unit."');

With these files in place, run "fpc test.pas" and it fails to find the unit. Run "fpc -Fuunitdir test.pas", and it succeeds.
Additional InformationI've reproduced this on a 64-bit Fedora 31, and 32-bit Windows 7 and Windows 10.

This doesn't happen when using FPC 3.0.4, so it's a regression in 3.2.0 RC1.
TagsNo tags attached.
Fixed in Revision45410
Attached Files



2020-05-17 16:57

reporter (679 bytes)

Jonas Maebe

2020-05-17 23:28

manager   ~0122894

I don't know if the fix will still make it into 3.2.0. If not, you can work around it by using {$unitpath ./unitdir} (or {$unitpath .\unitdir}).

Issue History

Date Modified Username Field Change
2020-05-17 16:57 Kirinn New Issue
2020-05-17 16:57 Kirinn File Added:
2020-05-17 23:16 Jonas Maebe Assigned To => Jonas Maebe
2020-05-17 23:16 Jonas Maebe Status new => assigned
2020-05-17 23:28 Jonas Maebe Status assigned => resolved
2020-05-17 23:28 Jonas Maebe Resolution open => fixed
2020-05-17 23:28 Jonas Maebe Fixed in Version => 3.3.1
2020-05-17 23:28 Jonas Maebe Fixed in Revision => 45410
2020-05-17 23:28 Jonas Maebe FPCTarget => -
2020-05-17 23:28 Jonas Maebe Note Added: 0122894