cling icon indicating copy to clipboard operation
cling copied to clipboard

smaller binary snapshots download (without bundled LLVM)

Open ustcscgy opened this issue 8 years ago • 48 comments

The binary snapshots listed in https://root.cern.ch/download/cling/ are pretty big, over 200MB, but most of it are LLVM, while cling is static linked against it. After removing bundled LLVM, cling is under 40MB, and after compression, it's 14MB.

Would you consider uploading this cling-only binary snapshots?

BTW, what's the progress of upstreaming LLVM patches? (So that I can build cling against system bundled LLVM instead of downloading binary snapshots.)

ustcscgy avatar Jul 22 '16 02:07 ustcscgy

Thanks for the report. Yes we are working on this. We have a packaging tool that makes them considerably smaller.

We consider uploading binary releases along with each tag.

Some of the patches could be upstreamed but some of them cannot. I have this on my todo list but it is not with high priority. I am completely in favor of building cling against bundled LLVM, but it may require some more work and time.

vgvassilev avatar Jul 22 '16 13:07 vgvassilev

Glad to know that you're working on it, I'll wait for the samller binary packages then.

As for the pacthes that can't be upstreamed, can you tell a bit more about it? As far as I am concered, if unpatched LLVM can't provide functionalities that cling needs, isn't that a bug/missing feature for LLVM?

ustcscgy avatar Jul 23 '16 01:07 ustcscgy

We have uploaded smaller binaries here.

vgvassilev avatar Aug 05 '16 20:08 vgvassilev

Great! Two small improvements:

  1. Fedora version. Which do not use libtinfo and libcxx.
  2. Nightly version, like https://root.cern.ch/download/cling/

ustcscgy avatar Aug 06 '16 04:08 ustcscgy

I see there's a nightly version now, will there be fedora version too?

ustcscgy avatar Aug 08 '16 12:08 ustcscgy

Currently we are looking into this. I am not quite sure we can succeed, because we are using travis ci public service, running on ubuntu. I've been thinking to add a build which spans fedora environment with docker to deliver the fedora nightly. I don't think I will have enough time though. You are welcome to help us out.

vgvassilev avatar Aug 08 '16 12:08 vgvassilev

OK, one reason I want to have Fedora version is because it works and Ubuntu version not work: my current system don't have libtinfo and libc++abi.

Anyways to avoid link cling againt these libraries?

ustcscgy avatar Aug 08 '16 13:08 ustcscgy

Can you download the latest binary and try? I don't think we depend on libtinfo and libc++ at least for the current nightly builds.

vgvassilev avatar Aug 08 '16 13:08 vgvassilev

In 2016-Aug-08-cling-Ubuntu-12.04-x86_64-0.3.dev-e21ea6d.tar.bz2 :

ldd ./bin/cling
....
        libtinfo.so.5 => not found
....

libc++/libc++rt/libc++abi is in release 0.2 IIRC, but they are gone in this snapshot I think.

ustcscgy avatar Aug 08 '16 13:08 ustcscgy

We need tinfo for colored diagnostics.

vgvassilev avatar Aug 09 '16 10:08 vgvassilev

tinfo is a part of ncurses, can be configured off. What cling actually need is ncurses, I think.

ustcscgy avatar Aug 09 '16 11:08 ustcscgy

We provide our own terminal library, because we don't want to depend on ncurses. Maybe we could have a static/fat binary build.

vgvassilev avatar Aug 10 '16 07:08 vgvassilev

cling uses its own terminal library? Let me look into source code to provide more comment.

BTW, cling's terminal behavior is odd under emacs (M-x comint-run), I wonder if it's possibe to disable its terminal capability (and let emacs handle that).

ustcscgy avatar Aug 10 '16 07:08 ustcscgy

First, grep -R tinfo . only returns one match in ./www/index.html, and I think that needs to be fixed.

I think the libtinfo dependency may be come from LLVM, just a guess.

ustcscgy avatar Aug 10 '16 07:08 ustcscgy

Yes, it comes from llvm. It is used by clang to produce colored diagnostics.

vgvassilev avatar Aug 10 '16 08:08 vgvassilev

tinfo is old ncurses, I think?

I see that lib/UserInterface/textinput/doc/textinput.txt says the reason to not use ncurses is license and simplicity.

Well, LLVM/Clang has to use ncurses/libtinfo, or BSD licensed libedit.

So, question 1: is it possible to static link ncurses/libtinfo or libedit againt LLVM/Clang? (Is that what happened in Fedora build?)

