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

Update with experimental support for LLVM 6.0.0 #2595

Merged
merged 16 commits into from
Apr 11, 2018

Conversation

chalcolith
Copy link
Member

This PR includes build system and code changes to support LLVM 6.0.0.

@chalcolith chalcolith added the do not merge This PR should not be merged at this time label Mar 11, 2018
@SeanTAllen
Copy link
Member

@kulibali does this work without the workarounds in llvm 4 and 5 support?

@SeanTAllen
Copy link
Member

@kulibali do you know how to add support for CI testing of LLVM 6?

@chalcolith
Copy link
Member Author

I haven't done anything on Linux yet, so I haven't tested the workaround or CI for Linux yet. The single AppVeyor failure seems spurious.

I'll look at Linux, including CI, today.

@chalcolith
Copy link
Member Author

Ok, I have copied the CI configuration to make 6.0.0 happen; if I understand it correctly, someone will have to make a container for LLVM 6? Someone who knows Docker much better than me, ideally.

One caveat: LLVM seems to not have generated a binary tarball for Ubuntu 16.04: http://releases.llvm.org/6.0.0/

@SeanTAllen
Copy link
Member

@kulibali i think either @jemc or i could create the container for you. and you could update the circleci config to test with 6 as well. Using Ubuntu 16.04 isnt a requirement for setting up the CI. If you check, you'll see we use different uses of Ubuntu for the various LLVM versions.

https://github.com/ponylang/ponyc/tree/master/.ci-dockerfiles


export CC1=clang-6.0
export CXX1=clang++-6.0
#echo "Running LLVM 5.0 config=debug build..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can ditch these commented out lines

@chalcolith
Copy link
Member Author

Hmm, I thought I had made and pushed a Docker image for LLVM 6; it seems I didn't do it right.

@jemc
Copy link
Member

jemc commented Mar 22, 2018

It looks like the docker image you built may be broken with an owner id issue, as noted by CircleCI.

I'm going to try building it myself to see if it resolves the issue.

@jemc
Copy link
Member

jemc commented Apr 3, 2018

The image also was broken when I built it.

I figured out last night that the LLVM archive seems to have been built with a "high" UID/GID, and when extracting tar archives as the root user, tar will keep the original UID/GID of the file. You can apparently override this with --no-same-owner, so I'm going to try that.

@jemc
Copy link
Member

jemc commented Apr 4, 2018

@kulibali - I was able to create (last night) and upload (this morning) a working image, using the following Dockerfile:

FROM ubuntu:14.04

ENV LLVM_VERSION 6.0.0

RUN apt-get update \
 && apt-get install -y \
  apt-transport-https \
  build-essential \
  g++ \
  git \
  libncurses5-dev \
  libssl-dev \
  make \
  wget \
  xz-utils \
  zlib1g-dev \
 && cd /tmp \
 && wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.bz2 \
 && tar xjvf pcre2-10.21.tar.bz2 \
 && cd pcre2-10.21 \
 && ./configure --prefix=/usr \
 && make \
 && sudo make install \
 && cd / \
 && rm -rf /tmp/pcre* \
 && wget -O - http://releases.llvm.org/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz \
 | tar xJf - --no-same-owner --strip-components 1 -C /usr/local/ clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04

So I think Linux CI is passing now.

The difference was using --no-same-owner in the tar extraction.

echo "Running LLVM 5.0 config=release build..."
export config=release
ponyc-test

make clean
brew uninstall llvm@5

# 6.0.x
# There is no llvm@6 package right now, so this will break once LLVM 7
Copy link
Member

@jemc jemc Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

// hoisting loads (see #2303, #2061, #1592).
// TODO: figure out the real reason LLVM 4 and 5 produce bad code
// TODO: figure out the real reason LLVM 4 and 5 produce bad code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we figured out whether LLVM 6 also produces this bad code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are still problems with LLVM 6 on Linux, but different from 4 & 5. @Praetonus was going to look at it again in his copious free time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I turned on the workaround again for the time being, which is why the CI tests are passing.

