Code Monkey home page Code Monkey logo

Comments (10)

asr avatar asr commented on August 15, 2024

Any comment about this issue?

from uhc.

phile314 avatar phile314 commented on August 15, 2024

@asr It's probably easiest to just disable the float equality primitive in the UHC backend (for now). I can do that if you don't mind?

from uhc.

asr avatar asr commented on August 15, 2024

OK. Please file an Agda issue about it.

from uhc.

atzedijkstra avatar atzedijkstra commented on August 15, 2024

If the extracted/unpacked sources from the ieee746 package are on the search path of UHC then both .hs and .c should be picked up and compiled. C compilation is integrated into UHC for the 'bc' (default) backend.

from uhc.

asr avatar asr commented on August 15, 2024

I downloaded the ieee754 package on the ~/tmp-asr/ieee754-0.7.8 directory using cabal get ieee754.

Now adding the -i command-line option I got the following error:

$ uhc -i ~/tmp-asr/ieee754-0.7.8/ Test.hs
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3797:16: error: ‘feqrelf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3799:16: error: ‘mknan’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3801:16: error: ‘ieeemeanf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3803:16: error: ‘mknanf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3805:16: error: ‘nextdownf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3807:16: error: ‘nextup’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3809:16: error: ‘getnanf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3811:16: error: ‘ieeemean’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3813:16: error: ‘getnan’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3815:16: error: ‘feqrel’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3817:16: error: ‘nextupf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3819:16: error: ‘nextdown’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3820:16: error: ‘identicalf’ undeclared here (not in a function)
/home/asr/tmp-asr/ieee754-0.7.8//Numeric/IEEE.c:3822:16: error: ‘identical’ undeclared here (not in a function)

Note that the IEEE.c: file is generated by UHC.

Note also I fixed a typo in the OP: ieee746 -> ieee754

Am I missing something?

from uhc.

atzedijkstra avatar atzedijkstra commented on August 15, 2024

UHC does not know which .c files to compile, i.e. there is not a real import mechanism like in Haskell nor a cabal spec & mechanism. .c files of which the .h file is used still have to be explicitly specified on the commandline invocation of UHC.

from uhc.

asr avatar asr commented on August 15, 2024

A MVE:

$ cat Test.hs
module Main where

foreign import ccall "id" c_id :: Double -> Double

main = print (c_id 1.0)
$ cat id.c
int
id (double x)
{
  return x;
}

Using GHC:

$ ghc Test.hs id.c
$ ./Test 
1.0

Using UHC:

$ uhc Test.hs id.c
[1/2] Compiling C                        id                     (id.c)
[2/2] Compiling Haskell                  Main                   (Test.hs)
Test.c:162:16: error: ‘id’ undeclared here (not in a function)

What else do I need to include when invoking UHC?

from uhc.

atzedijkstra avatar atzedijkstra commented on August 15, 2024

The "id" in the import should (as per FFI spec for Haskell) refer to an include file, say id.h, mentioning id via an extern declaration. The "id" should be "id.h id". That ought to do it...

A

On 28 Sep 2016, at 17:51, Andrés Sicard-Ramírez [email protected] wrote:

A MVE:

$ cat Test.
hs

module Main where

foreign import ccall "id" c_id :: Double -> Double

main =
print (c_id 1.0
)

foreign import ccall "identical" c_identical :: Double -> Double

main =
print (c_identical 1.0)
$ cat id.c

int
id (double
x)
{

return
x;
}

Using GHC:

$ ghc Test.hs id.c
$ ./Test
1.0

Using UHC:

Using UHC:

$ uhc Test.hs id.c
[1/2] Compiling C id (id.c)
[2/2] Compiling Haskell Main (Test.hs)
Test.c:162:16: error: ‘id’ undeclared here (not in a function)

What else do I need to include when invoking UHC?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

from uhc.

asr avatar asr commented on August 15, 2024

That works. Thanks!

from uhc.

asr avatar asr commented on August 15, 2024

For future reference, I add the fixed example:

$ cat Test.hs
module Main where

foreign import ccall "id.h id" c_id :: Double -> Double

main = print (c_id 1.0)
$ cat id.h
int id (double x);
$ cat id.c
int
id (double x)
{
  return x;
}

Using GHC:

$ ghc Test.hs id.c

Using UHC:

$ uhc Test.hs id.h

from uhc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.