Question 2: is textinput written from scratch or borrowed from some open source project?

ustcscgy avatar Aug 10 '16 08:08 ustcscgy

Q1: Could you find out. The LLVM cmake config flag for this is LLVM_ENABLE_TERMINFO. I think it should be possible with minimal changes to our build system to do it. Q2: It was written from scratch by @karies.

vgvassilev avatar Aug 10 '16 08:08 vgvassilev

I skim through gentoo's llvm build script, I think it's impossible to static link LLVM against ncurses.

However, one can disable ncurses support by -DLLVM_ENABLE_TERMINFO=NO, does that impact anything else? I'd like to disable that, otherwise it would be a mess to distribute binary packages: because there are ncurses5 and ncurses6 nowadays...

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

Yes you could disable it, but you won't see colored output on error. I don't think we can afford that in mainline.

vgvassilev avatar Aug 10 '16 09:08 vgvassilev

Colored output... Currently I have a Fedora snapshot from https://root.cern.ch/download/cling, it doesn't have colored error output and doesn't link to tinfo or ncurses.

Do you aware of that?

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

No. I think this is a bug. Does clang have colored diagnostics on fedora? Eg. echo "error" | clang++ -xc++ - returns non color error message?

vgvassilev avatar Aug 10 '16 09:08 vgvassilev

I'm not using fedora, I'm using gentoo. And yes, that line have colored error output on my system, no colored error output from bundled clang.

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

So we need to figure out what's wrong in our version...

vgvassilev avatar Aug 10 '16 09:08 vgvassilev

May I ask which script generate binary snapshot on github and https://root.cern.ch/download/cling?

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

On github I use cpt. For the others it is an internal custom post build procedure.

vgvassilev avatar Aug 10 '16 09:08 vgvassilev

More info: I have cling_2016-07-20_fedora22 on my system, and running ldd on every bin and so from that tarball, none links to tinfo or ncurses.

And echo "error" | ./clang++ -xc++ - has no colored output.

I'm downloading cling_2016-08-09_fedora24.tar.bz2 .

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

Look at https://root.cern.ch/gitweb/?p=rootspi.git;a=tree;f=jenkins;h=fee15867baf9244d6ed003110c5fa3c133584557;hb=HEAD. cling-* are the builders there. I don't understand why we don't build with colors. Maybe the machine doesn't have tinfo installed.

vgvassilev avatar Aug 10 '16 09:08 vgvassilev

Same error for cling_2016-08-09_fedora24, I guess there is a bug in fedora building script.

But I have to say, being never have a cling with colored error output, I'm OK with that ...

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

I see the jenkins build scripts, nothing related with tinfo/ncurses. I'm not familar with jenkins CI, so maybe the build machine don't have ncurses/tinfo installed.

And one correction: libedit is supposed to be a replacement for readline, not ncurses.

So, do you think package libtinfo.so.5 inside the package is OK?

Also, seems Ubuntu version hard code g++4.9 inside binary, Fedora version doesn't have this problem:

ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
    echo | LC_ALL=C g++-4.9  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -xc++ -E -v - 2>&1 >/dev/null | awk '/^#include </,/^End of search/{if (!/^#include </ && !/^End of search/){ print }}' | GREP_OPTIONS= grep -E "(c|g)\+\+"
results in
with exit code 256
input_line_1:1:10: fatal error: 'new' file not found
#include <new>
         ^

causes segfault on any input.

ustcscgy avatar Aug 10 '16 09:08 ustcscgy

One more PS: I think cling's textinput library is more like a readline replacement than a ncurses like terminal library.

So the root problem here is clang uses ncurses to display colored error output, cling don't use ncurses/tinfo.

ustcscgy avatar Aug 10 '16 10:08 ustcscgy

Would it be conceivable to not require any cling patches for llvm and use stock llvm at some point in the future?

SylvainCorlay avatar Oct 07 '16 07:10 SylvainCorlay

Short term no (we lack manpower) long term: yes once we get rid of the 100 patches we have on top of llvm and clang.

vgvassilev avatar Oct 07 '16 08:10 vgvassilev

@vgvassilev , why not ask the llvm/clang community for help? There's a post by Axel on cfe-dev in 2011, now 5 years later, cling has made huge improvements, maybe more people will find cling useful or interesting, and willing to help to upstream these patches.

ustcscgy avatar Oct 07 '16 09:10 ustcscgy

I was wondering what it would take to create a conda package for cling on conda-forge. We could have a variant of the llvm package which is marked as conflicting with the regular one...

