Skip to content

Commit

Permalink
Fix trampoline on PPC (JuliaLang#38980)
Browse files Browse the repository at this point in the history
* [Make] Normalize ppc64le to powerpc64le

* [CLI] Fix trampoline on PowerPC

1. Add global entry
2. Don't store `r2` on parent frame
3. Conservative load from toc

* remove jl_compile_extern_c from exported funcs
  • Loading branch information
vchuravy authored Dec 25, 2020
1 parent 9fa97f9 commit 29d5d60
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
5 changes: 5 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,11 @@ XC_HOST := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
endif
endif

# Normalize ppc64le to powerpc64le
ifeq ($(ARCH), ppc64le)
override ARCH := powerpc64le
endif

ifeq ($(ARCH),mingw32)
$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the README.windows document for a replacement")
else ifeq (cygwin, $(shell $(CC) -dumpmachine | cut -d\- -f3))
Expand Down
25 changes: 25 additions & 0 deletions cli/trampolines/trampolines_powerpc64le.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "../../src/jl_exported_funcs.inc"

// Notes:
// bctr: branch to CTR without LR update (tail-call)
// localentry: On PPC functions have a localentry that assumes r2 contains
// the TOC pointer, and a global entry point that sets r2.
// See 64-Bit ELF V2 ABI Specification: Power Architecture v1.4

#define XX(name) \
.global name; \
.type name##, @function; \
.cfi_startproc; \
name##: ; \
addis 2, 12, .TOC.-name##@ha; \
addi 2, 2, .TOC.-name##@l; \
.localentry name##,.-name##; \
addis 9,2,name##_addr@toc@ha; \
ld 12,name##_addr@toc@l(9); \
mtctr 12; \
bctr; \
.cfi_endproc; \
.size name##,.-name##; \

JL_EXPORTED_FUNCS(XX)
#undef XX
14 changes: 0 additions & 14 deletions cli/trampolines/trampolines_ppc64le.S

This file was deleted.

1 change: 0 additions & 1 deletion src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
XX(jl_clock_now) \
XX(jl_close_uv) \
XX(jl_code_for_staged) \
XX(jl_compile_extern_c) \
XX(jl_compile_hint) \
XX(jl_compress_argnames) \
XX(jl_compress_ir) \
Expand Down

0 comments on commit 29d5d60

Please sign in to comment.