Discussion:
gnulib and emscripten
(too old to reply)
Bruno Haible
2017-02-10 23:12:07 UTC
Permalink
Raw Message
Hi,

emscripten [1][2] is a C runtime environment, where execution takes place in
JavaScript (NodeJS by default, but some things can also run inside a web
browser).

Just to see how it works out, I built it using the GNU Taler instructions
[3], created a gnulib testdir
$ ./gnulib-tool --create-testdir --dir=testdir-posix --with-tests --single-configure `./posix-modules`
and ran it
$ emconfigure ./configure --host=asmjs-local-emscripten
$ emmake make

Observations
============

I. During the configure run:

I.1. getuid() apparently returns 0, which causes a test to bark:
checking whether mknod can create fifo without root privileges... configure: error: in `/media/private+free/devel/GNULIB/testdir-posix-20170210':
configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
See `config.log' for more details
ERROR:root:Configure step failed with non-zero return code 1! Command line: ['./configure', '--host=asmjs-local-emscripten'] at /media/private+free/devel/GNULIB/testdir-posix-20170210

I have to set FORCE_UNSAFE_CONFIGURE=1.

I.2. checking for working nanosleep... hangs (eating 100% CPU time)
I.3. checking for working sleep... hangs (eating 100% CPU time)

This looks like a bug in the sleep() and nanosleep() functions.

II. "make" failures:

II.1. In module 'fseeko':

fseeko.c:110:4: error: "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
#error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
^
1 error generated.

II.2. In module 'glob':

glob.c:772:27: error: use of undeclared identifier 'malloc_pwtmpbuf'
if (malloc_pwtmpbuf == NULL)
^
glob.c:785:41: error: use of undeclared identifier 'pwtmpbuf'
free (pwtmpbuf);
^
glob.c:793:33: error: use of undeclared identifier 'pwtmpbuf'
free (pwtmpbuf);
^
glob.c:1003:31: error: use of undeclared identifier 'malloc_pwtmpbuf'
free (malloc_pwtmpbuf);
^
glob.c:1015:23: error: use of undeclared identifier 'malloc_pwtmpbuf'
free (malloc_pwtmpbuf);
^
glob.c:1019:23: error: use of undeclared identifier 'malloc_pwtmpbuf'
free (malloc_pwtmpbuf);
^
6 errors generated.

This looks like it is caused by the 2016-05-04 merge from glibc.
These two variables are declared only
if defined HAVE_GETPWNAM_R || defined _LIBC
but then are used unconditionally.

II.3. In module 'tsearch':

In file included from tsearch.c:98:
./search.h:416:3: error: redefinition of enumerator 'preorder'
preorder,
^
/media/private+free/devel/emsdk_portable/emscripten/master/system/include/libc/search.h:14:16: note: previous definition is here
typedef enum { preorder, postorder, endorder, leaf } VISIT;
^
In file included from tsearch.c:98:
./search.h:417:3: error: redefinition of enumerator 'postorder'
postorder,
^
/media/private+free/devel/emsdk_portable/emscripten/master/system/include/libc/search.h:14:26: note: previous definition is here
typedef enum { preorder, postorder, endorder, leaf } VISIT;
^
In file included from tsearch.c:98:
./search.h:418:3: error: redefinition of enumerator 'endorder'
endorder,
^
/media/private+free/devel/emsdk_portable/emscripten/master/system/include/libc/search.h:14:37: note: previous definition is here
typedef enum { preorder, postorder, endorder, leaf } VISIT;
^
In file included from tsearch.c:98:
./search.h:419:3: error: redefinition of enumerator 'leaf'
leaf
^
/media/private+free/devel/emsdk_portable/emscripten/master/system/include/libc/search.h:14:47: note: previous definition is here
typedef enum { preorder, postorder, endorder, leaf } VISIT;
^
In file included from tsearch.c:98:
./search.h:421:1: error: typedef redefinition with different types ('enum VISIT' vs 'enum VISIT')
VISIT;
^
/media/private+free/devel/emsdk_portable/emscripten/master/system/include/libc/search.h:14:54: note: previous definition is here
typedef enum { preorder, postorder, endorder, leaf } VISIT;
^
5 errors generated.

The reason is that this system has <search.h>, and it defines the 'VISIT' enum,
but it does not have the tsearch() function.

III. "make check" trouble

"emmake make check" does not generate executable files. To get something executable,
I had to
- change EXEEXT = .js in Makefile,
- run the tests through a shell loop:
$ for f in test-*.js ; do echo $f ; node $f ; echo $?; done


I'm fixing only the 'tsearch' bug.


[1] https://en.wikipedia.org/wiki/Emscripten
[2] https://github.com/kripken/emscripten
[3] https://git.taler.net/libtalerutil-emscripten.git/tree/README
Paul Eggert
2017-02-12 08:15:29 UTC
Permalink
Raw Message
Post by Bruno Haible
fseeko.c:110:4: error: "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
I couldn't reproduce this problem with emscripten 1.22.1-1build1 as shipped in
Ubuntu 16.04 x86-64.
Looks like a clear bug in gnulib. I installed the attached to try to fix it.
Bruno Haible
2017-02-12 11:07:31 UTC
Permalink
Raw Message
Hi Paul,
Post by Paul Eggert
Looks like a clear bug in gnulib. I installed the attached to try to fix it.
Thanks. Looks all right.
Post by Paul Eggert
I couldn't reproduce this problem with emscripten 1.22.1-1build1 as shipped in
Ubuntu 16.04 x86-64.
That version is from 2014. I'm using the current version, 1.37.0.

Bruno

Loading...