jameysharp / corrode

C to Rust translator
GNU General Public License v2.0
2.16k stars 116 forks source link

Error while building on macOS #117

Open abhi18av opened 7 years ago

abhi18av commented 7 years ago

Hi @jameysharp

FIrst off, I think this is an amazing project and a great contribution to community - Thanks 😄

I wanted to try this on some small c files but I'm unable to stack install corrode properly.

corrode git/master
❯ stack setup
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-7.10.3.
Installed GHC.                                                  stack will use a locally installed GHC
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

corrode git/master  804s
❯ stack install
[1 of 1] Compiling Main             ( /private/var/folders/vt/9ywhthp94tz2b_23l97x9zcc0000gn/T/stack5939/Setup.hs, /private/var/folders/vt/9ywhthp94tz2b_23l97x9zcc0000gn/T/stack5939/Setup.o )
Linking /Users/eklavya/.stack/setup-exe-cache/x86_64-osx/tmp-setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 ...
base-compat-0.9.1: configure
base-compat-0.9.1: build
mtl-2.2.1: download
primitive-0.6.1.0: download
random-1.1: download
primitive-0.6.1.0: configure
primitive-0.6.1.0: build
random-1.1: configure
base-compat-0.9.1: copy/register
random-1.1: build
mtl-2.2.1: configure
mtl-2.2.1: build
markdown-unlit-0.4.0: download
markdown-unlit-0.4.0: configure
markdown-unlit-0.4.0: build
markdown-unlit-0.4.0: copy/register
primitive-0.6.1.0: copy/register
mtl-2.2.1: copy/register
syb-0.6: download
random-1.1: copy/register
happy-1.19.5: download
syb-0.6: configure
tf-random-0.5: download
syb-0.6: build
tf-random-0.5: configure
tf-random-0.5: build
happy-1.19.5: configure
syb-0.6: copy/register
tf-random-0.5: copy/register
happy-1.19.5: build
QuickCheck-2.8.2: download
QuickCheck-2.8.2: configure
QuickCheck-2.8.2: build
happy-1.19.5: copy/register
QuickCheck-2.8.2: copy/register
alex-3.1.7: download
alex-3.1.7: configure
alex-3.1.7: build
alex-3.1.7: copy/register
language-c-0.5.0: download
language-c-0.5.0: configure
language-c-0.5.0: build
language-c-0.5.0: copy/register
corrode-0.1.0.0: configure
Configuring corrode-0.1.0.0...
corrode-0.1.0.0: build
Preprocessing library corrode-0.1.0.0...

/Users/eklavya/Projects/Amsterdam/COMPILER_INTERPRETER/corrode/src/Language/Rust/Corrode/C.lhs:1:1:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘Language.Rust.Corrode.C’
Completed 12 action(s).

--  While building package corrode-0.1.0.0 using:
      /Users/eklavya/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:corrode exe:corrode --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

Could you please help me out?

This project can be a life saver for me right now.

abhi18av commented 7 years ago

I've been careful with the install


corrode git/master
❯ stack setup
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-7.10.3.
Installed GHC.                                                  stack will use a locally installed GHC
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
abhi18av commented 7 years ago

I've been trying to set it up again, used the very basic cabal install things


❯ cabal install
Resolving dependencies...
Configuring corrode-0.1.0.0...
Building corrode-0.1.0.0...
Failed to install corrode-0.1.0.0
Build log ( /Users/eklavya/.cabal/logs/corrode-0.1.0.0.log ):
cabal: Entering directory '.'
Configuring corrode-0.1.0.0...
Building corrode-0.1.0.0...
Preprocessing library corrode-0.1.0.0...

src/Language/Rust/Corrode/C.lhs:1:1: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘Language.Rust.Corrode.C’
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
corrode-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1
jameysharp commented 7 years ago

Sorry it's taken me a while to get back to you! I have a couple questions:

Is src/Language/Rust/Corrode/C.lhs empty in your checkout?

Which filesystem type is your home directory on?

I'm guessing that error message means the compiler didn't see any source text in the file. We've previously seen this happen on Windows due to weird handling of symbolic links there. If you aren't using the Mac default of HFS+ I could imagine symlinks might be a problem for you too.

abhi18av commented 7 years ago

No issues, I understand :)

Yes, the contents of the C.lhs are,

C.md

And regarding the information about the machine, still running on Yosemite

❯ uname -a
Darwin abhinavs-MBP.Home 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
0rvar commented 7 years ago

I have the same problem on Windows 10 64bit, compiling latest master (34053342c2f1ca04f23ad94d) with stack build

0rvar commented 7 years ago

I could bypass the problem by removing the .lhs files with .md links and renaming the .md files to .lhs

joseluisq commented 6 years ago

I got a similar error on OSX too:

~> cabal install
Resolving dependencies...
Downloading base-compat-0.10.4...
Downloading syb-0.7...
Configuring syb-0.7...
Configuring base-compat-0.10.4...
Building syb-0.7...
Building base-compat-0.10.4...
Installed syb-0.7
Downloading language-c-0.6.1...
Configuring language-c-0.6.1...
Building language-c-0.6.1...
Installed base-compat-0.10.4
Downloading markdown-unlit-0.5.0...
Configuring markdown-unlit-0.5.0...
Building markdown-unlit-0.5.0...
Installed markdown-unlit-0.5.0
Failed to install language-c-0.6.1
Build log ( /Users/jq/.cabal/logs/ghc-8.4.3/language-c-0.6.1-5v6oYERi1tRAptXLR6wS7O.log ):
cabal: Entering directory '/var/folders/5y/qnqlwlt14mz19xvmpvtnwrzr0000gn/T/cabal-tmp-10665/language-c-0.6.1'
Configuring language-c-0.6.1...
Preprocessing library for language-c-0.6.1..
Building library for language-c-0.6.1..
[ 1 of 39] Compiling Language.C.Analysis.NameSpaceMap ( src/Language/C/Analysis/NameSpaceMap.hs, dist/build/Language/C/Analysis/NameSpaceMap.o )
[ 2 of 39] Compiling Language.C.Data.InputStream ( src/Language/C/Data/InputStream.hs, dist/build/Language/C/Data/InputStream.o )
[ 3 of 39] Compiling Language.C.Data.Name ( src/Language/C/Data/Name.hs, dist/build/Language/C/Data/Name.o )
[ 4 of 39] Compiling Language.C.Data.Position ( src/Language/C/Data/Position.hs, dist/build/Language/C/Data/Position.o )
[ 5 of 39] Compiling Language.C.Data.Node ( src/Language/C/Data/Node.hs, dist/build/Language/C/Data/Node.o )
[ 6 of 39] Compiling Language.C.Data.Ident ( src/Language/C/Data/Ident.hs, dist/build/Language/C/Data/Ident.o )
[ 7 of 39] Compiling Language.C.Data.Error ( src/Language/C/Data/Error.hs, dist/build/Language/C/Data/Error.o )
[ 8 of 39] Compiling Language.C.Data  ( src/Language/C/Data.hs, dist/build/Language/C/Data.o )
[ 9 of 39] Compiling Language.C.Data.RList ( src/Language/C/Data/RList.hs, dist/build/Language/C/Data/RList.o )
[10 of 39] Compiling Language.C.Parser.Builtin ( src/Language/C/Parser/Builtin.hs, dist/build/Language/C/Parser/Builtin.o )
[11 of 39] Compiling Language.C.Syntax.Constants ( src/Language/C/Syntax/Constants.hs, dist/build/Language/C/Syntax/Constants.o )
[12 of 39] Compiling Language.C.Parser.Tokens ( src/Language/C/Parser/Tokens.hs, dist/build/Language/C/Parser/Tokens.o )
[13 of 39] Compiling Language.C.Parser.ParserMonad ( src/Language/C/Parser/ParserMonad.hs, dist/build/Language/C/Parser/ParserMonad.o )
[14 of 39] Compiling Language.C.Parser.Lexer ( dist/build/Language/C/Parser/Lexer.hs, dist/build/Language/C/Parser/Lexer.o )
[15 of 39] Compiling Language.C.Syntax.Ops ( src/Language/C/Syntax/Ops.hs, dist/build/Language/C/Syntax/Ops.o )
[16 of 39] Compiling Language.C.Syntax.AST ( src/Language/C/Syntax/AST.hs, dist/build/Language/C/Syntax/AST.o )
[17 of 39] Compiling Language.C.Syntax ( src/Language/C/Syntax.hs, dist/build/Language/C/Syntax.o )
[18 of 39] Compiling Language.C.Pretty ( src/Language/C/Pretty.hs, dist/build/Language/C/Pretty.o )

src/Language/C/Pretty.hs:60:40: error:
    Ambiguous occurrence ‘<>’
    It could refer to either ‘Prelude.<>’,
                             imported from ‘Prelude’ at src/Language/C/Pretty.hs:15:8-24
                             (and originally defined in ‘GHC.Base’)
                          or ‘Text.PrettyPrint.HughesPJ.<>’,
                             imported from ‘Text.PrettyPrint.HughesPJ’ at src/Language/C/Pretty.hs:23:1-32
   |
60 | attrlistP attrs = text "__attribute__" <> parens (parens (hcat . punctuate comma . map pretty $ attrs))
   |                                        ^^

The entire log is here: https://pastebin.com/5Vhc8GGk

Packages:

~> gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

~> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.4.3

~> cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.1 of the Cabal library
fogti commented 5 years ago

I get this error on linux, too (even after renaming).

Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Configuring corrode-0.1.0.0...
Building corrode-0.1.0.0...
Failed to install corrode-0.1.0.0
Build log ( .../.cabal/logs/corrode-0.1.0.0.log ):
cabal: Entering directory '.'
Configuring corrode-0.1.0.0...
Building corrode-0.1.0.0...
Preprocessing library corrode-0.1.0.0...

src/Language/Rust/Corrode/C.lhs:1:1: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘Language.Rust.Corrode.C’
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
corrode-0.1.0.0 failed during the building phase. The exception was:
ExitFailure 1
~> gcc --version
gcc (Gentoo 8.3.0-r1 p1.1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
~> cabal --version
cabal-install version 1.24.0.2
compiled using version 1.24.2.0 of the Cabal library