@jemc
Copy link
Member

jemc commented Apr 4, 2018

It looks like this just needs some OSX attention now.

@jemc
Copy link
Member

jemc commented Apr 4, 2018

Here's the error from the Travis OSX build:

src/libponyc/codegen/host.cc:42:45: error: no member named 'JITDefault' in namespace 'llvm::CodeModel'
  CodeModel::Model model = jit ? CodeModel::JITDefault : CodeModel::Default;
                                 ~~~~~~~~~~~^

src/libponyc/codegen/host.cc:42:69: error: no member named 'Default' in namespace 'llvm::CodeModel'
  CodeModel::Model model = jit ? CodeModel::JITDefault : CodeModel::Default;
                                                         ~~~~~~~~~~~^

@chalcolith
Copy link
Member Author

I see a warning for LLVM 5 in the build log, so I think that LLVM 5 is getting installed instead of 6: Makefile:266: WARNING: LLVM 5 support is experimental and may result in decreased performance or crashes

@SeanTAllen
Copy link
Member

SeanTAllen commented Apr 4, 2018 via email

@winksaville
Copy link
Contributor

winksaville commented Apr 4, 2018

I also just ran into the JITDefault problem that @jemc found. I looked at the llvm sources and found JITDefault was deleted last year with this change hopefully that helps.

@jemc
Copy link
Member

jemc commented Apr 4, 2018

Thanks, @winksaville!

So, based on that change, I think what's needed should be something like this:

#if PONY_LLVM < 600
  CodeModel::Model model = jit ? CodeModel::JITDefault : CodeModel::Default;
  TargetMachine* m = t->createTargetMachine(opt->triple, opt->cpu,
    opt->features, options, reloc, model, opt_level);
#else
  CodeModel::Model model = jit ? CodeModel::Large : CodeModel::Small;
  TargetMachine* m = t->createTargetMachine(opt->triple, opt->cpu,
    opt->features, options, reloc, model, opt_level, jit);
#end

@jemc
Copy link
Member

jemc commented Apr 4, 2018

\cc @Praetonus for confirmation on the small/large choice I made there with respect to the JIT...

@chalcolith
Copy link
Member Author

chalcolith commented Apr 4, 2018

That code is in master; my branch is a bit behind. I will rebase it, but why is travis building master and not my branch?

@chalcolith
Copy link
Member Author

chalcolith commented Apr 4, 2018

OK, I have:

  • rebased this branch on master and fixed the compile per @jemc's comment
  • updated the LLVM 6 dockerfile with @jemc's changes
  • added build system warnings for LLVM 6

@Praetonus
Copy link
Member

The change suggested by @jemc looks correct to me, but in case the default code models change in future LLVM versions, I think we should rather do something like this:

TargetMachine* m = t->createTargetMachine(opt->triple, opt->cpu,
  opt->features, options, reloc, llvm::None, opt_level, jit);

With a None argument to the Optional<CodeModel> parameter, the LLVM internals will determine the code model to use based on the value of jit.

@chalcolith chalcolith added changelog - added Automatically add "Added" CHANGELOG entry on merge needs discussion during sync and removed do not merge This PR should not be merged at this time labels Apr 5, 2018
@chalcolith chalcolith changed the title Update to support LLVM 6.0.0 Update with experimental support for LLVM 6.0.0 Apr 11, 2018
@chalcolith chalcolith merged commit 48d1cb0 into ponylang:master Apr 11, 2018
ponylang-main added a commit that referenced this pull request Apr 11, 2018
@jemc jemc deleted the llvm600 branch April 12, 2018 23:39
dipinhora pushed a commit to dipinhora/ponyc that referenced this pull request Jun 5, 2018
This change adds experimental support for LLVM 6.0.0 and removes support for 4.0.1.

The change still includes the workaround in the `Heap2Stack` optimization pass that can cause performance degradation (see ponylang#2371).
dipinhora pushed a commit to dipinhora/ponyc that referenced this pull request Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - added Automatically add "Added" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants