Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_glibc() has nil argument #1

Closed
WhoisZihan opened this issue Nov 19, 2018 · 15 comments
Closed

build_glibc() has nil argument #1

WhoisZihan opened this issue Nov 19, 2018 · 15 comments
Assignees

Comments

@WhoisZihan
Copy link

Hi

I'm trying to compile your project in Ubuntu 16.04(I tried 18.04 as well). I followed extacly the same instructions in your README file, however, it gives the following errors

config.status: creating po/Makefile.in
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: executing bfd_stdint.h commands
config.status: executing default commands
make[6]: Nothing to be done for 'info'.
make[6]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd/po'
make[6]: Entering directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd'
make[6]: Nothing to be done for 'info-am'.
make[6]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd'
Makefile:1544: recipe for target 'info-recursive' failed
make[5]: *** [info-recursive] Error 1
make[5]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd'
Makefile:3278: recipe for target 'all-bfd' failed
make[4]: *** [all-bfd] Error 2
make[4]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl'
Makefile:828: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl'
Makefile:372: recipe for target 'BUILD/stamp-x86_64-nacl-binutils' failed
make[2]: *** [BUILD/stamp-x86_64-nacl-binutils] Error 2
make[2]: Leaving directory '/home/fma/lind_project/native_client/tools'
Makefile:954: recipe for target 'build-with-glibc' failed
make[1]: *** [build-with-glibc] Error 2
make[1]: Leaving directory '/home/fma/lind_project/native_client/tools'

[./mklind:552] Error: [function: build_glibc()] [arguments: (nil)].


It took 141 seconds

All done.
Makefile:8: recipe for target 'all' failed
make: *** [all] Error 1

It seems to be compiling for all-bsd? I don't see how I can specify the architecture. I already libglib2.0-dev with version 2.48.2-0ubuntu4.1.
Here is the extact commands I run (I already installed virtualenv and virtualenvwrapper)

git clone https://github.com/Lind-Project/lind_project.git
mv lind_project ~/
cd ~/lind_project
make  # choose 1 for all

Then I get the error after a while. Did I miss anything? Thanks.

@alyptik
Copy link
Contributor

alyptik commented Nov 19, 2018

@WhoisZihan Weird, try running a git pull -t in the top directory, then trying ./mklind all (I actually need to update the README there, the build script should be using that instead of make). I am thinking maybe it's something to do with the submodules not being initialized right. I'm gonna see if I can reproduce in an Ubuntu docker image as well.

@alyptik alyptik self-assigned this Nov 19, 2018
@WhoisZihan
Copy link
Author

@alyptik Thanks for the quick reply, and I tried your suggestion. Unfortunately, it fails at the same place.
I suspect the reason might be the wrong LD_LIBRARY_PATH, which is set to /lib/glibc by default. However, there is no such directory in ubuntu. Also, by greping the source files I find there are many places with hard-coded path /lib/glibc, e.g., line 594 in native_client/src/trusted/service_runtime/nacl_syscall_common.c. I guess you are under another distribution of linux.

Unfortunately again, I tried to replace the value with /lib/x86_64-linux-gnu, which is the directory in ubuntu, but it did NOT work either. Am I missing anything again?

@WhoisZihan
Copy link
Author

I just saw the update in README file, and I saw

n.b. LD_LIBRARY_PATH needs to be set to /lib/glibc unless you are modifying the target directory for Repy's modified glibc toolchain installation.

Then I'm a little confused, do I have to installed any pre-requesties before installing Lind?

Another question is that how do I compile certain applications with Lind (e.g., wget) while allowing certain system call to pass down to kernel? That means, I'd like to configure what system call to replace and what to not. I saw the instrucitons to compile wget on https://lind.poly.edu/projects/project, but it seems it has been tranferred since the paper was published, so I guess those instructions do not work anymore. Is there any way to compile wget with Lind?

Thanks.

@alyptik
Copy link
Contributor

alyptik commented Nov 19, 2018

@WhoisZihan No :) Justgcc, clang, and python2 virtualenv should be all that is required. The modified glibc it talks about here is the one built by the build script. the LD_LIBRARY_PATH is used by Repy and refers to the Lind filesystem /lib/glibc, not the one on your host system. Also, that website is very out of date, yeah :( Most of it is pretty out of date, but we are working on having a new website up soon.

Another option if you can't get it working is to try the docker images I have uploaded. You can install docker then follow the instructions in the README to pull and run the already built image.

@WhoisZihan
Copy link
Author

Thanks, then I guess I must miss something, could you please point to the exact environment you are using for development? I'd really like to run it on a native linux if possible. I can get more accurate performance statistics in native machine, although container only brings little overhead.

I have tried the docker image and I can get a shell, but when I run ./hello under the directory, I get bash: ./hello: No such file or directory. Also, it is linked with /lib64/ld-nacl-x86-64.so.1, but there is no such file. Is is expected in the docker environment? Do I have some example applications to run on docker image?

@WhoisZihan
Copy link
Author

Hi, after looking backward for some lines, I find this error

fi; \
rm -rf $backupdir; exit $rc
../../../../SRC/binutils/bfd/doc/bfd.texinfo:326: unknown command `colophon'
../../../../SRC/binutils/bfd/doc/bfd.texinfo:337: unknown command `cygnus'
Makefile:419: recipe for target 'bfd.info' failed
make[5]: *** [bfd.info] Error 1
make[5]: Leaving directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd/doc'
Making info in po
make[5]: Entering directory '/home/fma/lind_project/native_client/tools/BUILD/build-binutils-x86_64-nacl/bfd/po'

Searching in google gives me possible answer in this issue in riscv-gdb. It seems you are using an older version of texinfo than I do, and new texinfo does not include these 2 commands any more?

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan Aha, I completely forgot about having to do that, yes, that's correct. I put it in the README.md in a not-so-obvious place, apologies.

The subdirectory ./docker/pkgs.tar.xz contains the older make and texinfo versions needed. I really don't like needing to do this, but I haven't been able to successfully patch glibc so that newer versions work yet :(

I'll put that in an issue when I get the chance so we don't forget about it again, thanks for unintentionally reminding me, haha!

@WhoisZihan
Copy link
Author

@alyptik I see, I'll try compiling the older texinfo. Do I need to install it on system directory or I can do a local install and specify something like TEXINFO_PREFIX=... when building glibc?

One more little thing I'd like to know is whether I can compile some example applications, for example, applications in the paper? I'd like to measure the performance on my own machine with a newer kernel. I'd appreciate your help.

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan That should be fine. I installed it to ~/.local on my computer, but your way shouldn't cause any issues.

For the second one you should be able to compile most programs, you can check the test_cases/ subdirectory in the lind_project repo to see some examples of what I've tried/had to do.

Some of them are simple one file ones and I also have bash and stuff in there. The bigger programs need a bit more work, though. Each of them has a script named ./bootstrap_nacl to handle the build, so you can look at those to sort of get an idea of the different patches and stuff I had to make in order to successfully compile each one of the bigger programs. Most of those should work (httpd was terribly annoying to get to build...), so just let me know if you run into any problems.

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan said:

Thanks, then I guess I must miss something, could you please point to the exact environment you are using for development? I'd really like to run it on a native linux if possible. I can get more accurate performance statistics in native machine, although container only brings little overhead.

I have tried the docker image and I can get a shell, but when I run ./hello under the directory, I get bash: ./hello: No such file or directory. Also, it is linked with /lib64/ld-nacl-x86-64.so.1, but there is no such file. Is is expected in the docker environment? Do I have some example applications to run on docker image?

Whoops sorry, I completely missed this message! That docker image drops you into a normal bash shell, and you can run programs with lind and manage the filesystem with lindfs. The -h flags explain how to use them, but a few quick examples:

View the filesystem:

  • lindfs find /

Copy a file/directory to the filesystem:

  • lindfs cp ./share

Execute a program:

  • lind /fork

Execute an argument list:

  • lind /bin/bash -c 'a=hi; [[ "$a" =~ h.* ]] && echo succeeded'

Turn up verbosity (up to seven -v are meaningful to show more verbose debugging information):

  • lind -vvvvvvv /dup2

Debug a Lind program with gdb:

  • lind -g /exec

The -g flag to lind is very, very useful :)

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan As far as my environment goes, I develop on an Arch Linux installation and build most programs by writing a ./bootstrap_nacl script to handle ./configure and make steps and set ~/lind_project/lind/repy/repy as the PREFIX for make install.

I then copy it over with cd ~/lind_project/lind/repy/repy && for d in bin lib share; do lindfs cp "$d"; done to copy those folders to the / directory of the virtual filesystem.

I can then run it with something like lind /bin/busybox dir. Often I need lind -v or lind -g for debugging tricky problems.

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan Sorry again about the lack of documentation with lind and lindfs, I actually only recently wrote those helper scripts and haven't gotten around to adding documentation for them yet, heh.

@WhoisZihan
Copy link
Author

@alyptik Wow thank you so much for such a detailed explanation! I will try it as soon as possible.

@alyptik
Copy link
Contributor

alyptik commented Nov 20, 2018

@WhoisZihan No problem :)

@WhoisZihan
Copy link
Author

Hi @alyptik ,

It's been a while since our last discussion. I wonder if you are still working on this project? I just replaced the texinfo with the specified version in my Ubuntu 18.04, yet it gives me another error:

sh: 1: /home/fma/lind_project/native_client/toolchain/linux_x86/bin/x86_64-nacl-g++: not found
...
**********************************************************************
COMMAND EXECUTION REPORT
**********************************************************************
   5 Install
   1 g++
   6 gcc
   2 set
   1 x86_64-nacl-g++
   3 x86_64-nacl-gcc

**********************************************************************
ENVIRONMENT USAGE REPORT
**********************************************************************
  13  dbg-linux-x86-64
   5  nacl-x86-64-pic-glibc

**********************************************************************
ERROR REPORT: 1 failures
**********************************************************************

scons-out/nacl-x86-64-pic-glibc/obj/tests/mmap/mmap_test.o failed: Error 127

However, this file does exists

$ file /home/fma/lind_project/native_client/toolchain/linux_x86/bin/x86_64-nacl-g++
/home/fma/lind_project/native_client/toolchain/linux_x86/bin/x86_64-nacl-g++: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.15, BuildID[sha1]=bff65d170d29424941159d5dd3a42f5aca309820, stripped
am trying to compile some programs and add some custom tests in the `test_cases`

It seems to be 32-bit file, is it expected? Is it the right step if I want to compile the tests under test_cases folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants