Opened 8 years ago

Closed 3 years ago

Last modified 2 years ago

#3321 closed bug (worksforme)

-fhpc assumes original sources relative to the current directory

Reported by: duncan Owned by:
Priority: lowest Milestone: 8.0.1
Component: Code Coverage Version: 6.10.1
Keywords: Cc: ttuegel
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

For the most part, ghc can be invoked in a manner that is independent of the current directory by suitable use of -i options.

With -fhpc it appears that the hpc bits always look in the current directory to find original source files.

Consider the following file layout:

Codec/Compression/Zlib/Stream.hsc
dist/build/Codec/Compression/Zlib/Stream.hs
examples/gunzip.hs

Now if we cd to examples and run:

ghc --make gunzip.hs -lz -i../ -i../dist/build

then it works fine. It finds Codec/Compression/Zlib/Stream.hs in ../dist/build and it never bothers to look for the original source of course.

Now in -fhpc mode it has to also find the original sources so that it can match things back to them. However just adding -fhpc to the above command fails:

ghc --make gunzip.hs -lz -i../ -i../dist/build -fhpc
[1 of 4] Compiling Codec.Compression.Zlib.Stream ( ../dist/build/Codec/Compression/Zlib/Stream.hs, ../dist/build/Codec/Compression/Zlib/Stream.o )
Codec/Compression/Zlib/Stream.hsc: getModificationTime: does not exist (No such file or directory)

So it's clearly not looking in the directory given by -i.. for the original sources. Also, the failure mode is a bit unfriendly.

Cabal sometimes takes advantage of the fact that ghc can be invoked in a manner that is independent of the current directory, and we would like to add hpc support into Cabal.

Change History (14)

comment:1 Changed 8 years ago by igloo

difficulty: Unknown
Milestone: 6.12 branch

comment:2 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:3 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:4 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:6 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:7 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:8 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:9 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:10 Changed 3 years ago by thomie

Component: CompilerCode Coverage
Type of failure: None/Unknown

comment:11 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:12 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:13 Changed 3 years ago by thomie

Cc: ttuegel added
Resolution: worksforme
Status: newclosed

@duncan, @ttuegel: I think this works now (the issue was opened 7 years ago). Please reopen if you find ghc still doesn't handle the combination of -fhpc and -i properly.

$ mkdir a
$ mkdir b

$ cat > ./a/A.hs <<EOF
module A where
import B
EOF

$ cat > ./B.hsc <<EOF
module B where
EOF

$ hsc2hs B.hsc -o b/B.hs
$ cd a
$ ghc-7.8.4 --make A.hs -i../b -fhpc
[1 of 2] Compiling B                ( ../b/B.hs, ../b/B.o )
[2 of 2] Compiling A                ( A.hs, A.o )

Note that we don't get an error message that the source for B can not be found, with or without -fhpc.

comment:14 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.