Skip to content

Commit 29d5d60

Browse files
authored
Fix trampoline on PPC (#38980)
* [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
1 parent 9fa97f9 commit 29d5d60

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

Make.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,11 @@ XC_HOST := $(ARCH)$(shell echo $(BUILD_MACHINE) | sed "s/[^-]*\(.*\)$$/\1/")
795795
endif
796796
endif
797797

798+
# Normalize ppc64le to powerpc64le
799+
ifeq ($(ARCH), ppc64le)
800+
override ARCH := powerpc64le
801+
endif
802+
798803
ifeq ($(ARCH),mingw32)
799804
$(error "the mingw32 compiler you are using fails the openblas testsuite. please see the README.windows document for a replacement")
800805
else ifeq (cygwin, $(shell $(CC) -dumpmachine | cut -d\- -f3))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "../../src/jl_exported_funcs.inc"
2+
3+
// Notes:
4+
// bctr: branch to CTR without LR update (tail-call)
5+
// localentry: On PPC functions have a localentry that assumes r2 contains
6+
// the TOC pointer, and a global entry point that sets r2.
7+
// See 64-Bit ELF V2 ABI Specification: Power Architecture v1.4
8+
9+
#define XX(name) \
10+
.global name; \
11+
.type name##, @function; \
12+
.cfi_startproc; \
13+
name##: ; \
14+
addis 2, 12, .TOC.-name##@ha; \
15+
addi 2, 2, .TOC.-name##@l; \
16+
.localentry name##,.-name##; \
17+
addis 9,2,name##_addr@toc@ha; \
18+
ld 12,name##_addr@toc@l(9); \
19+
mtctr 12; \
20+
bctr; \
21+
.cfi_endproc; \
22+
.size name##,.-name##; \
23+
24+
JL_EXPORTED_FUNCS(XX)
25+
#undef XX

cli/trampolines/trampolines_ppc64le.S

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/jl_exported_funcs.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
XX(jl_clock_now) \
112112
XX(jl_close_uv) \
113113
XX(jl_code_for_staged) \
114-
XX(jl_compile_extern_c) \
115114
XX(jl_compile_hint) \
116115
XX(jl_compress_argnames) \
117116
XX(jl_compress_ir) \

0 commit comments

Comments
 (0)