Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nonportable-include-path warning on case-insensitive systems #3918

Open
gelisam opened this issue Mar 13, 2018 · 14 comments
Open

nonportable-include-path warning on case-insensitive systems #3918

gelisam opened this issue Mar 13, 2018 · 14 comments

Comments

@gelisam
Copy link

gelisam commented Mar 13, 2018

General summary/comments

The common case of using the same name for the executable (e.g. interplay) and the top-level module of the corresponding library (e.g. Interplay.Types) leads to a spurious warning being displayed while building using stack on a case-insensitive filesystem:

     warning: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Interplay/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include ".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/interplay/autogen/cabal_macros.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         ".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Interplay/autogen/cabal_macros.h"
1 warning generated.

It looks like stack tries to create both a folder named interplay and one named Interplay, but the OS considers them the same. As a result, the files generated for the module and for the executable end up in the same folder. Luckily, the files have different names so this doesn't cause any problems, except for the fact that the above warning is generated.

The problem does not occur when building using cabal, because it uses a different folder scheme. Similarly, stack could change its folder scheme (e.g. put the executable folders and the module folders in two different sub-folders) in order to avoid the warning.

Steps to reproduce

For your convenience, I have created a minimal project which demonstrates the problem. The important parts are the fact that the package.yaml specifies an executable named interplay:

name: interplay
dependencies:
- base

library:
  source-dirs: src

executables:
  interplay:
    main: Main.hs
    source-dirs: app

and the fact that the project contains a file src/Interplay/Types.hs, that is, there is a top-level module named Interplay.

Simply run stack build on a case-insensitive system and you will see the warning. I have tried it on macOS, and I suspect that the problem will also occur on Windows but not on Linux.

Expected

The project builds with no warning.

Actual

The projects builds successfully, but displays the above warning. Here is the full output of stack build --verbose, after a stack clean --full.

Stack version

I tried with both stack-1.6.5 and stack-HEAD.

$ stack --version
Version 1.6.5, Git revision 24ab0d6ff07f28276e082c3ce74dfdeb1a2ca9e9 (5514 commits) x86_64 hpack-0.20.0

Method of installation

  • Other: stack upgrade --git for stack-HEAD and then stack upgrade --force-download for stack-1.6.5
@simonmichael
Copy link
Contributor

Related: the warning mentions [-Wnonportable-include-path], which looks like a GHC warning flag but is not recognised by GHC, confusingly (right ?)

@simonmichael
Copy link
Contributor

I could not reproduce this on mac today with stack 1.7.1 or 1.6.3, possibly resolved somehow ?

@gelisam
Copy link
Author

gelisam commented May 18, 2018

I still see the problem with both stack-1.6.5, stack-1.7.1, and stack-HEAD. Is your filesystem case-insensitive or case-sensitive? That is, if you type touch foo Foo, does it create one or two files?

@simonmichael
Copy link
Contributor

Yes I'm on a case-insensitive filesystem. I'm not sure what happened, either I erred or some unknown factor was helping out.

@ncaq
Copy link
Contributor

ncaq commented May 22, 2018

relation?
#4017

@gelisam
Copy link
Author

gelisam commented May 22, 2018

relation?
#4017

Adding ghc-options: ["-optP-Wno-nonportable-include-path"] to the top-level of my package.yaml does fix the problem, thanks!

@simonmichael, that PR includes a link to haskell/cabal#4739, which claims that the warning comes from clang, so perhaps we simply have different versions of clang? Mine is clang-900.0.38.

@gelisam
Copy link
Author

gelisam commented May 22, 2018

Hmm, taking a closer look at the "fix", I now realize that this simply tells clang not to print the warning, but it doesn't fix the root cause. I think that's fine though, since the warning is about the file in some generated paths being non-portable, and that's fine because those file and paths are going to be re-generated on other systems, we're not going to copy them over. So if stack wants to fix the problem by always passing this flag instead of by changing the directory structure of the files it generates, that would be fine by me.

@simonmichael
Copy link
Contributor

simonmichael commented May 22, 2018

Not sure @gelisam. I seem to have clang-900.0.37 (which I think was what I had last time I saw the error).

@clord
Copy link

clord commented Oct 5, 2018

Sharing the directory with other machines with different case sensitivity will still be a problem (e.g., cache of build products in a CI server farm; working on the same project on a home machine and a laptop that is synced, etc) So I think the right fix here is to fix the code generating this path.

@dmalikov
Copy link

Can confirm/reproduce with clang-900.0.39.2

@brandonchinn178
Copy link

Still getting this on Stack 1.7.3. You should be able to repro this with my repo:

  1. Be on a case-insensitive machine
  2. git clone https://github.com/brandonchinn178/snake.git
  3. git checkout 4505c7b4c46a2004924b11f87b915f5ce02b0778
  4. stack build

@qrilka
Copy link
Contributor

qrilka commented Oct 5, 2021

@brandonchinn178 did you mean 2.7.3 maybe?

@brandonchinn178
Copy link

Sorry, yes

@brandonchinn178
Copy link

So it seems like this might be fixed with Cabal 3.6.3.0 (bundled with GHC 9.2)! I added an integration test which fails:

diff --git a/test/integration/tests/3918-non-portable-path/Main.hs b/test/integration/tests/3918-non-portable-path/Main.hs
new file mode 100644
index 00000000..e61b083a
--- /dev/null
+++ b/test/integration/tests/3918-non-portable-path/Main.hs
@@ -0,0 +1,4 @@
+import StackTest
+
+main :: IO ()
+main = stack ["build"]
diff --git a/test/integration/tests/3918-non-portable-path/files/Foo/Bar.hs b/test/integration/tests/3918-non-portable-path/files/Foo/Bar.hs
new file mode 100644
index 00000000..8bce7828
--- /dev/null
+++ b/test/integration/tests/3918-non-portable-path/files/Foo/Bar.hs
@@ -0,0 +1 @@
+module Foo.Bar where
diff --git a/test/integration/tests/3918-non-portable-path/files/Main.hs b/test/integration/tests/3918-non-portable-path/files/Main.hs
new file mode 100644
index 00000000..d82a4bd9
--- /dev/null
+++ b/test/integration/tests/3918-non-portable-path/files/Main.hs
@@ -0,0 +1,4 @@
+module Main where
+
+main :: IO ()
+main = return ()
diff --git a/test/integration/tests/3918-non-portable-path/files/foo.cabal b/test/integration/tests/3918-non-portable-path/files/foo.cabal
new file mode 100644
index 00000000..53ce8fc0
--- /dev/null
+++ b/test/integration/tests/3918-non-portable-path/files/foo.cabal
@@ -0,0 +1,16 @@
+cabal-version: 1.12
+
+name: foo
+version: 0.1.0.0
+build-type: Simple
+
+library
+  exposed-modules: Foo.Bar
+  other-modules: Paths_foo
+  build-depends: base
+
+executable foo
+  main-is: Main.hs
+  other-modules: Paths_foo
+  build-depends: base
+  ghc-options: -Werror
diff --git a/test/integration/tests/3918-non-portable-path/files/stack.yaml b/test/integration/tests/3918-non-portable-path/files/stack.yaml
new file mode 100644
index 00000000..181b3a2e
--- /dev/null
+++ b/test/integration/tests/3918-non-portable-path/files/stack.yaml
@@ -0,0 +1 @@
+resolver: ghc-9.0.2

It succeeds when passing ghc-9.2.4 as the resolver. Inspecting the .stack-work directory, Cabal 3.4 has a different directory structure than 3.6:

├── dist
│   └── aarch64-osx
│       └── Cabal-3.4.1.0
│           ├── build
│           │   ├── Foo
│           │   │   ├── Bar.dyn_hi
│           │   │   ├── Bar.dyn_o
│           │   │   ├── Bar.hi
│           │   │   ├── Bar.o
│           │   │   ├── autogen
│           │   │   │   ├── Paths_foo.hs
│           │   │   │   └── cabal_macros.h
│           │   │   └── foo-tmp
│           │   ├── Paths_foo.dyn_hi
│           │   ├── Paths_foo.dyn_o
│           │   ├── Paths_foo.hi
│           │   ├── Paths_foo.o
│           │   ├── autogen
│           │   │   ├── Paths_foo.hs
│           │   │   └── cabal_macros.h
│           │   ├── libHSfoo-0.1.0.0-DLxW3UjNdJkHmMvLxKbeDf-ghc9.0.2.dylib
│           │   └── libHSfoo-0.1.0.0-DLxW3UjNdJkHmMvLxKbeDf.a
│           ├── build-lock
│           ├── package.conf.inplace
│           │   ├── foo-0.1.0.0-DLxW3UjNdJkHmMvLxKbeDf.conf
│           │   ├── package.cache
│           │   └── package.cache.lock
│           ├── setup-config
│           ├── stack-build-caches
│           │   └── d217be00c2f35f9df4f6d29d392e285d1f0415b093c05ddda1d7a4f0702eab79
│           │       ├── exe-foo
│           │       └── lib
│           ├── stack-cabal-mod
│           ├── stack-project-root
│           └── stack-setup-config-mod
├── dist
│   └── aarch64-osx
│       └── Cabal-3.6.3.0
│           ├── build
│           │   ├── Paths_foo.dyn_hi
│           │   ├── Paths_foo.dyn_o
│           │   ├── Paths_foo.hi
│           │   ├── Paths_foo.o
│           │   ├── autogen
│           │   │   ├── Paths_foo.hs
│           │   │   └── cabal_macros.h
│           │   ├── foo
│           │   │   ├── Bar.dyn_hi
│           │   │   ├── Bar.dyn_o
│           │   │   ├── Bar.hi
│           │   │   ├── Bar.o
│           │   │   ├── autogen
│           │   │   │   ├── Paths_foo.hs
│           │   │   │   └── cabal_macros.h
│           │   │   ├── foo
│           │   │   └── foo-tmp
│           │   │       ├── Main.hi
│           │   │       ├── Main.o
│           │   │       ├── Paths_foo.hi
│           │   │       └── Paths_foo.o
│           │   ├── libHSfoo-0.1.0.0-3Ko25qvmyQMFzMJbqZCtOE-ghc9.2.4.dylib
│           │   └── libHSfoo-0.1.0.0-3Ko25qvmyQMFzMJbqZCtOE.a
│           ├── build-lock
│           ├── package.conf.inplace
│           │   ├── foo-0.1.0.0-3Ko25qvmyQMFzMJbqZCtOE.conf
│           │   ├── package.cache
│           │   └── package.cache.lock
│           ├── setup-config
│           ├── stack-build-caches
│           │   └── 45ea6e7c0570925accf9b6efd2d3c0b8c9bed270cfb88a43d01e39a1d341f488
│           │       ├── exe-foo
│           │       └── lib
│           ├── stack-cabal-mod
│           ├── stack-project-root
│           └── stack-setup-config-mod

jship added a commit to jship/stack-templates that referenced this issue Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants