REPL #3877

Merged
merged 11 commits into from Nov 5, 2012

Conversation

Projects
None yet
4 participants
Contributor

z0w0 commented Oct 27, 2012

A really basic REPL, using liblinenoise. Also adds linenoise bindings into libcore, as core::rl.

Issues out of my control:

  • There could only be one parser context at a time, so the entire rustc has to be started up each time in a task (has this been fixed since then?)
  • AST is not sendable, so I had to (hackily) pretty print each parsed AST and then send it back to the REPL context - results in performance degrading over time
  • Unused variable warnings can't be disabled so it's incredibly in your face

Big thanks to @bleibig, @dbp, etc. for their work on REPL prototypes.

Contributor

z0w0 commented Oct 27, 2012

OK, so this is what I get for not cleaning (I don't know why it worked in the first place), I believe I'm doing something wrong in the makefiles (at the moment liblinenoise.a is copied to every stage so that libcore can find it). I thought linking in liblinenoise.a to libcore would work, but apparently rustc can't find the symbols when it tries to link. Any ideas?

compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libsyntax.so
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/librustc.so
cp: x86_64-unknown-linux-gnu/stage1/lib/libsyntax.so
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc
cp: x86_64-unknown-linux-gnu/stage1/lib/librustc.so
error: linking with `cc` failed with code 1
note: cc arguments: -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc.o -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lcore-c3ca5d77d81b46c1-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-4782a756585a81-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lsyntax-84efebcb12c867a2-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lrustc-c84825241471686d-0.4 -lrustrt -lrt -ldl -lm -lmorestack -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath,/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib
note: /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseHistorySave'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoise'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseHistorySetMaxLen'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseSetCompletionCallback'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseHistoryAdd'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseClearScreen'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseHistoryLoad'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to `linenoiseAddCompletion'
Contributor

dbp commented Oct 27, 2012

Totally naive guess - did you change Makefile (instead of Makefile.in)? Probably a stupid suggestion, but sometimes it is the stupid things that we never think about :)
On Oct 27, 2012, at 7:29 AM, Zack Corr wrote:

OK, so this is what I get for not cleaning (I don't know why it worked in the first place), I believe I'm doing something wrong in the makefiles (at the moment liblinenoise.a is copied to every stage so that libcore can find it). I thought linking in liblinenoise.a to libcore would work, but apparently rustc can't find the symbols when it tries to link. Any ideas?

compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libsyntax.so
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/librustc.so
cp: x86_64-unknown-linux-gnu/stage1/lib/libsyntax.so
compile_and_link: x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc
cp: x86_64-unknown-linux-gnu/stage1/lib/librustc.so
error: linking with cc failed with code 1
note: cc arguments: -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/bin/rustc.o -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lcore-c3ca5d77d81b46c1-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-4782a756585a81-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lsyntax-84efebcb12c867a2-0.4 -L/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -lrustc-c84825241471686d-0.4 -lrustrt -lrt -ldl -lm -lmorestack -Wl,-rpath,$ORIGIN/../lib -Wl,-rpath,/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/usr/local/li
b/rustc/x86_64-unknown-linux-gnu/lib
note: /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to linenoiseHistorySave' /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference tolinenoise'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to linenoiseHistorySetMaxLen' /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference tolinenoiseSetCompletionCallback'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to linenoiseHistoryAdd' /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference tolinenoiseClearScreen'
/home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference to linenoiseHistoryLoad' /home/zack/Code/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so: undefined reference tolinenoiseAddCompletion'

Reply to this email directly or view it on GitHub.

Contributor

z0w0 commented Oct 28, 2012

It was definitely Makefile.in.

Contributor

graydon commented Oct 29, 2012

Oh dear. I hate to have been responsible for all these adventures in makefile and submodule hacking; I honestly just meant to drop the linenoise.c file into the list of .c files compiled into librt and add its (few) symbols to the export list. Linenoise is very stable, no?

Contributor

brson commented Oct 29, 2012

I agree linenoise doesn't need to be a submodule. I also prefer not to have it in core. Beyond that I haven't reviewed the rest.

Contributor

brson commented Oct 31, 2012

We're still waiting for the windows bot to come back online before this can be merged.

Contributor

dbp commented Oct 31, 2012

I noticed rusti is tracking v0.4 of core, std, etc (in src/rusti/rusti.rs:15-18) - which means that it won't work with incoming, I think (as they are now on 0.5).

Also, I guess once this merges I can continue the library-ification project and turn rusti into a library too. Once all that code merges we should try to get that to be the default with new tools (if new tools are added) - as Makefile hacking is no fun! (that, or manage to free graydon up enough to rebuild the build system :P)

Contributor

brson commented Nov 3, 2012

'make check' immediately fails with whitespace errors. It looks like the tidy script is checking the native linenoise library.

Contributor

z0w0 commented Nov 4, 2012

Fixed.

Contributor

brson commented Nov 4, 2012

linenoise seems to be a unix-only thing: http://bot.rust-lang.org/logs/2012/10/04/2012-11-04T03:38:25Z-96c8d488-dcf0-41d5-8e48-eaea49507b2b.html

What can we do on windows?

Contributor

brson commented Nov 4, 2012

MinGW has some termios support so this should be possible with some build tweaking.

Contributor

brson commented Nov 5, 2012

I've tried plugging in this win32-enabled linenoise and it builds and seems to work ok, but it does not have a linenoiseClear function. In my brief experiments I get link errors every time I tried to execute a line, but at least it builds.

Here's my current working branch with various fixes: https://github.com/brson/rust/tree/repl-merge

@brson brson merged commit a450119 into rust-lang:incoming Nov 5, 2012

Contributor

brson commented Nov 5, 2012

Merged. I had to break the :clear command because linenoiseClear doesn't exist.

Contributor

brson commented Nov 5, 2012

Thanks, @z0w0!

Contributor

z0w0 commented Nov 5, 2012

Awesome! I think making linenoiseClear work is as simple as exposing the clearScreen function?

Contributor

z0w0 commented Nov 5, 2012

install_lib: /usr/local/lib/librusti-*.so
ls: cannot access x86_64-unknown-linux-gnu/stage2/lib/librusti-*.so: No such file or directory
install: missing destination file operand after ‘/usr/local/lib/’
Try 'install --help' for more information.

Caused by RUSTI_GLOB trying to be installed in install.mk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment