Hello,
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/Makefile.inc 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/gen/setjmp.S
/usr/src/lib/libc/arch/powerpc/gen/sigsetjmp.S
/usr/src/lib/libc/arch/powerpc/string/memmove.S
/usr/src/lib/libc/arch/powerpc/sys/Ovfork.S
/usr/src/lib/libc/arch/powerpc/sys/brk.S
/usr/src/lib/libc/arch/powerpc/sys/sbrk.S
/usr/src/lib/libc/arch/powerpc/sys/sigpending.S
/usr/src/lib/libc/arch/powerpc/sys/sigprocmask.S
/usr/src/lib/libc/arch/powerpc/sys/sigsuspend.S
/usr/src/lib/libc/arch/powerpc/sys/syscall.S
/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
-DRESOLVSORT -DFLOATING_POINT -DPRINTF_WIDE_CHAR -DSCANF_WIDE_CHAR
-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/Makefile.inc:153 '__semctl.o': @echo
creating __semctl.o && printf '\t.file "__semctl.S"\n#include
"SYS.h"\nRS...)
*** Error 1 in /usr/src (Makefile.cross:360 'cross-lib')
The diff of my changes is attached.
Thanks!
Karel
diff --git a/Makefile.cross b/Makefile.cross
index 94a394e21dd..007d2f0ce38 100644
--- a/Makefile.cross
+++ b/Makefile.cross
@@ -135,6 +135,8 @@ cross-env:
${CROSSDIRS}:
.if ${TARGET_ARCH} == "arm" && ${MACHINE_IS_LP64} == "yes"
# this config is allowed
+.elif ${TARGET_ARCH} == "powerpc" && ${MACHINE_IS_LP64} == "yes"
+ # this config is allowed too
.elif ${TARGET_IS_LP64} != ${MACHINE_IS_LP64}
@echo "host and target have different size longs"
@echo "cross compiler generates bad code; aborting"; exit 1
diff --git a/gnu/usr.bin/binutils-2.17/bfd/coffcode.h b/gnu/usr.bin/binutils-2.17/bfd/coffcode.h
index 7ac403d6c14..5ac4bc1f2f4 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/coffcode.h
+++ b/gnu/usr.bin/binutils-2.17/bfd/coffcode.h
@@ -3162,8 +3162,10 @@ coff_compute_section_file_positions (bfd * abfd)
sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
align = 1 << current->alignment_power;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wabsolute-value"
pad = abs (current->vma - sofar) % align;
-
+#pragma GCC diagnostic pop
if (pad)
{
pad = align - pad;
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c b/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
index 328031bbe7e..884d1b5ce42 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf32-ppc.c
@@ -5849,6 +5849,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
howto = NULL;
if (r_type < R_PPC_max)
howto = ppc_elf_howto_table[r_type];
+#pragma GCC diagnostic ignored "-Wswitch"
switch (r_type)
{
default:
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf64-ppc.c b/gnu/usr.bin/binutils-2.17/bfd/elf64-ppc.c
index 33327f44cba..76dd52ded42 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/elf64-ppc.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/elf64-ppc.c
@@ -4111,8 +4111,11 @@ ppc64_elf_archive_symbol_lookup (bfd *abfd,
len = strlen (name);
dot_name = bfd_alloc (abfd, len + 2);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-pointer-arithmetic"
if (dot_name == NULL)
return (struct elf_link_hash_entry *) 0 - 1;
+#pragma GCC diagnostic pop
dot_name[0] = '.';
memcpy (dot_name + 1, name, len + 1);
h = _bfd_elf_archive_symbol_lookup (abfd, info, dot_name);
diff --git a/gnu/usr.bin/binutils-2.17/bfd/ppcboot.c b/gnu/usr.bin/binutils-2.17/bfd/ppcboot.c
index 7c8a4190bac..6ea0cf6c9bb 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/ppcboot.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/ppcboot.c
@@ -425,10 +425,11 @@ ppcboot_bfd_print_private_bfd_data (abfd, farg)
if (tdata->header.os_id)
fprintf (f, "OS_ID = 0x%.2x\n", tdata->header.os_id);
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpointer-bool-conversion"
if (tdata->header.partition_name)
fprintf (f, _("Partition name = \"%s\"\n"), tdata->header.partition_name);
-
+#pragma GCC diagnostic pop
for (i = 0; i < 4; i++)
{
long sector_begin = bfd_getl_signed_32 ((PTR) tdata->header.partition[i].sector_begin);
diff --git a/gnu/usr.bin/binutils-2.17/bfd/xcofflink.c b/gnu/usr.bin/binutils-2.17/bfd/xcofflink.c
index 47c330b6c15..46cd8cfe665 100644
--- a/gnu/usr.bin/binutils-2.17/bfd/xcofflink.c
+++ b/gnu/usr.bin/binutils-2.17/bfd/xcofflink.c
@@ -5763,7 +5763,7 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
struct internal_reloc *irelend;
struct xcoff_link_hash_entry **rel_hash;
struct xcoff_toc_rel_hash *toc_rel_hash;
- bfd_byte *erel;
+ bfd_byte *erel = NULL;
bfd_size_type rel_size;
/* A stripped file has no relocs. */
diff --git a/gnu/usr.bin/binutils-2.17/gas/config/tc-ppc.c b/gnu/usr.bin/binutils-2.17/gas/config/tc-ppc.c
index d5bdb9e643e..f15baf9600f 100644
--- a/gnu/usr.bin/binutils-2.17/gas/config/tc-ppc.c
+++ b/gnu/usr.bin/binutils-2.17/gas/config/tc-ppc.c
@@ -1482,8 +1482,11 @@ ppc_insert_operand (insn, operand, val, file, line)
errmsg = NULL;
insn = (*operand->insert) (insn, (long) val, ppc_cpu, &errmsg);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-security"
if (errmsg != (const char *) NULL)
as_bad_where (file, line, errmsg);
+#pragma GCC diagnostic pop
}
else
insn |= (((long) val & ((1 << operand->bits) - 1))
@@ -2224,6 +2227,8 @@ md_assemble (str)
if ((operand->flags & PPC_OPERAND_FAKE) != 0)
{
insn = (*operand->insert) (insn, 0L, ppc_cpu, &errmsg);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-security"
if (errmsg != (const char *) NULL)
as_bad (errmsg);
continue;
@@ -2239,6 +2244,7 @@ md_assemble (str)
insn = (*operand->insert) (insn, 0L, ppc_cpu, &errmsg);
if (errmsg != (const char *) NULL)
as_bad (errmsg);
+#pragma GCC diagnostic pop
}
if ((operand->flags & PPC_OPERAND_NEXT) != 0)
next_opindex = *opindex_ptr + 1;
diff --git a/gnu/usr.bin/binutils-2.17/opcodes/ppc-dis.c b/gnu/usr.bin/binutils-2.17/opcodes/ppc-dis.c
index 35875d1ac33..5e0185cbfaa 100644
--- a/gnu/usr.bin/binutils-2.17/opcodes/ppc-dis.c
+++ b/gnu/usr.bin/binutils-2.17/opcodes/ppc-dis.c
@@ -84,8 +84,10 @@ powerpc_dialect (struct disassemble_info *info)
else if (strstr (info->disassembler_options, "64") != NULL)
dialect |= PPC_OPCODE_64;
}
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-pointer-arithmetic"
info->private_data = (char *) 0 + dialect;
+#pragma GCC diagnostic pop
return dialect;
}
diff --git a/gnu/usr.bin/clang/Makefile.inc b/gnu/usr.bin/clang/Makefile.inc
index 5dda2c369a1..4ae028354bb 100644
--- a/gnu/usr.bin/clang/Makefile.inc
+++ b/gnu/usr.bin/clang/Makefile.inc
@@ -70,6 +70,6 @@ LDADD+= ${.OBJDIR}/../lib${lib}/lib${lib}.a
.endfor
LDADD+=-Wl,--end-group
-.if ${MACHINE_ARCH} == "powerpc"
-LDFLAGS+=-Wl,-relax
-.endif
+#.if ${MACHINE_ARCH} == "powerpc"
+#LDFLAGS+=-Wl,-relax
+#.endif
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index 812bef29aea..cd8288c781e 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -2,10 +2,10 @@
.include <bsd.own.mk>
-.if ${COMPILER_VERSION:L} != "clang"
-CC= clang
-CXX= clang++
-.endif
+#.if ${COMPILER_VERSION:L} != "clang"
+#CC= clang
+#CXX= clang++
+#.endif
.if ${BUILD_CLANG:L} == "yes"