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

Upgrade to LLVM 6 and use BinaryBuilder for LLVM on CI #26925

Merged
merged 2 commits into from
May 6, 2018
Merged

Conversation

vchuravy
Copy link
Member

This is a work-in-progress PR for #26398.
This uses the BinaryBuilder infrastructure to create tarballs
with our patchset, that we can use to seed the Mac OSX and Windows
CIs. See https://github.com/staticfloat/LLVMBuilder for the buildscripts.

Many thanks to @staticfloat

configure-llvm:
compile-llvm:
fastcheck-llvm:
check-llvm:
Copy link
Member

Choose a reason for hiding this comment

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

need to define whichever of these are applicable (probably just get?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I thought about it and was unsure which ones to define.
One could argue that get-llvm really means getsrc-llvm.

One related question where should the tarball be stored? Right now I dump it in scratch and if we use get-llvm it probably should go into srccache.

@ararslan ararslan added building Build system, or building Julia or its dependencies external dependencies Involves LLVM, OpenBLAS, or other linked libraries ci Continuous integration labels Apr 28, 2018
@vchuravy
Copy link
Member Author

Intermittent status report:

The build-system changes seem to work, but we hit issues with the prepared tarballs.

@vchuravy
Copy link
Member Author

Good news!

All test pass. CI is red because apparently httpbin.org got hit by a network fluke and that caused one test to fail across Circle, Travis, and Appveyor.

At this point I would encourage testing and reviews by others and I would like to see this merged soon (tm).

@vchuravy vchuravy changed the title [WIP] Use BinaryBuilder for LLVM 6.0.0 Upgrade to LLVM 6 and use BinaryBuilder for LLVM on CI Apr 30, 2018
@@ -220,6 +220,11 @@ includedir_rel := $(shell $(JULIAHOME)/contrib/relative_path.sh $(bindir) $(incl
INSTALL_F := $(JULIAHOME)/contrib/install.sh 644
INSTALL_M := $(JULIAHOME)/contrib/install.sh 755

# BinaryBuilder options
# TODO: Autodiscover triplet
Copy link
Member

Choose a reason for hiding this comment

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

I think $(shell $(CC) -dumpmachine) should work in the majority of cases, with two exceptions: cross-compiling (in which case we already know the target triplet, right?) and platforms such as macOS and FreeBSD, where the minimum version number we support is part of the triplet. But if BinaryBuilder does triplet mapping using the Platform type, the latter case shouldn't be an issue, I would think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it is very close, but not quite and I don't want to spend time on figuring out the precise differences. So for now this has to be a conscious choice.

Make.inc Outdated
# BinaryBuilder options
# TODO: Autodiscover triplet
USE_BINARYBUILDER_LLVM := 0
BB_TRIPLET :=
Copy link
Member

Choose a reason for hiding this comment

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

If this is intended to be at all user-facing, could we use a more descriptive name, perhaps just spelling out BinaryBuilder as in the USE_BINARYBUILDER_LLVM variable above?

deps/llvm.mk Outdated

#Override provision of stage tarball
$(build_staging)/llvm-$(LLVM_VER)-$(LLVM_BB_REL).tgz: $(BUILDDIR)/llvm-$(LLVM_VER)-$(LLVM_BB_REL)/build-compiled
$(info Using staged install form staticfloat/LLVMBuilder)
Copy link
Member

Choose a reason for hiding this comment

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

form -> from?

@@ -5493,9 +5493,7 @@ static std::unique_ptr<Module> emit_function(
AttrBuilder *attr = new AttrBuilder();
attr->addStackAlignmentAttr(16);
#if JL_LLVM_VERSION >= 50000
f->addAttributes(AttributeList::FunctionIndex,
AttributeList::get(f->getContext(),
AttributeList::FunctionIndex, *attr));
Copy link
Member

Choose a reason for hiding this comment

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

Is this not still applicable to LLVM 5.0?

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 think it was just never tested.

@vchuravy vchuravy force-pushed the vc/llvmbb branch 2 times, most recently from 098428f to 7e06ce0 Compare April 30, 2018 20:58
@vchuravy
Copy link
Member Author

vchuravy commented May 1, 2018

Wohaaa straight flush.

@vchuravy
Copy link
Member Author

vchuravy commented May 1, 2018

@nanosoldier runbenchmarks(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@vchuravy
Copy link
Member Author

vchuravy commented May 1, 2018

I will merge this on Friday if there aren't any objections or comments that require big reworks.

@ararslan
Copy link
Member

ararslan commented May 1, 2018

We don't have CI set up for Alpine Linux so I'm building and running tests for this branch on Alpine in a Docker container now. I'll report back with my findings.

@ararslan
Copy link
Member

ararslan commented May 1, 2018

Note that all systems appear to be showing this during the build:

In file included from /home/julia/ci/worker/11rel-amd64/build/src/llvm-api.cpp:15:
In file included from /home/julia/ci/worker/11rel-amd64/build/usr/include/llvm/Analysis/TargetLibraryInfo.h:13:
In file included from /home/julia/ci/worker/11rel-amd64/build/usr/include/llvm/ADT/DenseMap.h:18:
In file included from /home/julia/ci/worker/11rel-amd64/build/usr/include/llvm/ADT/EpochTracker.h:19:
/home/julia/ci/worker/11rel-amd64/build/usr/include/llvm/Config/abi-breaking.h:23:6: warning: 'LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING' is not defined, evaluates to 0 [-Wundef]
#if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
     ^
1 warning generated.

Not sure what the deal with that is. The macro doesn't appear to be referenced directly in any of the Julia files. Perhaps we (or LLVM?) are missing an #include somewhere?

@ararslan
Copy link
Member

ararslan commented May 1, 2018

The situation on Alpine doesn't change with this PR; all tests pass except for those noted in #26761 (cmdlineargs and precompile).

@fredrikekre
Copy link
Member

Seems like all benchmarks with BigInt is ~1.5x-2x times slower, whats up with that?

@vchuravy
Copy link
Member Author

vchuravy commented May 2, 2018

@nanosoldier runbenchmarks(ALL, vs = "509d6a1a8871dcec78cd6603b6d64871d1088b2f")

@KristofferC
Copy link
Member

Even if the BigInt benchmarks happen to be a bit slower here, I don't think that should block this PR.

@ararslan
Copy link
Member

ararslan commented May 2, 2018

Restarted Nanosoldier. Looks like your invocation had a syntax error though: specific SHAs need to be prefixed with @.

@nanosoldier runbenchmarks(ALL, vs="@509d6a1a8871dcec78cd6603b6d64871d1088b2f")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@vchuravy
Copy link
Member Author

vchuravy commented May 3, 2018

@Keno You asked how the new optimizer is faring on this branch.

I run the tests locally and the only error I encountered was:

      From worker 5:	Internal error: encountered unexpected error in runtime:
      From worker 5:	MethodError(f=typeof(Core.Compiler.convert)(), args=(Core.SSAValue, false), world=0x0000000000000f5f)
      From worker 5:	rec_backtrace at /home/vchuravy/src/julia/src/stackwalk.c:94
      From worker 5:	record_backtrace at /home/vchuravy/src/julia/src/task.c:246
      From worker 5:	jl_throw at /home/vchuravy/src/julia/src/task.c:577
      From worker 5:	jl_method_error_bare at /home/vchuravy/src/julia/src/gf.c:1596
      From worker 5:	jl_method_error at /home/vchuravy/src/julia/src/gf.c:1614
      From worker 5:	jl_lookup_generic_ at /home/vchuravy/src/julia/src/gf.c:2144 [inlined]
      From worker 5:	jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2164
      From worker 5:	setindex! at ./abstractdict.jl:619
      From worker 5:	jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2167
      From worker 5:	type_lift_pass! at ./compiler/ssair/passes.jl:463
      From worker 5:	run_passes at ./compiler/ssair/driver.jl:170
      From worker 5:	optimize at ./compiler/optimize.jl:294
      From worker 5:	typeinf at ./compiler/typeinfer.jl:440
      From worker 5:	typeinf_frame at ./compiler/typeinfer.jl:96 [inlined]
      From worker 5:	typeinf_code at ./compiler/typeinfer.jl:191
      From worker 5:	jfptr_typeinf_code_114 at /home/vchuravy/src/julia/usr/lib/julia/sys.so (unknown line)
      From worker 5:	jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2167
      From worker 5:	typeinf_ext at ./compiler/typeinfer.jl:233
      From worker 5:	jfptr_typeinf_ext_12 at /home/vchuravy/src/julia/usr/lib/julia/sys.so (unknown line)
      From worker 5:	jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2167
      From worker 5:	jl_apply at /home/vchuravy/src/julia/src/julia.h:1540 [inlined]
      From worker 5:	jl_apply_with_saved_exception_state at /home/vchuravy/src/julia/src/rtutils.c:257
      From worker 5:	jl_type_infer at /home/vchuravy/src/julia/src/gf.c:274
      From worker 5:	jl_compile_method_internal at /home/vchuravy/src/julia/src/gf.c:1793 [inlined]
      From worker 5:	jl_fptr_trampoline at /home/vchuravy/src/julia/src/gf.c:1837
      From worker 5:	jl_apply_generic at /home/vchuravy/src/julia/src/gf.c:2167
      From worker 5:	macro expansion at /home/vchuravy/src/julia/usr/share/julia/stdlib/v0.7/Sockets/test/runtests.jl:154 [inlined]
      From worker 5:	macro expansion at /home/vchuravy/src/julia/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:1022 [inlined]
      From worker 5:	top-level scope at /home/vchuravy/src/julia/usr/share/julia/stdlib/v0.7/Sockets/test/runtests.jl:154

but maybe I also haven't rebased this for the last three days.

@Keno
Copy link
Member

Keno commented May 3, 2018

Yeah, you'll want to rebase.

@vchuravy
Copy link
Member Author

vchuravy commented May 4, 2018

master at fa0704b only triggered with new optimizer.

     From worker 7:	julia: /scratch/vchuravy/julia/usr/include/llvm/Support/Casting.h:255: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
      From worker 7:	
      From worker 7:	signal (6): Aborted
      From worker 7:	in expression starting at /scratch/vchuravy/julia/test/strings/search.jl:9
      From worker 7:	raise at /build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54
      From worker 7:	abort at /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:89
      From worker 7:	__assert_fail_base at /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92
      From worker 7:	__assert_fail at /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:101
      From worker 7:	cast<llvm::PointerType, llvm::Type> at /scratch/vchuravy/julia/usr/include/llvm/Support/Casting.h:255
      From worker 7:	getValueAddrSpace at /scratch/vchuravy/julia/src/llvm-late-gc-lowering.cpp:446 [inlined]
      From worker 7:	NumberBase at /scratch/vchuravy/julia/src/llvm-late-gc-lowering.cpp:589
      From worker 7:	Number at /scratch/vchuravy/julia/src/llvm-late-gc-lowering.cpp:612
      From worker 7:	LocalScan at /scratch/vchuravy/julia/src/llvm-late-gc-lowering.cpp:1156
      From worker 7:	runOnFunction at /scratch/vchuravy/julia/src/llvm-late-gc-lowering.cpp:2113
      From worker 7:	runOnFunction at /scratch/vchuravy/julia/deps/srccache/llvm-6.0.0/lib/IR/LegacyPassManager.cpp:1520
      From worker 7:	runOnModule at /scratch/vchuravy/julia/deps/srccache/llvm-6.0.0/lib/IR/LegacyPassManager.cpp:1541
      From worker 7:	run at /scratch/vchuravy/julia/deps/srccache/llvm-6.0.0/lib/IR/LegacyPassManager.cpp:1597
      From worker 7:	operator() at /scratch/vchuravy/julia/src/jitlayers.cpp:466
      From worker 7:	addModule at /scratch/vchuravy/julia/usr/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:57 [inlined]
      From worker 7:	addModule at /scratch/vchuravy/julia/src/jitlayers.cpp:593
      From worker 7:	jl_add_to_ee at /scratch/vchuravy/julia/src/jitlayers.cpp:831 [inlined]
      From worker 7:	jl_finalize_function at /scratch/vchuravy/julia/src/jitlayers.cpp:839
      From worker 7:	getAddressForFunction at /scratch/vchuravy/julia/src/codegen.cpp:1317
      From worker 7:	jl_generate_fptr at /scratch/vchuravy/julia/src/codegen.cpp:1428
      From worker 7:	jl_compile_method_internal at /scratch/vchuravy/julia/src/gf.c:1830 [inlined]
      From worker 7:	jl_fptr_trampoline at /scratch/vchuravy/julia/src/gf.c:1837
      From worker 7:	jl_toplevel_eval_flex at /scratch/vchuravy/julia/src/toplevel.c:850
      From worker 7:	jl_parse_eval_all at /scratch/vchuravy/julia/src/ast.c:852
      From worker 7:	jl_load at /scratch/vchuravy/julia/src/toplevel.c:894
      From worker 7:	include at ./boot.jl:314 [inlined]
      From worker 7:	include_relative at ./loading.jl:1067
      From worker 7:	include at ./sysimg.jl:29
      From worker 7:	include at /scratch/vchuravy/julia/test/testdefs.jl:13
      From worker 7:	jl_fptr_trampoline at /scratch/vchuravy/julia/src/gf.c:1838
      From worker 7:	jl_apply_generic at /scratch/vchuravy/julia/src/gf.c:2167
      From worker 7:	macro expansion at /scratch/vchuravy/julia/test/testdefs.jl:22 [inlined]
      From worker 7:	macro expansion at /scratch/vchuravy/julia/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:1079 [inlined]
      From worker 7:	macro expansion at /scratch/vchuravy/julia/test/testdefs.jl:21 [inlined]
      From worker 7:	macro expansion at ./util.jl:289 [inlined]
      From worker 7:	top-level scope at ./<missing>:19

vchuravy added 2 commits May 4, 2018 11:48
- changes the support LLVM version to 6.0.0
- adds support for using a pre-built LLVM binary from
  `staticfloat/LLVMBuilder` taking advantage of the
  BinaryBuilder infrastructure.
- adds two Makefile flags:
  - `BINARYBUILDER_TRIPLET` the BinaryBuilder triplet you are building for.
    An example would be `x86_64-linux-gnu`.
  - `USE_BINARYBUILDER_LLVM = 0` set this to 1 if you want to use
    the pre-built binaries for LLVM.
- uses the pre-built binaries on OSX Travis instead of the bottle.
- uses the pre-built binaries on Appveyor instead of a custom cache.
@Keno
Copy link
Member

Keno commented May 4, 2018

I'll take a look at that failure.

Keno added a commit that referenced this pull request May 4, 2018
This fixes gc lowering for phis of the form:
```
%phi = phi {%jl_value_t addrspace(10)*, i8} [%aunion, %a], [%bunion, %b]
```
This kind of struct (used by the tagged union representation) has special support
in GC lowering. After optimization, these structs often survive quite far as a
struct (i.e. the destructuring of them is often elided). We simply need to extend
this support to the cases that handle phi and select nodes.

Fixes crashes with the new optimizer enabled noted in #26925
Keno added a commit that referenced this pull request May 5, 2018
This fixes gc lowering for phis of the form:
```
%phi = phi {%jl_value_t addrspace(10)*, i8} [%aunion, %a], [%bunion, %b]
```
This kind of struct (used by the tagged union representation) has special support
in GC lowering. After optimization, these structs often survive quite far as a
struct (i.e. the destructuring of them is often elided). We simply need to extend
this support to the cases that handle phi and select nodes.

Fixes crashes with the new optimizer enabled noted in #26925
@vchuravy vchuravy merged commit bfb1c1b into master May 6, 2018
@vchuravy vchuravy deleted the vc/llvmbb branch May 6, 2018 00:40
@ararslan
Copy link
Member

ararslan commented May 6, 2018

Awesome work here, Valentin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies ci Continuous integration external dependencies Involves LLVM, OpenBLAS, or other linked libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants