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

Add Windows patches for LLVM 3.9 #19138

Merged
merged 7 commits into from
Dec 3, 2016
Merged

Add Windows patches for LLVM 3.9 #19138

merged 7 commits into from
Dec 3, 2016

Conversation

tkelman
Copy link
Contributor

@tkelman tkelman commented Oct 27, 2016

part of #19123

threads patch was rebased on rust's llvm fork
rust-lang/llvm@d1cc489

cygwin build patch is from llvm-mirror/llvm@9f79578
in cross-compile, a subset of llvm gets built for the native build system

This crashes at the start of bootstrap on both win64:

    JULIA usr/lib/julia/inference.ji

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed!

Program: C:\cygwin64\home\Tony\julia\usr\bin\julia.exe
File: /home/Tony/julia/src/codegen.cpp, Line 1149

Expression: fptr.fptr != NULL
make[1]: *** [Makefile:217: /home/Tony/julia/usr/lib/julia/inference.ji] Error 3
make: *** [Makefile:96: julia-inference] Error 2

and win32:

    JULIA usr/lib/julia/inference.ji
LLVM ERROR: Program used external function '_memset' which could not be resolved!
make[1]: *** [Makefile:217: /home/Tony/julia32/usr/lib/julia/inference.ji] Error 1
make: *** [Makefile:96: julia-inference] Error 2

threads patch was rebased on rust's llvm fork
rust-lang/llvm@d1cc489

cygwin build patch is from llvm-mirror/llvm@9f79578
in cross-compile, a subset of llvm gets built for the native build system
@tkelman tkelman added the domain:building Build system, or building Julia or its dependencies label Oct 27, 2016
@vchuravy vchuravy mentioned this pull request Oct 27, 2016
@tkelman tkelman added the system:windows Affects only Windows label Oct 27, 2016
@tkelman tkelman changed the title Add two patches so LLVM 3.9 at least builds for Windows Add Windows patches for LLVM 3.9 Oct 28, 2016
@tkelman
Copy link
Contributor Author

tkelman commented Oct 28, 2016

@vtjnash I'll need you to check that I rebased 7ee818c right. We also need to write an LLVM unit test for that so we can get it upstreamed.

(did not help with the assertion/external function failure on bootstrap though)

@tkelman
Copy link
Contributor Author

tkelman commented Oct 28, 2016

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 29, 2016

We don't need it, as we don't use that code path. Could be interesting to look into though at some point, now that we know that code path might work.

@vchuravy
Copy link
Sponsor Member

vchuravy commented Nov 25, 2016

I tried to look into this:

  • Rebased this branch and added patch to copy missing winpthread-1
  • Building on Windows 10 Cygwin + Mingw64 5.4.0
  • Branch is vc/win-fixes

Debug on Win64

    LINK usr/bin/julia-debug.exe
    JULIA usr/lib/julia/inference.ji
LLVM ERROR: Program used external function '__security_check_cookie' which could not be resolved!
make[1]: *** [Makefile:217: /home/valentin-churavy/julia/usr/lib/julia/inference.ji] Error 1
make: *** [Makefile:96: julia-inference] Error 

The lowering for that is In lib/Target/X86/X86ISelLowering.cpp around line 1994, which is guarded by a check to Subtarget.getTargetTriple().isOSMSVCRT(). Added in D20346.
We either have to load the MSVC bufferoverflowu.lib or change the SubTarget to not be MSVC.

Win64:

$ make
    JULIA usr/lib/julia/inference.ji
/bin/sh: line 1:  6560 Segmentation fault      /home/valentin-churavy/julia/usr/bin/julia.exe -C native --output-ji `cygpath -w /home/valentin-churavy/julia/usr/lib/julia/inference.ji` --startup-file=no -g0 -O0 coreimg.jl
make[1]: *** [Makefile:217: /home/valentin-churavy/julia/usr/lib/julia/inference.ji] Error 139
make: *** [Makefile:96: julia-inference] Error 2
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) set $pc = *(void **)$esp
(gdb) set $esp = $esp + 4
(gdb) bt
#0  0x000000006c292b9d in jl_call_method_internal (meth=0x100f8d630, args=0xc6d6a0, nargs=2) at /home/valentin-churavy/julia/src/julia_internal.h:239
#1  0x000000006c298e0e in jl_apply_generic (args=0xc6d6a0, nargs=2) at /home/valentin-churavy/julia/src/gf.c:1861
#2  0x000000006c2ae22c in do_call (args=0x100f8d0d0, nargs=2, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:71
#3  0x000000006c2aed7a in eval (e=0x100f86df0, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:210
#4  0x000000006c2ae208 in do_call (args=0x100f8d070, nargs=2, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:70
#5  0x000000006c2aed7a in eval (e=0x100f86dd0, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:210
#6  0x000000006c2ae208 in do_call (args=0x100f8acf0, nargs=3, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:70
#7  0x000000006c2aed7a in eval (e=0x100f86db0, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:210
#8  0x000000006c2af206 in eval (e=0x100f86d90, s=0x0) at /home/valentin-churavy/julia/src/interpreter.c:267
#9  0x000000006c2b081e in eval_body (stmts=0x100f8abd0, s=0x0, start=0, toplevel=1) at /home/valentin-churavy/julia/src/interpreter.c:549
#10 0x000000006c2b0260 in jl_toplevel_eval_body (stmts=0x100f8abd0) at /home/valentin-churavy/julia/src/interpreter.c:456
#11 0x000000006c2d2ae1 in jl_toplevel_eval_flex (e=0x100f86d50, fast=1, expanded=1) at /home/valentin-churavy/julia/src/toplevel.c:622
#12 0x000000006c2a20dc in jl_parse_eval_all (fname=0x6c4bc0ec <INEXACT_ENTRY+1124> "boot.jl", content=0x0, contentlen=0) at /home/valentin-churavy/julia/src/ast.c:735
#13 0x000000006c2d2cf0 in jl_load (fname=0x6c4bc0ec <INEXACT_ENTRY+1124> "boot.jl") at /home/valentin-churavy/julia/src/toplevel.c:666
#14 0x000000006c2bb725 in _julia_init (rel=JL_IMAGE_JULIA_HOME) at /home/valentin-churavy/julia/src/init.c:639
#15 0x000000006c2bd827 in julia_init (rel=JL_IMAGE_JULIA_HOME) at /home/valentin-churavy/julia/src/task.c:289
#16 0x000000000040243c in wmain (argc=1, argv=0x407fbd0, envp=0x407e8a0) at /home/valentin-churavy/julia/ui/repl.c:247
#17 0x000000000040140c in __tmainCRTStartup () at /usr/src/debug/mingw64-x86_64-runtime-5.0.0-1/crt/crtexe.c:329
#18 0x000000000040153b in mainCRTStartup () at /usr/src/debug/mingw64-x86_64-runtime-5.0.0-1/crt/crtexe.c:212

@tkelman
Copy link
Contributor Author

tkelman commented Nov 25, 2016

GCC 5.4 will most likely still miscompile LLVM (even 3.7) on win32. The GCC 4.9 build from cygwin did not need libwinpthread, but it's not currently easy to get. Probably need to use the cygwin time machine to get the past versions.

@vchuravy
Copy link
Sponsor Member

Thanks for the hint with cygwin time machine (2016/09/09-131242 still has 4.9.2)

@vchuravy
Copy link
Sponsor Member

Same problem with 4.9.2

(gdb) call jl_(meth)
Core.Typeof(#Typeof, #<null>.Any)
(gdb) p meth.fptr
$1 = (jl_fptr_t) 0x0

@vchuravy
Copy link
Sponsor Member

@tkelman The llvm-3.9.0_threads patch seems to be excessively large in comparison to the patch for 3.8.

@tkelman
Copy link
Contributor Author

tkelman commented Nov 28, 2016

I took it straight from Rust's fork, didn't think too much about it.

@vchuravy
Copy link
Sponsor Member

Restarted appveyor for this. Log is backed up here https://gist.github.com/vchuravy/4b995598e033574c45b7b9f83c4333b1

Copy link
Sponsor Member

@vchuravy vchuravy left a comment

Choose a reason for hiding this comment

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

From my perspective this is ready to be merged

@tkelman
Copy link
Contributor Author

tkelman commented Nov 30, 2016

I still haven't looked much at the threads patch, but I think the old copy was doing #if 0 around big chunks of code. Maybe that's not as possible to do cleanly in 3.9 for some reason?

@vchuravy
Copy link
Sponsor Member

It seems to remove lli-child-target, llvm-cov, and sancov completely. Maybe these are parts of llvm that rely on the functionality that is disabled? It looks like the patch is turning of `RPCUtils.

@tkelman tkelman merged commit 1e0e793 into master Dec 3, 2016
@tkelman tkelman deleted the tk/llvmpatches branch December 3, 2016 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies system:windows Affects only Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants