Commit 9d238791 authored by KevinBuhr's avatar KevinBuhr Committed by Marge Bot

Handle trailing path separator in package DB names (#16360)

Package DB directories with trailing separator (provided via
GHC_PACKAGE_PATH or via -package-db) resulted in incorrect calculation of
${pkgroot} substitution variable.  Keep the trailing separator while
resolving as directory or file, but remove it before dropping the last
path component with takeDirectory.

Closes #16360.
parent b9fe91fc
Pipeline #6758 failed with stages
in 118 minutes and 49 seconds
...@@ -559,13 +559,15 @@ readPackageConfig dflags conf_file = do ...@@ -559,13 +559,15 @@ readPackageConfig dflags conf_file = do
"can't find a package database at " ++ conf_file "can't find a package database at " ++ conf_file
let let
-- Fix #16360: remove trailing slash from conf_file before calculting pkgroot
conf_file' = dropTrailingPathSeparator conf_file
top_dir = topDir dflags top_dir = topDir dflags
pkgroot = takeDirectory conf_file pkgroot = takeDirectory conf_file'
pkg_configs1 = map (mungePackageConfig top_dir pkgroot) pkg_configs1 = map (mungePackageConfig top_dir pkgroot)
proto_pkg_configs proto_pkg_configs
pkg_configs2 = setBatchPackageFlags dflags pkg_configs1 pkg_configs2 = setBatchPackageFlags dflags pkg_configs1
-- --
return (conf_file, pkg_configs2) return (conf_file', pkg_configs2)
where where
readDirStylePackageConfig conf_dir = do readDirStylePackageConfig conf_dir = do
let filename = conf_dir </> "package.cache" let filename = conf_dir </> "package.cache"
import Test
main = print test
include $(TOP)/mk/
include $(TOP)/mk/
rm -f test/*.o test/*.hi *.o *.hi
.PHONY: T16360
@rm -rf $(LOCAL_PKGCONF)
"$(TEST_HC)" $(TEST_HC_OPTS) -this-unit-id test-1.0 -c test/Test.hs
"$(GHC_PKG)" --no-user-package-db -f $(LOCAL_PKGCONF) register test/test.pkg -v0
"$(TEST_HC)" $(TEST_HC_OPTS) -package-db $(LOCAL_PKGCONF)/ -c Hello.hs
test('T16360', [extra_files(['Hello.hs', 'test/'])], makefile_test, [])
module Test where
test :: Int
test = 42
name: test
version: 1.0
id: test-1.0
key: test-1.0
exposed-modules: Test
import-dirs: ${pkgroot}/test
library-dirs: ${pkgroot}/test
exposed: True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment