-
Notifications
You must be signed in to change notification settings - Fork 841
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
local packages with c-sources give runtime errors in stack ghci #1239
Comments
@chrisdone, any ideas? |
I cannot reproduce this issue with another package which has C source files,
@vagifverdi Can you please give a set of steps for reproducing the problem? |
@mgsloan You need to create a separate project that refers to the cloned package. packages:
Also, Not every call fails. Only the ones that call a code from the c files in that cloned package. |
Even with process as a separate package, I don't get this error. Being in a separate package really has no affect on GHCI, since it loads all the modules together anyway.
It'd be great to have a repro that's more minimal than a usage of hdbc. Or if you could point me to your project (if it has instructions for setting it up). As is, I keep on spending time attempting to construct a repro for this, and not getting anywhere. Also, does this happen with the development version of stack ( |
i'll try to build a minimal example. |
You are right. It is not related to c-sources generally. process package works for me too. But hdbc-odbc does not. It works fine if stack build or in cabal repl, but not in stack ghci Here are the steps to reproduce:
remove all test build targets from cabal file, just leave library. Put this stack.yaml in there:
stack build works fine. Then do stack ghci
Inside stack ghci trying to run test_foo will give you first the error that it could not connect to database (which is normal since you did not supply connection string), But then it will give you the symbol lookup error: /usr/local/lib/ghc-7.10.2/bin/ghc: symbol lookup error: /tmp/ghc25980_0/libghc_1.so: |
Thanks for the repro! I installed libodbc via I do indeed get the following output:
Very strange! I'll look into this more later, but I'm starting to think that this is a GHC issue. In particular, this is probably the case if |
I've been using hdbc-odbc in haskell-mode with repl for years. It works fine. As far as i remember haskell-mode uses cabal repl for its session. Anyway, testing cabal repl should be quite easy, just to rule it out. |
I work with @vagifverdi and we did some troubleshooting of this today. As confirmed by @mgsloan However, there is another scenario that we're interested in. We have another project that depends on hdbc-odbc and we're able to run resolver: lts-5.0
packages:
- '.'
- '../hdbc-odbc' However, this stack.yaml works fine with resolver: lts-5.0
packages:
- '.'
- location: /home/sidev/hdbc-odbc
extra-dep: true I don't know enough about stack to know whether this is a bug or intentional behavior. |
Interesting! I haven't checked, but I'm thinking that in the first case, the code gets loaded into ghci, whereas in the 2nd case it gets used as a dependency. What happens if you do |
I'm fighting some like that for a few weeks already. But my struggle is with
|
@wiz Sounds like something that should get reported to the |
In case another example is helpful https://github.com/cocreature/nanovg-hs suffers from the same problem although in this case the unknown symbol is |
I can repro this using the
|
@mboes You might want to try using |
@cocreature interesting. Doesn't seem to help in this case. |
@cocreature I'm not sure I understand why |
@mboes I stole that solution from deech’s fltkhs bindings. I sadly can’t tell you what exactly it does or why it works, I just know that it did :) |
@mgsloan @chrisdone so I found a hacky workaround, if that can help point towards a solution. The idea is to load the object file corresponding to the local C file with a missing symbol manually:
Perhaps the right logic to add to Stack is: "for each file in |
@mboes That sounds like a quite likely solution! |
Aha! It turns out |
Good news! @mboes committed an elegant PR resolving this. Great stuff! I didn't realize it could be so straightforward. |
To be clear, I'm not sure that PR #2242 fixes all instances of this error in |
if you point to a package source code located on the hard drive and that package has c source files, it will give runtime errors in stack ghci.
For example hdbc-odbc errors out in stack ghci when trying to connect to db. It gives following error:
/usr/local/lib/ghc-7.10.2/bin/ghc: symbol lookup error: /tmp/ghc25980_0/libghc_1.so: undefined symbol: SQLSetConnectAttr
The function SQLSetConnectAttr is calling a c module hdbc-odbc-helper.c that is bundled with hdbc-odbc package.
Loading hdbc-odbc from hackage works fine in stack ghci.
Stack build also works fine.
The text was updated successfully, but these errors were encountered: