cross-compilation amd64 -> ppc (macppc)

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

cross-compilation amd64 -> ppc (macppc)

Karel Gardas


I'm trying to cross-compile (first cross-tools) on amd64 to macppc
target. Since I've hit several issues along the way I'd first like to
verify I'm doing it in expected way. Of course I'm on fairly recent
-current (last week's code). What I do is:

$ cd /usr/src
$ doas make -f Makefile.cross TARGET=macppc cross-tools

is that supported/expected way or not?

My changes raping OpenBSD src are:

1) enable cross-compilation of 32-bit ppc on 64-bit amd64 in Makefile.cross

2) Clang produces more warnings than GCC so it chokes on -Werror in
binutils-2.17. "Fixed" by switching off appropriate warning option just
in related code by using #pragma ...Attempted to minimize impact since
those warnings are usable

3) fix un-init variabnle in xcofflink.c -- Clang caught.

4) clang/ uses -Wl,-relax on powerpc platform, but this
option is not supported by neither of OpenBSD linkers. GNU supports
--relax but since clang (used as HOSTCC) seems to use LLVM's ld, it
chokes on this so I commented this out.

5) libcompiler_rt/Makefile. Defines CC and CXX, but got it in a wrong
way for cross-compilation hence I ended with using clang for compiling
ppc code in libcompiler_rt and correctly used TARGET ld complains about
wrong ELF format. Comment the code to solve this.

The issue I'm hitting now shows as:

egrep "^SYSENTRY(.*)|^ENTRY(.*)|^FUNC(.*)|^SYSCALL(.*)"  /dev/null
/usr/src/lib/libc/arch/powerpc/sys/tfork_thread.S |  sed
"s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1      /^\2(\3\4$/;"  >>
tags; sort -o tags tags
/usr/cross/macppc/usr/powerpc-unknown-openbsd6.5/bin/cc  -O2 -pipe
-Wimplicit -I/usr/src/lib/libc/include -I/usr/src/lib/libc/hidden
-D__LIBC__  -Werror-implicit-function-declaration -include namespace.h
-Werror=deprecated-declarations -DAPIWARN -DYP -I/usr/src/lib/libc/yp
-I/usr/src/lib/libc -I/usr/src/lib/libc/gdtoa
-I/usr/src/lib/libc/arch/powerpc/gdtoa -DINFNAN_CHECK -DMULTIPLE_THREADS
-DNO_FENV_H -DUSE_LOCALE -I/usr/src/lib/libc -I/usr/src/lib/libc/citrus
-DFUTEX  -MD -MP  -c /usr/src/lib/libc/arch/powerpc/gen/_atomic_lock.c
-o _atomic_lock.o
creating __semctl.o
/tmp/--55bf64.s:9:570: error: invalid reassignment of non-absolute
variable '_libc___semctl' in '.set' directive
.weak __semctl; .set __semctl,_thread_sys___semctl; .text; .align 2;
.globl _thread_sys___semctl; .type _thread_sys___semctl,@function;
_thread_sys___semctl:; li 0, 295 ; ; sc ; cmpwi 0, 0 ; beqlr+ ; stw 0,
(-0x7000 + (-8))(2); li 3, -1; li 4, -1; blr; .size
_thread_sys___semctl, . - _thread_sys___semctl; .global _libc___semctl;
.set _libc___semctl,_thread_sys___semctl; .hidden _libc___semctl; .type
_libc___semctl,@function; .size _libc___semctl, . - _libc___semctl;
.size _thread_sys___semctl, . - _thread_sys___semctl; .global
_libc___semctl; .set _libc___semctl,_thread_sys___semctl; .hidden
_libc___semctl; .type _libc___semctl,@function; .size _libc___semctl, .
- _libc___semctl; .size __semctl, . - __semctl
*** Error 1 in lib/libc (sys/ '__semctl.o': @echo
creating __semctl.o &&  printf '\t.file "__semctl.S"\n#include
*** Error 1 in /usr/src (Makefile.cross:360 'cross-lib')

The diff of my changes is attached.


cross.diff (6K) Download Attachment