Porting `gawk` to NaCl (nexe) which can be run on Dev Environment

166 views
Skip to first unread message

Ashish Gaurav

unread,
Mar 17, 2015, 1:40:28 PM3/17/15
to native-cli...@googlegroups.com
As an example project, I'm trying to port `gawk` to NaCl. Specifically, I wish to create a nexe that runs gawk in NaCl Dev Env. I don't see a port of `gawk` as such in the naclports `ports` folder. I've written a build.sh which doesn't (as for now) work. Here's the code :


ConfigureStep() {
 
SetupCrossEnvironment
  NACLPORTS_CPPFLAGS
+=" -Dmain=nacl_main -D__GNU_LIBRARY__ -fPIC"
 
export LIBS+="${NACL_CLI_MAIN_LIB} -lppapi_simple -lnacl_io -lppapi -lpthread -l${NACL_CPP_LIB}"
 
DefaultConfigureStep
}


BuildStep() {
 
DefaultBuildStep
}


PublishStep() {
 
PublishByArchForDevEnv
}


However, the challenge is the fact that `gawk` uses its personal `getopt.c`, which is by default included in GNU C Library, and thus the NaCl C library. Thus, upon building, I get errors for multiple definitions of getopt related variables. Also, the makefile generated after configure step is deleted once the build fails, and so any patches are impossible.

Any clues ?

P.S. I'm a newbie, so correct me wherever you think I'm messing things up.

Thanks
Ashish

Sam Clegg

unread,
Mar 17, 2015, 7:37:45 PM3/17/15
to native-cli...@googlegroups.com
Hi Ashish,

Thanks for contributing. Comments inline.

On Tue, Mar 17, 2015 at 10:40 AM, Ashish Gaurav
<gaurava...@gmail.com> wrote:
> As an example project, I'm trying to port `gawk` to NaCl. Specifically, I
> wish to create a nexe that runs gawk in NaCl Dev Env. I don't see a port of
> `gawk` as such in the naclports `ports` folder. I've written a build.sh
> which doesn't (as for now) work. Here's the code :
>
>
> ConfigureStep() {
> SetupCrossEnvironment
> NACLPORTS_CPPFLAGS+=" -Dmain=nacl_main -D__GNU_LIBRARY__ -fPIC"
> export LIBS+="${NACL_CLI_MAIN_LIB} -lppapi_simple -lnacl_io -lppapi
> -lpthread -l${NACL_CPP_LIB}"
> DefaultConfigureStep
> }
>
>
> BuildStep() {
> DefaultBuildStep
> }
>
>
> PublishStep() {
> PublishByArchForDevEnv
> }
>
>
> However, the challenge is the fact that `gawk` uses its personal `getopt.c`,
> which is by default included in GNU C Library, and thus the NaCl C library.
> Thus, upon building, I get errors for multiple definitions of getopt related
> variables.

How does gawk build on linux, then? Perhaps configure is detecting
that getopt is missing when in fact it is not? You can try some
different approaches to fix the problem: Firstly you'll want to look
at why configure is mis-detecting the presence of getopt (see
config.log), and try to address that. Secondly, you could try forcing
configure to think that gotopt is present (you can often do this by
export a shell variable that looks like 'ax_cv_xxxx', see the
configure script itself). Finally, if you are desperate, you can wrap
getopt.c in #ifndef __native_client__, or remove it from Makefile.in
completely.

> Also, the makefile generated after configure step is deleted once
> the build fails, and so any patches are impossible.
>

The generated makefiles normally live in out/build/<pkgname>/build_*
directories. They should not be deleted if the build fails.

> Any clues ?
>
> P.S. I'm a newbie, so correct me wherever you think I'm messing things up.
>
> Thanks
> Ashish
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/native-client-discuss.
> For more options, visit https://groups.google.com/d/optout.

Ashish Gaurav

unread,
Mar 19, 2015, 7:46:54 AM3/19/15
to native-cli...@googlegroups.com
Sam

I tried looking up how exactly was gawk building on Linux. When I ran ./configure on my Linux machine, there is a step which outputs
gcc  -g -O2 -DNDEBUG  -export-dynamic -o gawk array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o -lsigsegv   -lreadline -lmpfr -lgmp -ldl -lm -lm
My build fails exactly at this point. It does something like (from the console)
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc  -DNDEBUG -O2 -DNDEBUG  -L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o -lm -lm

I noticed the fact that my build was not linking to mpfr and gmp which were already ported to NaCl. So I added them in the dependencies, and now I got a failure (the same one) at
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc  -DNDEBUG -O2 -DNDEBUG  -L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o -lmpfr -lgmp -lm -lm

So now it is linking to mpfr and gmp. I looked up the fact that -export-dynamic was for dynamic loading and libdl was the one being used here (I think so). You have a page on dynamic loading, I suppose at https://developer.chrome.com/native-client/devguide/devcycle/dynamic-loading. But to implement this without shared libraries (I want a static build), what are my options ?

Also, what is the status of lib-readline and lib-sigsegv ? Are they ported ?

Apologies for the late reply
Thanks
Ashish


Sam Clegg

unread,
Mar 19, 2015, 3:26:31 PM3/19/15
to native-cli...@googlegroups.com
Unless you include the full error message its hard to know exactly
what the problem is.

> So now it is linking to mpfr and gmp. I looked up the fact that
> -export-dynamic was for dynamic loading and libdl was the one being used
> here (I think so). You have a page on dynamic loading, I suppose at
> https://developer.chrome.com/native-client/devguide/devcycle/dynamic-loading.
> But to implement this without shared libraries (I want a static build), what
> are my options ?

Its not surprising the export-dynamic is missing. (IIUC) It doesn't
make sense in a static build (which is what you are doing there).

>
> Also, what is the status of lib-readline and lib-sigsegv ? Are they ported ?

readline should work fine. Just add a dependency on it and it should
be detected by configure.

>
> Apologies for the late reply
> Thanks
> Ashish
>
>

Ashish Gaurav

unread,
Mar 19, 2015, 3:47:25 PM3/19/15
to native-cli...@googlegroups.com
Sam

I apologize for not posting the entire error, although I think I'd indicated a multiple definition error. Here's it in full detail (console output) :
######################################################################
Building gawk
######################################################################
chdir /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_glibc
make -j4
make 'CFLAGS=-DNDEBUG -O2 -DNDEBUG' 'LDFLAGS=-L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/glibc_x86_64/Release -Wl,-rpath-link=/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/glibc_x86_64/Release' all-recursive
make[1]: Entering directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_glibc'
Making all in .
make[2]: Entering directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_glibc'
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT array.o -MD -MP -MF .deps/array.Tpo -c -o array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/array.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT awkgram.o -MD -MP -MF .deps/awkgram.Tpo -c -o awkgram.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awkgram.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT builtin.o -MD -MP -MF .deps/builtin.Tpo -c -o builtin.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/builtin.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT cint_array.o -MD -MP -MF .deps/cint_array.Tpo -c -o cint_array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/cint_array.c
mv -f .deps/cint_array.Tpo .deps/cint_array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT command.o -MD -MP -MF .deps/command.Tpo -c -o command.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/command.c
mv -f .deps/array.Tpo .deps/array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT debug.o -MD -MP -MF .deps/debug.Tpo -c -o debug.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/debug.c
mv -f .deps/command.Tpo .deps/command.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT dfa.o -MD -MP -MF .deps/dfa.Tpo -c -o dfa.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c
In file included from /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c:92:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h: In function ‘xnmalloc’:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: ‘ptrdiff_t’ undeclared (first use in this function)
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: (Each undeclared identifier is reported only once
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: for each function it appears in.)
In file included from /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c:92:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h: In function ‘xnrealloc’:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:190: error: ‘ptrdiff_t’ undeclared (first use in this function)
Makefile:683: recipe for target 'dfa.o' failed
make[2]: *** [dfa.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/builtin.Tpo .deps/builtin.Po
mv -f .deps/awkgram.Tpo .deps/awkgram.Po
mv -f .deps/debug.Tpo .deps/debug.Po
make[2]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_glibc'
Makefile:727: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_glibc'
Makefile:546: recipe for target 'all' failed
make: *** [all] Error 2
naclports: Building gawk: failed.


-Ashish

Ashish Gaurav

unread,
Mar 19, 2015, 3:52:42 PM3/19/15
to native-cli...@googlegroups.com
Sam

The previous error log was for a glibc compile (I tried that afterwards). Here's the original error output :
<more output...>

/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc  -DNDEBUG -O2 -DNDEBUG  -L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o     -lmpfr -lgmp -lm -lm 
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o): In function `getopt_long_only':
getopt.c:(.text+0x1600): multiple definition of `getopt_long_only'
getopt1.o:getopt1.c:(.text+0xa0): first defined here
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o):(.bss+0x4): multiple definition of `optind'
getopt.o:(.data+0x0): first defined here
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o):(.data+0x0): multiple definition of `opterr'
getopt.o:(.data+0x4): first defined here
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o):(.data+0x4): multiple definition of `optopt'
getopt.o:(.data+0x8): first defined here
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o): In function `getopt_long':
getopt.c:(.text+0x16c0): multiple definition of `getopt_long'
getopt1.o:getopt1.c:(.text+0xe0): first defined here
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libcrt_common.a(lib_a-getopt.o): In function `getopt':
getopt.c:(.text+0x1780): multiple definition of `getopt'
getopt.o:getopt.c:(.text+0x1e60): first defined here
collect2: ld returned 1 exit status
Makefile:643: recipe for target 'gawk.nexe' failed
make[2]: *** [gawk.nexe] Error 1
make[2]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib'
Makefile:727: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib'
Makefile:546: recipe for target 'all' failed
make: *** [all] Error 2
naclports: Building gawk: failed.

Regards
-Ashish

Ashish Gaurav

unread,
Mar 19, 2015, 4:04:33 PM3/19/15
to native-cli...@googlegroups.com
Sam

There might have been some confusion regarding my previous two posts. This post is to make things clear (sorry about messing up the order of the errors). The outputs were long so I decided to keep them separate. The previous post contains the errors for the newlib build, that I originally started the topic for. The previous-to-previous post contains the errors for the glibc build, that I attempted afterwards. You may go through the glibc errors as well.

Sincere apologies
-Ashish

Sam Clegg

unread,
Mar 20, 2015, 2:01:25 PM3/20/15
to native-cli...@googlegroups.com
For the newlib I would look at the configure process. See why gawk is
deciding to build its own getopt rather than use the one that comes
with newlib.

For the glibc build its hard to see how ptrdiff_t could end up not
being defined. Normally this is defined in 'stddef.h'. You probably
want to take a look at the stddef.h and also look at the pre-processed
source for the failing source file (dfa.c). (To get the
pre-processed source go the build directory and run the failing
compiler command .. adding -E, which will cause the .o file to contain
the pre-processed sources, rather than object code).

cheers,
sam

Ashish Gaurav

unread,
Mar 20, 2015, 5:00:15 PM3/20/15
to native-cli...@googlegroups.com
Sam

I thought I'd begin by considering the newlib static build. So I saw configure, as you suggested, and then the source of getopt.c and getopt1.c, both of which had

   Comment out all this code if we are using the GNU C Library, and are not
   actually compiling the library itself.  This code is part of the GNU C
   Library, but also included in many other GNU distributions.  Compiling
   and linking in this code is a waste when using the GNU C library
   (especially if it is a shared library).  Rather than having every GNU
   program understand `configure --with-gnu-libc' and omit the object files,
   it is simpler to just do this in the source for each such file.

Commenting out everything just got me past the build step, and I got a gawk.nexe, although it didn't run on Dev Environment saying : 
./gawk.nexe: NaCl module load failed: Nexe crashed during startup

     ./gawk.nexe: NaCl module load failed: Nexe crashed during startup

I'm working with GDB in the meantime to find out the cause of the crash. The build has been partial, and only gawk's main executable was built fully. (So, the build failed) Here's the console log :

     [... more lines ...]
     Making all in .
     make[2]: Entering directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib'
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT getopt.o -MD -MP -MF .deps/getopt.Tpo -c -o getopt.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/getopt.c
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG -MT getopt1.o -MD -MP -MF .deps/getopt1.Tpo -c -o getopt1.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/getopt1.c
     mv -f .deps/getopt.Tpo .deps/getopt.Po
     mv -f .deps/getopt1.Tpo .deps/getopt1.Po
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc  -DNDEBUG -O2 -DNDEBUG  -Dmain=nacl_main -D__GNU_LIBRARY__ -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o     -lmpfr -lgmp -lm -lm 
     make[2]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib'
     Making all in awklib
     make[2]: Entering directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib/awklib'
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DHAVE_CONFIG_H -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib -I..  -I.. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1 -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib/eg/lib/pwcat.c -Dmain=nacl_main -D__GNU_LIBRARY__ -o pwcat.nexe
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DHAVE_CONFIG_H -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib -I..  -I.. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1 -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -DNDEBUG -O2 -DNDEBUG /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib/eg/lib/grcat.c -Dmain=nacl_main -D__GNU_LIBRARY__ -o grcat.nexe
     cp /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib/eg/prog/igawk.sh igawk ; chmod 755 igawk
     sed 's;/usr/local/libexec/awk;/naclports-dummydir/libexec/awk;' < /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib/eg/lib/passwdawk.in > passwd.awk
     sed 's;/usr/local/libexec/awk;/naclports-dummydir/libexec/awk;' < /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awklib/eg/lib/groupawk.in > group.awk
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libnacl.a(start_fa9ef7de.o): In function `_start':
     /mnt/data/b/build/slave/sdk/build/src/native_client/src/untrusted/nacl/start.c:64: undefined reference to `main'
     collect2: ld returned 1 exit status
     Makefile:732: recipe for target 'pwcat.nexe' failed
     make[2]: *** [pwcat.nexe] Error 1
     make[2]: *** Waiting for unfinished jobs....
     /home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib64/libnacl.a(start_fa9ef7de.o): In function `_start':
     /mnt/data/b/build/slave/sdk/build/src/native_client/src/untrusted/nacl/start.c:64: undefined reference to `main'
     collect2: ld returned 1 exit status
     Makefile:735: recipe for target 'grcat.nexe' failed
     make[2]: *** [grcat.nexe] Error 1
     make[2]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib/awklib'
     Makefile:727: recipe for target 'all-recursive' failed
     make[1]: *** [all-recursive] Error 1
     make[1]: Leaving directory '/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib'
     Makefile:546: recipe for target 'all' failed
     make: *** [all] Error 2
     naclports: Building gawk: failed.

What do you think about these new undefined reference errors?

Regards & Thanks
Ashish

./gawk.nexe: NaCl module load failed: Nexe crashed during startup

Sam Clegg

unread,
Mar 20, 2015, 10:30:15 PM3/20/15
to native-cli...@googlegroups.com
Hi Ashishm,

Looking at the failing linker command line, it looks like main is
being defined to nacl_main (-Dmain=nacl_main). However I don't see
the libraries required to make this work correctly. I would expect to
see at least -lnacl-spawn and -lppapi_simple.

cheers,
sam

Ashish Gaurav

unread,
Mar 26, 2015, 11:01:33 AM3/26/15
to native-cli...@googlegroups.com
Hi Sam

I've gone through the build process for gawk on Linux. While trying to understand why the default build didn't work, I revisited the log I gave you in my previous post. Here's what I've tried :

(1) Changing the Makefile.am

Because gawk uses an autoconf build, so I tried changing the Makefile.am, since every final makefile on Linux was being made from this file. A change in the Makefile.am required however that I also downgrade my automake from 1.15 to 1.13, for which the original Makefile was intended. This however, caused a lot of issues with the files around in that folder. At this point, I'd like to ask you something : what is the standard procedure to modify Makefile.am for ports? I feel I've messed up something.

(2) Detailing build.sh with the build instructions I got from the log

Reading the log in my previous post, I found out that if I ran those bash commands again via build.sh in my port, then I might be able to build a gawk nexe, not to forget the idea that I could link my gawk build to ppapi, nacl_io at the least. So, I added those commands into my build.sh in an attempt (and it has been five days tinkering with it without any avail) to get a proper gawk executable. Here's the failure log

[... more lines ...]
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DNDEBUG -O2 -DNDEBUG -Dmain=nacl_main -D__GNU_LIBRARY__ -I. -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/include -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib/../gawk-4.1.1/ -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o -lmpfr -lgmp -lm -lm -lppapi_simple -lnacl_io -lppapi -lpthread
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: cannot find -lppapi_simple
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: cannot find -lnacl_io
collect2
: ld returned 1 exit status
naclports
: Building gawk: failed.


I fail to see why it cannot find the linked libraries, even though I included those. Is it the order of included files (-I*) or the order of linked libraries (-l*) ?

Apologies if anything I ask is way too basic,

Regards & Thanks
Ashish

Bradley Nelson

unread,
Mar 27, 2015, 2:16:41 PM3/27/15
to Native Client Discuss
On Thu, Mar 26, 2015 at 8:01 AM, Ashish Gaurav <gaurava...@gmail.com> wrote:
Hi Sam

I've gone through the build process for gawk on Linux. While trying to understand why the default build didn't work, I revisited the log I gave you in my previous post. Here's what I've tried :

(1) Changing the Makefile.am

Because gawk uses an autoconf build, so I tried changing the Makefile.am, since every final makefile on Linux was being made from this file. A change in the Makefile.am required however that I also downgrade my automake from 1.15 to 1.13, for which the original Makefile was intended. This however, caused a lot of issues with the files around in that folder. At this point, I'd like to ask you something : what is the standard procedure to modify Makefile.am for ports? I feel I've messed up something.


Keeping autoconf generated files up to date with host tools is tricky.
Generally we've tried to patch the generated file directly, OR ideally to find external parameters that don't require changing the configure script (often you can find a variable to set externally).
 
(2) Detailing build.sh with the build instructions I got from the log

Reading the log in my previous post, I found out that if I ran those bash commands again via build.sh in my port, then I might be able to build a gawk nexe, not to forget the idea that I could link my gawk build to ppapi, nacl_io at the least. So, I added those commands into my build.sh in an attempt (and it has been five days tinkering with it without any avail) to get a proper gawk executable. Here's the failure log

[... more lines ...]
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DNDEBUG -O2 -DNDEBUG -Dmain=nacl_main -D__GNU_LIBRARY__ -I. -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/include -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib/../gawk-4.1.1/ -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o -lmpfr -lgmp -lm -lm -lppapi_simple -lnacl_io -lppapi -lpthread
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: cannot find -lppapi_simple
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary/toolchain/linux_x86_newlib/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: cannot find -lnacl_io
collect2
: ld returned 1 exit status
naclports
: Building gawk: failed.


I fail to see why it cannot find the linked libraries, even though I included those. Is it the order of included files (-I*) or the order of linked libraries (-l*) ?


Odd, normally -L${NACLPORTS_LIBDIR} should make its way to the link line (via NACLPORTS_LDFLAGS).
Try adding it explicitly. 

Apologies if anything I ask is way too basic,

Regards & Thanks
Ashish

--

Ashish Gaurav

unread,
Mar 29, 2015, 6:17:33 AM3/29/15
to native-cli...@googlegroups.com
Hi all

After a bit of editing and stuff, I finally ported gawk to x86-64 newlib (NaCl). Here's a picture



I guess getting the nexe to work on my Dev Environment was just the beginning. The build was similar to bzip2 (as BradN did). 

For any utility ported to Native Client, I know there are limitations upon what processing the utility can do, what part it can access and threads etc. I hope to get the maximum functionality out of gawk from here on. Before I ask any questions, here's my build log :

[... pre build, configure lines ...]
######################################################################
Building gawk
######################################################################
chdir
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/build_x86-64_newlib
CPPFLAGS
=-I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include
CFLAGS
= -Dmain=nacl_main -fPIC -DNDEBUG -O2
CXXFLAGS
= -DNDEBUG -O2
LDFLAGS
=-L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -Xlinker -uPSUserMainGet -lcli_main -lnacl_spawn -lppapi_simple -lnacl_io -lppapi -lstdc++
make
-j4 LDFLAGS=-Dmain=nacl_main -D__GNU_LIBRARY__ -L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -Xlinker -uPSUserMainGet -lcli_main -lnacl_spawn -lppapi_simple -lnacl_io -lppapi -lstdc++ CFLAGS= -Dmain=nacl_main -fPIC -DNDEBUG -O2 gawk.nexe
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT array.o -MD -MP -MF .deps/array.Tpo -c -o array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/array.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT awkgram.o -MD -MP -MF .deps/awkgram.Tpo -c -o awkgram.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/awkgram.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT builtin.o -MD -MP -MF .deps/builtin.Tpo -c -o builtin.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/builtin.c
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT cint_array.o -MD -MP -MF .deps/cint_array.Tpo -c -o cint_array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/cint_array.c
mv
-f .deps/cint_array.Tpo .deps/cint_array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT command.o -MD -MP -MF .deps/command.Tpo -c -o command.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/command.c
mv
-f .deps/array.Tpo .deps/array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT debug.o -MD -MP -MF .deps/debug.Tpo -c -o debug.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/debug.c
mv
-f .deps/command.Tpo .deps/command.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT dfa.o -MD -MP -MF .deps/dfa.Tpo -c -o dfa.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c
mv
-f .deps/builtin.Tpo .deps/builtin.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT eval.o -MD -MP -MF .deps/eval.Tpo -c -o eval.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/eval.c
mv
-f .deps/awkgram.Tpo .deps/awkgram.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT ext.o -MD -MP -MF .deps/ext.Tpo -c -o ext.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/ext.c
mv
-f .deps/debug.Tpo .deps/debug.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT field.o -MD -MP -MF .deps/field.Tpo -c -o field.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/field.c
mv
-f .deps/ext.Tpo .deps/ext.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT floatcomp.o -MD -MP -MF .deps/floatcomp.Tpo -c -o floatcomp.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/floatcomp.c
mv
-f .deps/dfa.Tpo .deps/dfa.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT gawkapi.o -MD -MP -MF .deps/gawkapi.Tpo -c -o gawkapi.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/gawkapi.c
mv
-f .deps/gawkmisc.Tpo .deps/gawkmisc.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT getopt.o -MD -MP -MF .deps/getopt.Tpo -c -o getopt.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/getopt.c
mv
-f .deps/getopt.Tpo .deps/getopt.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT getopt1.o -MD -MP -MF .deps/getopt1.Tpo -c -o getopt1.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/getopt1.c
mv
-f .deps/getopt1.Tpo .deps/getopt1.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT int_array.o -MD -MP -MF .deps/int_array.Tpo -c -o int_array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/int_array.c
mv
-f .deps/gawkapi.Tpo .deps/gawkapi.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT io.o -MD -MP -MF .deps/io.Tpo -c -o io.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/io.c
mv
-f .deps/int_array.Tpo .deps/int_array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/main.c
mv
-f .deps/field.Tpo .deps/field.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT mpfr.o -MD -MP -MF .deps/mpfr.Tpo -c -o mpfr.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/mpfr.c
mv
-f .deps/main.Tpo .deps/main.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT msg.o -MD -MP -MF .deps/msg.Tpo -c -o msg.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/msg.c
mv
-f .deps/msg.Tpo .deps/msg.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT node.o -MD -MP -MF .deps/node.Tpo -c -o node.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/node.c
mv
-f .deps/mpfr.Tpo .deps/mpfr.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT profile.o -MD -MP -MF .deps/profile.Tpo -c -o profile.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/profile.c
mv
-f .deps/io.Tpo .deps/io.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT random.o -MD -MP -MF .deps/random.Tpo -c -o random.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/random.c
mv
-f .deps/node.Tpo .deps/node.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT re.o -MD -MP -MF .deps/re.Tpo -c -o re.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/re.c
mv
-f .deps/random.Tpo .deps/random.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT regex.o -MD -MP -MF .deps/regex.Tpo -c -o regex.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/regex.c
mv
-f .deps/re.Tpo .deps/re.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT replace.o -MD -MP -MF .deps/replace.Tpo -c -o replace.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/replace.c
mv
-f .deps/replace.Tpo .deps/replace.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT str_array.o -MD -MP -MF .deps/str_array.Tpo -c -o str_array.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/str_array.c
mv
-f .deps/profile.Tpo .deps/profile.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT symbol.o -MD -MP -MF .deps/symbol.Tpo -c -o symbol.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/symbol.c
mv
-f .deps/str_array.Tpo .deps/str_array.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -Dmain=nacl_main -fPIC -DNDEBUG -O2 -MT version.o -MD -MP -MF .deps/version.Tpo -c -o version.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/version.c
mv
-f .deps/version.Tpo .deps/version.Po
mv
-f .deps/symbol.Tpo .deps/symbol.Po
mv
-f .deps/eval.Tpo .deps/eval.Po
mv
-f .deps/regex.Tpo .deps/regex.Po
/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_newlib/bin/x86_64-nacl-gcc  -Dmain=nacl_main -fPIC -DNDEBUG -O2  -Dmain=nacl_main -D__GNU_LIBRARY__ -L/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//lib/newlib_x86_64/Release -Xlinker -uPSUserMainGet -lcli_main -lnacl_spawn -lppapi_simple -lnacl_io -lppapi -lstdc++ -o gawk.nexe array.o awkgram.o builtin.o cint_array.o command.o debug.o dfa.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o getopt.o getopt1.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o random.o re.o regex.o replace.o str_array.o symbol.o version.o     -lmpfr -lgmp -lm -lm


[... post build lines ...]


Quick Questions :

(1) Running the nexe on my Dev Environment, I find that most of things are fine. I can see the help (--help), version (--version), run simple programs using print in gawk (I'm exploring more functionality). But sometimes I get a warning like :

gawk.nexe: warning: file  `/home/user/a.txt': could not get fd flags: (fcntl F_GETFD: Function not implemented)

I know it could be gawk specific, but is this error pattern seen elsewhere, in any other program?

(2) How does building for GlibC work? I know (from bzip2) that I have to get all the important libraries somewhere into payload perhaps, but how do I test to see if my port is working?

(3) How do I get my code into naclports? Or maybe, I should get it to naclports after I've tried to build it for PNaCl and GlibC?

(4) Are there coding style guidelines for bash?

Thanks and Regards
Ashish

Sam Clegg

unread,
Mar 30, 2015, 7:06:58 PM3/30/15
to native-cli...@googlegroups.com
fcntl(F_GETFD) should be implemented in nacl_io.  You'll need to do some debugging here to find out why its failing.

Also, you should be away that one of the main missing features of nacl_io today is lack to support for unnamed pipes, so building piped command lines won't work in bash today.

(2) How does building for GlibC work? I know (from bzip2) that I have to get all the important libraries somewhere into payload perhaps, but how do I test to see if my port is working?

I would just start by trying to run it in devenv.
 

(3) How do I get my code into naclports? Or maybe, I should get it to naclports after I've tried to build it for PNaCl and GlibC?

You can use 'git cl upload' to upload your change for review and send it out to either brad or myself.
 
(4) Are there coding style guidelines for bash?

Nothing written down I'm afraid.  Just try to match the local conventions.  (80 column max, two space indentation, CamelCase for function names).
 

Thanks and Regards
Ashish

Bradley Nelson

unread,
Mar 31, 2015, 12:58:19 PM3/31/15
to Native Client Discuss
fcntl can be tricky. We probably need to do something with it generally (I've finally filled an issue: http://crbug.com/472155  ).
Because it uses varargs, we don't have a runtime interception hook for it in our libcs, and instead rely on link order (which can be dicey in the face of different build systems).

A workaround we've used in a few of the ports is this (patched into a port in front of a fcntl call site):

#if defined(__native_client__)
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_wrap.h"
#include <stdarg.h>

/*
 * TODO(bradnelson): Drop this when fcntl is sorted out in nacl_io.
 * Explicitly use nacl_fcntl.
 * When built as a shared library, without this emacs seems to hit stubs.
 */
int nacl_fcntl(int fd, int cmd, ...) {
  va_list ap;
  va_start(ap, cmd);
  int rtn = ki_fcntl(fd, cmd, ap);
  va_end(ap);
  return rtn;
}
#define fcntl nacl_fcntl
#endif



 
Also, you should be away that one of the main missing features of nacl_io today is lack to support for unnamed pipes, so building piped command lines won't work in bash today.

(2) How does building for GlibC work? I know (from bzip2) that I have to get all the important libraries somewhere into payload perhaps, but how do I test to see if my port is working?

I would just start by trying to run it in devenv.
 

(3) How do I get my code into naclports? Or maybe, I should get it to naclports after I've tried to build it for PNaCl and GlibC?

You can use 'git cl upload' to upload your change for review and send it out to either brad or myself.
 
(4) Are there coding style guidelines for bash?

Nothing written down I'm afraid.  Just try to match the local conventions.  (80 column max, two space indentation, CamelCase for function names).

There is this actually. Though I doubt we follow it to the letter in naclports:

Ashish Gaurav

unread,
Mar 31, 2015, 2:46:39 PM3/31/15
to native-cli...@googlegroups.com
Hi all
 
From the previous post, as BradN, Sam said,
 
fcntl can be tricky. We probably need to do something with it generally (I've finally filled an issue: http://crbug.com/472155  ).
Because it uses varargs, we don't have a runtime interception hook for it in our libcs, and instead rely on link order (which can be dicey in the face of different build systems).

A workaround we've used in a few of the ports is this (patched into a port in front of a fcntl call site):

#if defined(__native_client__)
#include "nacl_io/kernel_intercept.h"
#include "nacl_io/kernel_wrap.h"
#include <stdarg.h>

/*
 * TODO(bradnelson): Drop this when fcntl is sorted out in nacl_io.
 * Explicitly use nacl_fcntl.
 * When built as a shared library, without this emacs seems to hit stubs.
 */
int nacl_fcntl(int fd, int cmd, ...) {
  va_list ap;
  va_start(ap, cmd);
  int rtn = ki_fcntl(fd, cmd, ap);
  va_end(ap);
  return rtn;
}
#define fcntl nacl_fcntl
#endif

Your workaround was quite helpful.

Meanwhile,
I've tried a lot of the functionality of gawk, and I didn't see any problems as such. I managed to get past the previous errors by using BradN's workaround. But till now, it has been a static build. For a dynamic build, I think my earlier explanation may not have been much clear. So I'm clarifying things now.

When I started off, I tried a newlib port of gawk. However, earlier it was building on glibc. It was placing library files (object and .a files) into a payload folder, which BradN said, was used by naclports for other builds. Quick questions :

(1) when should I use glibc-compat? 
(2) Just as a newlib port (static) can thought of as successful when the singular nexe runs fine on Dev Environment, what should I do for a GlibC port? I remember the fact that GlibC is done usually before newlib, but here I've completed newlib first. How do I do a GlibC port from here? More importantly, how do I deem a port successful for GlibC? It's a dynamic build, so do I need all the files related on my Dev Environment (if it involves the devenv)?
(3) What about PNaCl? Does a pexe run on Dev Environment?

Even a pointer to any answer of the above would be useful.
Thanks & Regards
Ashish

Bradley Nelson

unread,
Mar 31, 2015, 3:30:12 PM3/31/15
to Native Client Discuss
If need for newlib, never for glibc.
 
(2) Just as a newlib port (static) can thought of as successful when the singular nexe runs fine on Dev Environment, what should I do for a GlibC port? I remember the fact that GlibC is done usually before newlib, but here I've completed newlib first. How do I do a GlibC port from here? More importantly, how do I deem a port successful for GlibC? It's a dynamic build, so do I need all the files related on my Dev Environment (if it involves the devenv)?

Ideally yes you should run it in devenv.
For a glibc based package, you can get shared library version clash if things don't line up. So you'll need to point LD_LIBRARY_PATH at the lib64 directory of the built executable.
 
(3) What about PNaCl? Does a pexe run on Dev Environment?

Yes they should, and this should be straightforward given your newlib port.
 
Even a pointer to any answer of the above would be useful.
Thanks & Regards
Ashish

--

Ashish Gaurav

unread,
Mar 31, 2015, 4:08:44 PM3/31/15
to native-cli...@googlegroups.com
BradN

I figured out building the port using 
$ bin/naclports --toolchain pnacl|newlib|glibc build gawk
would be the essential part. My build.sh currently looks like :

# Copyright (c) 2014 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# define __GNU_LIBRARY__ because of issues with getopt
# getopt.c and getopt1.c have been commented for build
NACLPORTS_CFLAGS+=" -D__GNU_LIBRARY__ -D__native_client__ -Dmain=nacl_main \
-fPIC"

export NACLPORTS_LDFLAGS+=" ${NACL_CLI_MAIN_LIB} -lppapi_simple -lnacl_io \
-lppapi -l${NACL_CPP_LIB}"

ConfigureStep() {
  DefaultConfigureStep
}

BuildStep() {
SetupCrossEnvironment

EXTRA_LIBS=""
if [ "${NACL_LIBC}" = "glibc" ]; then
# required for a dynamic build
    EXTRA_LIBS+=" -ldl "
  fi
# including readline because it is not linked otherwise
LogExecute make -j${OS_JOBS} LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}" \
LIBS="-lreadline ${EXTRA_LIBS} -lm -lm" gawk${NACL_EXEEXT}
}

InstallStep() {
return
}

PublishStep() {
  PublishByArchForDevEnv
}

I've applied the basic style guidelines as Sam pointed out before, and my build works fine with newlib and pnacl. [pnacl pexe yet to be tested on devenv, however it builds without warnings/errors]

(1) GLibC Problems

For a glibc build, it gives me a build error saying "ptrdiff_t undeclared", somewhere in between for an .o file. Here's the build log for reference.
[... more lines ...]
/home/
agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//toolchain/linux_x86_glibc/bin/x86_64-nacl-gcc -DDEFPATH='".:/naclports-dummydir/share/awk"' -DDEFLIBPATH="\"/naclports-dummydir/lib/gawk\"" -DSHLIBEXT="\"so"\" -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"/naclports-dummydir/share/locale"' -I. -I/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1   -I/home/agaurav77/Programs/NaCl/nacl_sdk/pepper_canary//include  -D__GNU_LIBRARY__ -D__native_client__ -Dmain=nacl_main         -fPIC -DNDEBUG -O2 -MT dfa.o -MD -MP -MF .deps/dfa.Tpo -c -o dfa.o /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c

In file included from /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c:92:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h: In function xnmalloc’:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: ptrdiff_t undeclared (first use in this function)
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: (Each undeclared identifier is reported only once
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:132: error: for each function it appears in.)
In file included from /home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/dfa.c:92:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h: In function xnrealloc’:
/home/agaurav77/Programs/NaCl/naclports/src/out/build/gawk/gawk-4.1.1/xalloc.h:190: error: ptrdiff_t undeclared (first use in this function)
Makefile:683: recipe for target 'dfa.o'
failed
make
: *** [dfa.o] Error 1
make
: *** Waiting for unfinished jobs....

mv
-f .deps/builtin.Tpo .deps/builtin.Po
mv
-f .deps/awkgram.Tpo .deps/awkgram.Po
mv
-f .deps/debug.Tpo .deps/debug.Po

naclports
: Building gawk: failed.

I'm reading the source files to find out the cause, and I'll try and fix it soon. Clues (if possible)?

(2) Sel_Ldr & nmf files
Do I need to add a TranslateAndWriteSelLdrScript, or create a .nmf for my final pexe and relevant nexes? 

(3) Better Ways for Testing
I know it has been told to me before that for testing purposes, people run a custom httpd python server and access the nexe/pexe as required. Unfortunately that trick didn't work for me. I think running a custom server will make the nexes/pexes available to Chrome, but how do I access them in devenv? It's a bit tiring uploading it somewhere and then downloading it on devenv with curl for testing.

Thanks & Regards
Ashish

Ashish Gaurav

unread,
Mar 31, 2015, 5:08:02 PM3/31/15
to native-cli...@googlegroups.com
Hi all

Nevermind the build.sh I gave earlier. It wasn't properly indented, as it seems (I don't know how). Here's the same file again with proper indentation :

Bradley Nelson

unread,
Apr 1, 2015, 7:45:49 PM4/1/15
to Native Client Discuss
Check if that file has stddef.h included. It might not, which is arguably a error.
 
(2) Sel_Ldr & nmf files
Do I need to add a TranslateAndWriteSelLdrScript, or create a .nmf for my final pexe and relevant nexes? 

Depends on the testing, see below.

Regardless be sure to:
Add a PublishByArchForDevEnv (look at the ninja package for instance).
Also add a line to ports/devenv/package similar to the one for ninja.
That way it'll be installable in the devenv.

 
(3) Better Ways for Testing
I know it has been told to me before that for testing purposes, people run a custom httpd python server and access the nexe/pexe as required. Unfortunately that trick didn't work for me. I think running a custom server will make the nexes/pexes available to Chrome, but how do I access them in devenv? It's a bit tiring uploading it somewhere and then downloading it on devenv with curl for testing.


Apologies our test setup is less than great.
Awk might be reasonably testable with the sel_ldr.
A good model for that is look at sqlite.
A devenv_large_test in ports/devenv/tests might be nice, but isn't essential.
 
Thanks & Regards
Ashish

Ashish Gaurav

unread,
Apr 2, 2015, 5:14:40 PM4/2/15
to native-cli...@googlegroups.com
Hi all

After a bit of playing around with build.sh to get the desired build, I finally got my port to pass the ./make_all.sh gawk test. Now gawk builds for all the four platforms x86_64 (glibc, newlib), i686 (clang-newlib, glibc, newlib), arm (clang-newlib, newlib) and pnacl. Thank you all for being patient with me.

The only formality left I guess is to personally try the nexes through changes in devenv, or via SelLdr commands found in common.sh, before I submit my port for review (trying to be double sure). Wrapper questions -

(1) I guess an .nmf might not be needed, since gawk is not really a kind of web based port. Possible uses include gawk being used as a command line utility in the devenv, rather than serving a webpage. Please correct me?

(2) Should I make custom tests using SelLdr (saw sqlite)?

(3) Also, it looks like its not possible for me to use the devenv provided in naclports. I'm on Arch Linux, so it requires me to have CHROME-DEVEL-SANDBOX. Can someone provide a download link? I couldn't find anything for downloads even after reading "https://code.google.com/p/chromium/wiki/LinuxSUIDSandbox". Currently using Webstore's devenv.

(4) Should I file a bug before I submit my code for review, even if its just adding a feature?

Regards
Ashish

Bradley Nelson

unread,
Apr 2, 2015, 7:46:35 PM4/2/15
to Native Client Discuss
On Thu, Apr 2, 2015 at 2:14 PM, Ashish Gaurav <gaurava...@gmail.com> wrote:
Hi all

After a bit of playing around with build.sh to get the desired build, I finally got my port to pass the ./make_all.sh gawk test. Now gawk builds for all the four platforms x86_64 (glibc, newlib), i686 (clang-newlib, glibc, newlib), arm (clang-newlib, newlib) and pnacl. Thank you all for being patient with me.

The only formality left I guess is to personally try the nexes through changes in devenv, or via SelLdr commands found in common.sh, before I submit my port for review (trying to be double sure). Wrapper questions -

(1) I guess an .nmf might not be needed, since gawk is not really a kind of web based port. Possible uses include gawk being used as a command line utility in the devenv, rather than serving a webpage. Please correct me?


Correct
 
(2) Should I make custom tests using SelLdr (saw sqlite)?


This would be nice to have, however, I'm willing to defer tests to a second change.
Since this is your first port, I figure getting the build reviewed first is more useful in terms of feedback.
 
(3) Also, it looks like its not possible for me to use the devenv provided in naclports. I'm on Arch Linux, so it requires me to have CHROME-DEVEL-SANDBOX. Can someone provide a download link? I couldn't find anything for downloads even after reading "https://code.google.com/p/chromium/wiki/LinuxSUIDSandbox". Currently using Webstore's devenv.


Do you mean that the devenv tests don't run correctly? These download and run a copy of chromium. Though they do assume the CHROME_DEVEL_SANDBOX environment variable points somewhere setup.

If you do the devenv build in naclports, even if it fails on the tests, you should have something at:
out/downloaded_chrome/x86_64/chrome-linux/chrome_sandbox 

You'll want to move this somewhere permenant and do:
sudo chown root:root chrome_sandbox
sudo chmod 4755 chrome_sandbox

Then have CHROME_DEVEL_SANDBOX in your evironment set to the absolute path of that executable.


 
(4) Should I file a bug before I submit my code for review, even if its just adding a feature?

Just a code review is fine. You can list BUG=None in the commit description.

Ashish Gaurav

unread,
Apr 3, 2015, 4:16:58 PM4/3/15
to native-cli...@googlegroups.com
Hi all

devenv builds now, thanks. Should I run it by first starting up a build_tools/httpd.py server? "NaCl module loading..." goes on forever. Is it meant to be run using chromium which was downloaded to downloaded_chrome?

I made the issue.

Regards
Ashish

Ashish Gaurav

unread,
Apr 3, 2015, 4:24:53 PM4/3/15
to native-cli...@googlegroups.com
One more thing : what are CQ dry runs?

Bradley Nelson

unread,
Apr 13, 2015, 2:48:27 PM4/13/15
to Native Client Discuss
No idea.
I think the infrastructure team is testing some sort of automatic kick off of try jobs.


On Fri, Apr 3, 2015 at 1:24 PM, Ashish Gaurav <gaurava...@gmail.com> wrote:
One more thing : what are CQ dry runs?

--

Sam Clegg

unread,
Apr 13, 2015, 3:09:03 PM4/13/15
to native-cli...@googlegroups.com
The CQ dry run is a way to run the CQ to get results prior the getting
an LGTM. Basically works like "git cl try".

(The CQ is the Commit Queue, which is a way to automatically submit
changes once they pass on all required buildbots. I also allows
people without direct commit access to effectively commit changes,
once they have an LGTM from a comitter).

cheers,
sam

Ashish Gaurav

unread,
Apr 14, 2015, 11:58:21 AM4/14/15
to native-cli...@googlegroups.com
Informative, thanks Sam.
Reply all
Reply to author
Forward
0 new messages