SylvainCorlay avatar Oct 07 '16 09:10 SylvainCorlay

@ustcscgy: I don't think it's llvm/clang job to prepare our patches for a review. I have this in my todo list (as I said before) but not with very high priority. I am hoping for some help by the cling community if that is too big of a trouble.

@SylvainCorlay: I am not sure how exactly conda-forge works but it might be easier to squash all llvm/clang related patches which you would apply (temporarily) to llvm before the cling build. Note that we are very sensitive to revision numbers as the patch may not apply anymore to later versions.

vgvassilev avatar Oct 07 '16 10:10 vgvassilev

@ustcscgy: on the original issue, we have a PR #108 which is adds a fedora based cpt build. Once we have this integrated we could provide smaller nightlies. If you are still interested I wouldn't mind some help, as I don't think I can get to it soon.

vgvassilev avatar Oct 07 '16 10:10 vgvassilev

@SylvainCorlay: I am not sure how exactly conda-forge works but it might be easier to squash all llvm/clang related patches which you would apply (temporarily) to llvm before the cling build. Note that we are very sensitive to revision numbers as the patch may not apply anymore to later versions.

We could have an llvm-cling package which reuses the regular llvm recipe and applies your patches. conda builds are reproducible in that they target a specific hash for the source.

Also we would need to create a clang package too.

SylvainCorlay avatar Oct 07 '16 10:10 SylvainCorlay

The python recipe applies a few patches on the python source code:

https://github.com/conda-forge/python-feedstock/blob/master/recipe/meta.yaml

SylvainCorlay avatar Oct 07 '16 10:10 SylvainCorlay

@SylvainCorlay: for packaging you may want to look at cpt. And our 'nightlies' here.

vgvassilev avatar Oct 07 '16 10:10 vgvassilev

@vgvassilev I was playing around with conda, with the latest ubuntu nighly builds.

I put together a recipe for ubuntu conda install -c SylvainCorlay cling, which works well and installs the kernelspec.

On docker though, there is a link issue with cling::printValue(int const*).

SylvainCorlay avatar Oct 10 '16 01:10 SylvainCorlay

@SylvainCorlay cool! Could you open an ticket about the linker issue?

vgvassilev avatar Oct 10 '16 07:10 vgvassilev

It seems to be that issue, but with gcc 4.9 instead of 5.1. I will just need to use another build of cling that is based on gcc4 (like the ubuntu 14 build).

Remark: it would be really nice if it was possible to have a single wheel for all linux64 architectures.

SylvainCorlay avatar Oct 10 '16 09:10 SylvainCorlay

@vgvassilev

I put together a conda recipe with the current binary and published a binder so that anyone can play with it online. You can check it out here:

Binder

I would love to make the conda packaging so that we could industrialize this sort of thing.

SylvainCorlay avatar Oct 11 '16 17:10 SylvainCorlay

@SylvainCorlay cool. Maybe if it stabilizes (having at least a domain name) you could open a pull request and update cling's readme pointing to it.

Please open a new ticket if you need some more help about conda packaging.

vgvassilev avatar Oct 11 '16 20:10 vgvassilev

@vgvassilev this binder is meant to be a transient thing. What I wanted to emphasize, is that putting a clean conda package together would have a lot of benefits. A lot would come for free then.

  • users of anaconda / miniconda can install cling with

    conda install cling
    

    and run it in the notebook, or jupyterlab.

  • we can create binders like the above example, for people who want to share runable snippets in a git repository to show off they library.

If you want something like this for the cling website itself, the best approach would probably to use a tmpnb-style deployment and host it on a subdomain like try.root.cern.ch just like we have try.jupyter.org @rgbkrk.

I am opening a separate issue with the different pitfalls I encountered which I think should be solved to have cling be part of an official conda channel like conda-forge.

SylvainCorlay avatar Oct 12 '16 13:10 SylvainCorlay

@vgvassilev @karies I wanted to ping on the release of xtensor.

The project website has a Try it Now button powered by Cling and Jupyter.

screen shot 2016-11-11 at 12 26 30 am

SylvainCorlay avatar Nov 10 '16 23:11 SylvainCorlay

Cool! Why does the link resolve to an ip and not a domain? Once that's fixed we can add this to the README page of jupiter/cling.

vgvassilev avatar Nov 11 '16 17:11 vgvassilev

@vgvassilev it is because it is a redirection to the vm that is specifically spawned for you.

SylvainCorlay avatar Nov 11 '16 19:11 SylvainCorlay