Brian,

The standard method of skirting the LGPL restriction and saving your
source code is to link dynamically in a separate step and then
distribute your program along with the dynamically linked LGPL'd
library.  Compile with ghc -c (or with ghc -c -odir 'separate
directory where you want to store the object files') and pass specific
lines to the linker through gcc with -optc.  Then link the object
files for your program separately using ld and distribute the ghc
runtime libraries you need to dynamically link along with your
program.  Some of these runtime libraries are big but on average
libHSrts_dyn, libHSbase_dyn and libHSbase_cbits_dyn do the trick (I
have needed cbits up for programs that use -ffi).

Bulgat,

Yes, GMP allows the fastest implementation but the problem I posed
with GHC concerned "native" Integers, meaning that the actual
implementation of Integer would be internal to the language
implementation--i.e., not written in Haskell.  I guess--I don't know
GHC's internals apart from reading papers, such as "Haskell on a
Shared-Memory Multiprocessor"--the memory problem would involve adding
"carry" tag to chain thunks and allow lazy arbitrary precision
arithmetic without resorting to program-level constructs like lists or
big arrays.  My point concerning other functional languages (OCaml and
ML through MLton) was that gmp (or gmp-style) programs seem to be a
common way of implementing the representation.  Evolution means
getting beyond that: is there another possibility?

Esa,

I think the idea is to get rid of annoying dependencies (GMP), and not to
create new ones (C++).  There's few other big ifs with APREC as far as I
see: Fiddling with FPU precision regs in x86 and possibly problems in
Windows environment.  It might require a bit fiddling to get memory
handling right when using APREC, as well.

Right on.  I like ARPREC for some programs; it is easy and fast but I
can imagine encountering problems when building it on Windows.  ARPREC
also keeps its own internal memory representation: to use it from c
you essentially have to pass the numbers to its own runtime system
(i.e., you have to initialise ARPREC and allocate memory for a
variable using c_mpnew() before you can use it).  It was just a
suggestion to think about...

-Peter

On 7/30/06, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
Send Glasgow-haskell-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Glasgow-haskell-users digest..."


Today's Topics:

   1. Re: Replacement for GMP as Bignum: ARPREC? Haskell?; OS-X and
      OpenSSL (Seth Kurtzberg)
   2. (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?; OS
      X and OpenSSL ([EMAIL PROTECTED])
   3. Re: Re: Rebuilding GHC on Mac OSX PPC ([EMAIL PROTECTED])
   4. Re: (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?;
      OS X and OpenSSL (Bulat Ziganshin)
   5. Re: (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?;
      OS X and OpenSSL (Esa Ilari Vuokko)
   6. Re: Replacement for GMP as Bignum: ARPREC? Haskell?;      OS-X and
      OpenSSL (Brian Hulley)
   7. Re: Replacement for GMP as Bignum: ARPREC? Haskell?;      OS-X and
      OpenSSL (Esa Ilari Vuokko)
   8. Re: Replacement for GMP as Bignum: ARPREC? Haskell?; OS-X and
      OpenSSL (Duncan Coutts)
   9. Re: Replacement for GMP as Bignum: ARPREC? Haskell?;      OS-X and
      OpenSSL (Brian Hulley)


----------------------------------------------------------------------

Message: 1
Date: Sat, 29 Jul 2006 22:09:45 -0400
From: Seth Kurtzberg <[EMAIL PROTECTED]>
Subject: Re: Replacement for GMP as Bignum: ARPREC? Haskell?; OS-X and
        OpenSSL
To: [EMAIL PROTECTED]
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII

On Sat, 29 Jul 2006 21:45:21 -0400
[EMAIL PROTECTED] wrote:

> GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum library, 
BN.
> I have two questions concerning this:
>
> (1) Why not use the ARbitrary PRECision Computation Package (ARPREC)
> by David Bailey, Yozo Hida, Karthik Jeyabalan, Xiaoye Li and Brandon
> Thompson?  Here is a reference web page:
> http://crd.lbl.gov/~dhbailey/mpdist/
>
> ARPREC is written in C++ but supports calls from C (see
> include/arprec/c_mp.h in the distribution directory).  ARPREC is very
> fast and supports more complex mathematics than BN.  The Licensing for
> ARPREC is not a problem: essentially similar to BSD3.
>
> Note that there would be a basic configuration fix for building
> OpenSSL's BN library on OS 10.4: you would probably--I had to,
> myself--have to temporarily move the default installation of
> /usr/lib/libssl0.9.dylib (and variants) if you want to create a shared
> (.a) library because Apple's ln links dynamic libraries in preference
> to shared libraries.

I think you meant "if you want to create a static (.a) library", not "if you want to 
create a shared (.a) library"

  Those of you who have some experience with
> Apple's gcc also know that Apple's gcc does not recognise the -shared
> flag.
>
> (2) A much more aesthetic solution would be to replace any external
> Bignum library with a pure Haskell library.  There are many problems
> with building a truly efficient and fast Bignum library in Haskell but
> challenges like that are how languages evolve...
>
> -Peter Tanski
> _______________________________________________
> Glasgow-haskell-users mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>


------------------------------

Message: 2
Date: Sat, 29 Jul 2006 23:21:07 -0400
From: [EMAIL PROTECTED]
Subject: (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?;      OS
        X and OpenSSL
To: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

(Sorry for the repost: I needed to correct a few typos--thanks
Seth--and clarify a few things.)

GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum library, BN.
I have two questions concerning this:

(1) Why not use the ARbitrary PRECision Computation Package (ARPREC)
by David Bailey, Yozo Hida, Karthik Jeyabalan, Xiaoye Li and Brandon
Thompson?  Here is a reference web page:
http://crd.lbl.gov/~dhbailey/mpdist/

ARPREC is written in C++ but supports calls from C (see
include/arprec/c_mp.h in the distribution directory).  ARPREC is very
fast and supports more complex mathematics than BN.  The Licensing for
ARPREC is not a problem: essentially similar to BSD3.

Note that there would be a basic configuration fix for building
OpenSSL's BN library on OS 10.4: you would probably--I had to,
myself--have to temporarily move the default installation of
/usr/lib/libssl0.9.dylib (and variants) if you want to create a static
(.a) library because Apple's ln links dynamic libraries in preference
to static libraries.

(2) A much more aesthetic solution would be to replace any external
Bignum library with a pure Haskell library.  There are many problems
with building a truly efficient and fast Bignum library in Haskell but
challenges like that are how languages evolve...  Both GHC and nhc98
seem to use GMP, OCaml uses a custom bignum library written by Xavier
Leroy and even MLton uses GMP.  Robert Dockins wrote a type-based
library for arbitrary that can (slowly) handle big numbers (up to
10^15), see http://www.eecs.tufts.edu/~rdocki01/typenats.html  I don't
know what the constraints on making such native Integer support work
in GHC but my comment on the evolution of Haskell was not meant badly:
native Integer support would require modifications to how Integers are
handled in memory.  (I would be glad to lend whatever support I could
on this, but it seems like a big project.)

-Peter Tanski


------------------------------

Message: 3
Date: Sun, 30 Jul 2006 00:29:43 -0400
From: [EMAIL PROTECTED]
Subject: Re: Re: Rebuilding GHC on Mac OSX PPC
To: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Sorry to flood your mailboxes with my junk, but I had a few questions
on the configuration and Makefiles for building GHC on OS 10.4:

The odd memory bugs (wierd malloc errors) seem to remind me of errors
using pthreads...

in Joel Reymont's email, I noticed that ghc is given the -threaded option:

../../ghc/compiler/stage1/ghc-inplace -o stage2/ghc-6.4.3 ...
... -threaded     -package readline -DUSE_READLINE -

I have not had any luck using -threaded with GHC on my own programs,
but I do not know what options GHC passes to gcc with -threaded.  If
GHC -threaded means it passes gcc
the -pthread option when compiling -fvia-C, the problem might be that
Apple's gcc does not recognize the -pthread flag (you have to link
-lpthread manually, preferably after the object files).

If I can get the configuration correct--or whatever parameters you
think you might want--I will get a clean distribution and try to build
ghc-6.4.3 tomorrow (I am using a 1.25 MHz PPC).

-Peter Tanski


------------------------------

Message: 4
Date: Sun, 30 Jul 2006 10:35:20 +0400
From: Bulat Ziganshin <[EMAIL PROTECTED]>
Subject: Re: (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?;
        OS X and OpenSSL
To: [EMAIL PROTECTED]
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

Hello p,

Sunday, July 30, 2006, 7:21:07 AM, you wrote:

> Leroy and even MLton uses GMP.  Robert Dockins wrote a type-based
> library for arbitrary that can (slowly) handle big numbers (up to
> 10^15), see http://www.eecs.tufts.edu/~rdocki01/typenats.html  I don't

this don't have anything common with our problem of implementing
efficient runtime library

> know what the constraints on making such native Integer support work
> in GHC but my comment on the evolution of Haskell was not meant badly:
> native Integer support would require modifications to how Integers are
> handled in memory.  (I would be glad to lend whatever support I could
> on this, but it seems like a big project.)

imho, you are wrong. current representation allows fastest operations.
but anyway Haskell code will be several times slower than C one - even
for GHC, much more for Haskell interpreters


--
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]



------------------------------

Message: 5
Date: Sun, 30 Jul 2006 13:00:24 +0300
From: "Esa Ilari Vuokko" <[EMAIL PROTECTED]>
Subject: Re: (Repost) Replacement for GMP as Bignum: ARPREC? Haskell?;
        OS X and OpenSSL
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi

On 7/30/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> (Sorry for the repost: I needed to correct a few typos--thanks
> Seth--and clarify a few things.)
>
> GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum library, 
BN.
> I have two questions concerning this:
>
> (1) Why not use the ARbitrary PRECision Computation Package (ARPREC)
> by David Bailey, Yozo Hida, Karthik Jeyabalan, Xiaoye Li and Brandon
> Thompson?  Here is a reference web page:
> http://crd.lbl.gov/~dhbailey/mpdist/
>
> ARPREC is written in C++ but supports calls from C (see
> include/arprec/c_mp.h in the distribution directory).  ARPREC is very
> fast and supports more complex mathematics than BN.  The Licensing for
> ARPREC is not a problem: essentially similar to BSD3.

I think the idea is to get rid of annoying dependencies (GMP), and not to
create new ones (C++).  There's few other big ifs with APREC as far as I
see: Fiddling with FPU precision regs in x86 and possibly problems in
Windows environment.  It might require a bit fiddling to get memory
handling right when using APREC, as well.

In past, I tried to get rid of GMP by replacing it with libtommath
http://math.libtomcrypt.com/
But I have given up for now - because of related and unrelated problems.

But, whoever starts the work probably gets to pick their lib, so OpenSSL's
BN, APREC, LibTomMath or anything else...it's open :-)

Best regards,
Esa


------------------------------

Message: 6
Date: Sun, 30 Jul 2006 11:53:30 +0100
From: "Brian Hulley" <[EMAIL PROTECTED]>
Subject: Re: Replacement for GMP as Bignum: ARPREC? Haskell?;   OS-X and
        OpenSSL
To: <[EMAIL PROTECTED]>, <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
        reply-type=response

[EMAIL PROTECTED] wrote:
> GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum
> library, BN. I have two questions concerning this:

>From the ticket, this looks very scary:

          but its LGPL license is problematic for users of GHC
         (it prohibits static linking of GHC-compiled programs, for
example).

Does this mean I can't distribute my Haskell app as a commercial
application? I certainly don't want to distribute source code and I've got
no idea how to compile a Haskell app other than using ghc --make, which
creates a single exe ie with static linkage.

If I only use Int's (not Integer's) in my code, is there a way to get rid of
GMP so that I won't have an impossible licencing problem when trying to
distribute my application binary? If not, then it would seem absolutely
vital to get rid of GMP as soon as possible or else try to persuade the
authors to add the usual static linking exception to their LGPL licence for
it.

Thanks, Brian.

--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com



------------------------------

Message: 7
Date: Sun, 30 Jul 2006 14:18:30 +0300
From: "Esa Ilari Vuokko" <[EMAIL PROTECTED]>
Subject: Re: Replacement for GMP as Bignum: ARPREC? Haskell?;   OS-X and
        OpenSSL
To: "Brian Hulley" <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED], [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 7/30/06, Brian Hulley <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum
> > library, BN. I have two questions concerning this:
>
> >From the ticket, this looks very scary:
>
>           but its LGPL license is problematic for users of GHC
>          (it prohibits static linking of GHC-compiled programs, for
> example).
>
> Does this mean I can't distribute my Haskell app as a commercial
> application? I certainly don't want to distribute source code and I've got

I am not a lawyer, and you should consult lawyer if you want real
advice about licensing issues.

Strict answer to first question: No.  You can distribute statically compiled
binaries.

> no idea how to compile a Haskell app other than using ghc --make, which
> creates a single exe ie with static linkage.

But in this case, yes, you can't.  You need to provide way to
relink gmp in you program.  As far as I know, this is simply possible
by taking all the objs --make generates, other objs and libs and giving
them on - users need to have ghc distro+their own gmp set in.

> If I only use Int's (not Integer's) in my code, is there a way to get rid of
> GMP so that I won't have an impossible licencing problem when trying to

I am fairly certain you cannot force or rely GMP getting dropped by
linker.

> distribute my application binary? If not, then it would seem absolutely
> vital to get rid of GMP as soon as possible or else try to persuade the
> authors to add the usual static linking exception to their LGPL licence for
> it.

GMP being rather GNU ;-) replacing is probably the only option.

There's other reason for dropping GMP as well: The ghc rts steals GMP
memory allocation (sort of integrating it with garbage collector) which
makes it impossible for other parts of program use GMP (in practice).

HTH,
--Esa


------------------------------

Message: 8
Date: Sun, 30 Jul 2006 12:58:09 +0100
From: Duncan Coutts <[EMAIL PROTECTED]>
Subject: Re: Replacement for GMP as Bignum: ARPREC? Haskell?; OS-X and
        OpenSSL
To: Brian Hulley <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED], [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain

On Sun, 2006-07-30 at 11:53 +0100, Brian Hulley wrote:
> [EMAIL PROTECTED] wrote:
> > GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum
> > library, BN. I have two questions concerning this:
>
> >From the ticket, this looks very scary:
>
>           but its LGPL license is problematic for users of GHC
>          (it prohibits static linking of GHC-compiled programs, for
> example).
>
> Does this mean I can't distribute my Haskell app as a commercial
> application? I certainly don't want to distribute source code and I've got
> no idea how to compile a Haskell app other than using ghc --make, which
> creates a single exe ie with static linkage.

GHC only statically links Haskell code. It dynamically links to GMP and
the system C library and other C libs.

So you're fine.

On unix you can check for yourself with ldd. It lists all the shared
libs that your program needs. For example:

$ ldd /usr/lib/ghc-6.4.2/ghc-6.4.2
        libreadline.so.5 => /lib/libreadline.so.5 (0x00002b568fca6000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00002b568fde3000)
        libdl.so.2 => /lib/libdl.so.2 (0x00002b568ff3f000)
        libm.so.6 => /lib/libm.so.6 (0x00002b5690042000)
        libgmp.so.3 => /usr/lib/libgmp.so.3 (0x00002b569019a000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002b56902cf000)
        libc.so.6 => /lib/libc.so.6 (0x00002b56903e4000)
        /lib64/ld-linux-x86-64.so.2 (0x00002b568fb8e000)

Duncan



------------------------------

Message: 9
Date: Sun, 30 Jul 2006 13:21:12 +0100
From: "Brian Hulley" <[EMAIL PROTECTED]>
Subject: Re: Replacement for GMP as Bignum: ARPREC? Haskell?;   OS-X and
        OpenSSL
To: "Esa Ilari Vuokko" <[EMAIL PROTECTED]>
Cc: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
        reply-type=response

Esa Ilari Vuokko wrote:
> On 7/30/06, Brian Hulley <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>> GHC Task Ticket # 601 suggests replacing GMP with OpenSSL's Bignum
>>> library, BN. I have two questions concerning this:
>>
>>> From the ticket, this looks very scary:
>>
>>           but its LGPL license is problematic for users of GHC
>>          (it prohibits static linking of GHC-compiled programs, for
>> example).
[snip]
> But in this case, yes, you can't.  You need to provide way to
> relink gmp in you program.  As far as I know, this is simply possible
> by taking all the objs --make generates, other objs and libs and
> giving them on - users need to have ghc distro+their own gmp set in.

Hi Esa -
Thanks for reminding me about the distinction between source and object
files. I keep forgetting that object files exist (!) and that it's
sufficient for LGPL to just make them available.

Still, a slight problem is that since there is one object file per source
file, the names of the object files give quite a lot of information away
about the structure of the program especially when they are arranged in a
module hierarchy, so I'll be glad when GMP is replaced by something without
such a burdensome licence. (Although perhaps I can bundle my object files
into a single library file but I don't know how to do this yet, or if it
would really help in the goal to make the code completely obfuscated,
impenetrable, and unavailable to any rival company... ;-) )

Thanks again,
Brian.
--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com



------------------------------

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


End of Glasgow-haskell-users Digest, Vol 35, Issue 23
*****************************************************

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to