JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.72k stars 5.48k forks source link

poor man PLT breaks arm and power - need the rich man's version #17373

Closed josefsachsconning closed 8 years ago

josefsachsconning commented 8 years ago

Same as #17312. Using master branch of julia, after make cleanall. My last successful build was at 45400d0.

vtjnash commented 8 years ago

@yuyichao how hard would it be to just implement the "rich mans PLT"? It seems to me like that would require very little assembly and be easy to write for each platform we care about (and thus be easier to support than the musttail attribute)

ViralBShah commented 8 years ago

Getting this on Power:

/home/vinchhid/julia/base/precompile.jl
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
*** This error is usually fixed by running `make clean`. If the error persists, try `make cleanall`. ***
make[1]: *** [/home/vinchhid/julia/usr/lib/julia/sys.o] Error 1
make: *** [julia-sysimg-release] Error 2

Should we revert this PR?

cc @yuyichao @vtjnash

ViralBShah commented 8 years ago

I am tagging this as 0.5 so that we make sure we fix build breakage on both architectures before the release.

ViralBShah commented 8 years ago

The relevant PR I believe is: #17260

yuyichao commented 8 years ago

how hard would it be to just implement the "rich mans PLT"

Should be possible with module level inline asm? It might also need some assembly in C so I guess I can try to implement it for x86 and arm with it disabled on MSVC.

ViralBShah commented 8 years ago

Can we have some other generic fallback for other architectures?

yuyichao commented 8 years ago

generic fallback

Disable it.

yuyichao commented 8 years ago

The musttail is basically the generic fallback, although apparently it's so broken on anything other than x86 and aarch64 which is not mentioned in the document.......

vtjnash commented 8 years ago

I thought the PLT could be pretty much all in a .S file to push/pop all of the argument registers and update the callee site.

yuyichao commented 8 years ago

push/pop all of the argument registers

I can't think of how this can be implemented without writing assembly (the C part).

update the callee site.

As well as knowing which function it is calling requires finding the right GOT entry and the information about the library/symbol to use. This is the LLVM module level asm part since the whole function (two or three instructions) needs to be written in assembly to avoid llvm to clubber random registers.

It is possible that we can get rid of the second part by looking at the return address but that requires a complete map for all the callsite and it doesn't work for tailcall.

ViralBShah commented 8 years ago

If we fix this (for the build), we can support both arm and power in the 0.5 release.

StefanKarpinski commented 8 years ago

Not release blocking, however since it can be fixed in 0.5.1 without disrupting anything.