Re: [Ur] about the -static compiler flag

2018-11-23 Thread Benjamin Barenblat
On Friday, November 23, 2018, at  8:00 AM EST, Adam Chlipala wrote:
> I'm always interested in PRs that substitute behavior-equivalent code
> that relies less on functions from outside appropriate standards like
> POSIX (assuming said PRs don't bring in tons of hard-to-maintain code). 
> Is timelocal such a case?

The glibc man page for timelocal says, “The timelocal() function is
equivalent to the POSIX standard function mktime(3). There is no reason
to ever use it.” mktime is actualy a standard C function, which is
probably even better than POSIX. So yes, timelocal is a GNU extension
with an analogue in standard C. A global s/timelocal/mktime/ in the
source code would probably have the desired effect.

___
Ur mailing list
Ur@impredicative.com
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur


Re: [Ur] about the -static compiler flag

2018-11-23 Thread Adam Chlipala

On 11/23/18 5:04 AM, Chris Double wrote:

It's possible to get a complete static executable from urweb by using
musl-libc [1] and a workaround. I tried with a simple "hello world"
type project, with musl installed:

$ urweb -protocol http -output test -ccompiler musl-gcc -static hello1


Neat!  So just running the 'configure' script with the right arguments 
can enable the right command line.



Would you be interested in a PR for replacing timelocal usage?
I'm always interested in PRs that substitute behavior-equivalent code 
that relies less on functions from outside appropriate standards like 
POSIX (assuming said PRs don't bring in tons of hard-to-maintain code).  
Is timelocal such a case?


___
Ur mailing list
Ur@impredicative.com
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur


Re: [Ur] about the -static compiler flag

2018-11-23 Thread Chris Double
On Fri, Nov 23, 2018 at 11:04 PM Chris Double  wrote:
> It's possible to get a complete static executable from urweb by using
> musl-libc [1] and a workaround. I tried with a simple "hello world"
> type project, with musl installed:

A quick gist going through the steps to build a static executable with
musl is at https://gist.github.com/doublec/c723924fd252cd4cf6774ed84d1edbe8

-- 
https://bluishcoder.co.nz

___
Ur mailing list
Ur@impredicative.com
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur


Re: [Ur] about the -static compiler flag

2018-11-23 Thread Chris Double
On Wed, Oct 31, 2018 at 8:28 AM Adam Chlipala  wrote:
>
> I don't know if this GitHub issue is related, but in general I made a token 
> effort (about 10 years ago) to support static linking by adding one flag to 
> the GCC/Clang command line, and it has been clear for years that more 
> modifications are needed somehow.  I don't intend to research them myself 
> since I literally always use dynamic linking for Ur/Web apps, but I would be 
> very glad to see related PRs.

It's possible to get a complete static executable from urweb by using
musl-libc [1] and a workaround. I tried with a simple "hello world"
type project, with musl installed:

$ urweb -protocol http -output test -ccompiler musl-gcc -static hello1
/usr/bin/ld: /usr/local/lib/liburweb.a(urweb.o): in function
`uw_Basis_fromDatetime':
urweb/src/c/urweb.c:4241: undefined reference to `timelocal'
collect2: error: ld returned 1 exit status

Unfortunately musl doesn't support 'timelocal'. I created a stub for
this by a definition in a 'time.c', compiling it with musl-gcc, and
adding a "link time.o" in my urweb project. This worked, and I got a
static executable that run and served the example project.

As well as the 'timelocal' stub, I had to compile openssl and libz as
static libraries installed in /usr/local/musl' to link to them
statically.

Would you be interested in a PR for replacing timelocal usage?

[1] https://www.musl-libc.org/

-- 
http://bluishcoder.co.nz

___
Ur mailing list
Ur@impredicative.com
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur