Bug 206303

Summary: 11.0-CURRENT -r294096 boot/powerpc/kboot/Makefile for TARGET_ARCH=powerpc (non-64, clang based): unsupported argument '-mppc64bridge' to option '-Wc,' (clang 3.8.0 at the time)
Product: Base System Reporter: Mark Millard <marklmi26-fbsd>
Component: binAssignee: freebsd-bugs mailing list <bugs>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: patch
Priority: ---    
Version: 11.0-BETA1   
Hardware: powerpc   
OS: Any   
Attachments:
Description Flags
Updated patch since NETIF_OPEN_CLOSE_ONCE was later removed none

Description Mark Millard 2016-01-16 04:21:33 UTC
Not that I expected everything to work but I tried an amd64 based -r294096 -> powerpc buildworld buildkernel based on base/projects/clang3.8.0-import for TARGET_ARCH=powerpc (non-64). This was WITH_BOOT= in the src.conf file.

What stopped it was an attempt to use: -Wc,-mppc64bridge

That was from: base/head/sys/boot/powerpc/kboot/Makefile

(One of the SRCS in that Makefile is ppc64_elf_freebsd.c as well.)

The command line getting the message is for compiling conf.c and also has a -mcpu=powerpc64 in it. But the error message is:

cc: error: unsupported argument '-mppc64bridge' to option '-Wc,'

As far as I can tell looking at the history this has possibly been true since 11.0-CURRENT -r276331 on 2014-Dec-28 when base/head/sys/boot/powerpc/kboot/Makefile was created. I may just be the first to have tried such a clang-based powerpc build sequence.


It would appear that kboot should possibly only be built when TARGET_ARCH=powerpc64 and not when TARGET_ARCH=powerpc . Otherwise more than clang likely has to be able to target powerpc64 specifics for a TARGET_ARCH=powerpc build. (But this is guess work on my part for the FreeBSD criteria for such things. But a stopped TARGET_ARCH=powerpc build when clang based does not seem a likely intended result.)
Comment 1 Mark Millard 2016-01-16 04:49:13 UTC
Looks like I should have referenced -r276688 (2015-Jan-5) as when head/sys/boot/powerpc/Makefile got its reference to kboot.
Comment 2 Mark Millard 2016-07-11 21:03:01 UTC
Nathon Whitehorn had me instead test building based on sys/boot/powerpc/kboot/Makefile having 2 powerpc64 specific options removed:

# svnlite diff sys/boot/powerpc/kboot/Makefile
Index: sys/boot/powerpc/kboot/Makefile
===================================================================
--- sys/boot/powerpc/kboot/Makefile	(revision 302457)
+++ sys/boot/powerpc/kboot/Makefile	(working copy)
@@ -71,7 +71,7 @@
# Avoid the open-close-dance for every file access as some firmwares perform
# an auto-negotiation on every open of the network interface and thus causes
# netbooting to take horribly long.
-CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64
+CFLAGS+=	-DNETIF_OPEN_CLOSE_ONCE

# Always add MI sources
.PATH:		${.CURDIR}/../../common ${.CURDIR}/../../../libkern
@@ -88,9 +88,6 @@

LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.powerpc

-# 64-bit bridge extensions
-CFLAGS+= -Wa,-mppc64bridge
-
# Pull in common loader code
#.PATH:		${.CURDIR}/../../ofw/common
#.include	"${.CURDIR}/../../ofw/common/Makefile.inc"


The TARGET_ARCH=powerpc build completed with the following messages (from grep'ing for kboot in the typescript file):

===> sys/boot/powerpc/kboot (all)
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/vers.c
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/conf.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/metadata.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/vers.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/main.o
/usr/src/sys/boot/powerpc/kboot/main.c:307:12: warning: variable 'sp' is uninitialized when used here [-Wuninitialized]
/usr/src/sys/boot/powerpc/kboot/main.c:306:29: note: initialize the variable 'sp' to silence this warning
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/ppc64_elf_freebsd.o
/usr/src/sys/boot/powerpc/kboot/ppc64_elf_freebsd.c:94:15: warning: implicit declaration of function 'md_load64' is invalid in C99 [-Wimplicit-function-declaration]
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/host_syscall.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/hostcons.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/hostdisk.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/kerneltramp.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/kbootfdt.o
--- kbootfdt.o ---
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:54:17: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
/usr/src/sys/boot/powerpc/kboot/host_syscall.h:36:21: note: passing argument to parameter 'path' here
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:123:8: warning: assigning to 'uint64_t *' (aka 'unsigned long long *') from 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:125:8: warning: assigning to 'uint64_t *' (aka 'unsigned long long *') from 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:134:8: warning: assigning to 'uint32_t *' (aka 'unsigned int *') from 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:135:8: warning: assigning to 'uint32_t *' (aka 'unsigned int *') from 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/ucmpdi2.o
In file included from /usr/src/sys/boot/powerpc/kboot/../../../libkern/ucmpdi2.c:37:
In file included from /usr/src/sys/boot/powerpc/kboot/../../../libkern/quad.h:59:
/usr/src/sys/boot/powerpc/kboot/../../../sys/syslimits.h:41:2: warning: "No user-serviceable parts inside." [-W#warnings]
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/boot.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/commands.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/console.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/devopen.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/interp.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/interp_backslash.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/interp_parse.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/ls.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/misc.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/module.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/panic.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/load_elf32.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/reloc_elf32.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/load_elf64.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/reloc_elf64.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/dev_net.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/disk.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/part.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/crc32.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/interp_forth.o
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/loader.kboot
Building /usr/obj/clang/powerpc.powerpc/usr/src/sys/boot/powerpc/kboot/loader.help

The compiler involved was clang 3.8.0 . (This was a WITH_META_MODE=yes build.)

The TARGET_ARCH=powerpc64 build also completed. The compiler involved was powerpc64-gcc. (This was a WITH_META_MODE=yes build.) It showed the warnings:

# grep kboot ~/sys_typescripts/typescript_make_powerpc64vtsc_nodebug_incl_clang_xtoolchain-amd64-host-2016-07-11:11:02:56 | grep -i warning:
/usr/src/sys/boot/powerpc/kboot/ppc64_elf_freebsd.c:94:15: warning: implicit declaration of function 'md_load64' [-Wimplicit-function-declaration]
/usr/src/sys/boot/powerpc/kboot/hostdisk.c:96:10: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'void *' [-Wformat=]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:54:17: warning: passing argument 1 of 'host_open' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:123:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:125:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:134:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
/usr/src/sys/boot/powerpc/kboot/kbootfdt.c:135:8: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
/usr/src/sys/boot/powerpc/kboot/../../../sys/syslimits.h:41:2: warning: #warning "No user-serviceable parts inside." [-Wcpp]
/usr/src/sys/boot/powerpc/kboot/../../common/ls.c:142:18: warning: variable 'tail' set but not used [-Wunused-but-set-variable]

I also did gcc 4.2.1 based cross-builds for TARGET_ARCH=powerpc and TARGET_ARCH=powerpc64 and they completed. They had analogous warnings to what clang (powerpc) and powerpc64-gcc (powerpc64) produced.

I do not have a context to test powerpc64 or powerpc kboot in. But the above shows that the TARGET_ARCH=powerpc will build if the file is adjusted.
Comment 3 Mark Millard 2017-01-10 10:14:43 UTC
Created attachment 178694 [details]
Updated patch since NETIF_OPEN_CLOSE_ONCE was later removed

Be warned that I have no context to test a build of
kboot. I only checked if the buildworld buildkernel
completes with the change.

(The earlier patch was in comment #2.)
Comment 4 Mark Millard 2019-07-09 01:57:35 UTC
This was fixed in head -348005 and appears to have been MFC'd.