Bug 215107 - head -r309656 clang 3.9.0 for TARGET_ARCH=powerpc: -mminimal-toc rejected (missing llvm 19098 fix?)
Summary: head -r309656 clang 3.9.0 for TARGET_ARCH=powerpc: -mminimal-toc rejected (mi...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: powerpc Any
: --- Affects Only Me
Assignee: Justin Hibbits
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-12-07 04:36 UTC by Mark Millard
Modified: 2017-04-01 19:31 UTC (History)
1 user (show)

See Also:


Attachments
patch to remove -mminima-loc use for pwoerpc64 in modules/zfs (430 bytes, patch)
2016-12-09 02:41 UTC, Mark Millard
no flags Details | Diff
Corrected patch to track compiler type (579 bytes, text/plain)
2017-01-10 09:23 UTC, Mark Millard
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Millard 2016-12-07 04:36:10 UTC
llvm 19098 has a comment that says:

-mlongcall added in r280040/r280041

but the original submittal also requested
-mminimal-toc so the Resolved status
of 19098 might be that both were covered.

Another issue might be powerpc-only vs.
both powerpc64 and powerpc.

As for what happened when trying to build
head -309656 (after bypassing the rejection of
of some BOOK E instructions in hwpmc). . .

--- avl.o ---
clang: error: unknown argument: '-mminimal-toc'
*** [avl.o] Error code 1

( sys/modules/zfs/avl.o to be specific)

The metadata content was. . .

# Meta data file /usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/sys/GENERIC64vtsc-NODBG/modules/usr/src/sys/modules/zfs/avl.o.meta
CMD /usr/bin/clang -target powerpc64-unknown-freebsd12.0 --sysroot=/usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/tmp -B/usr/local/powerpc64-freebsd/bin/  -O2 -pipe -DFREEBSD_NAMECACHE -DBUILDING_ZFS -mminimal-toc  -fno-strict-aliasing -D_KERNEL -DKLD_MODULE -nostdinc  -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs -I/usr/src/sys/cddl/contrib/opensolaris/uts/common/zmod -I/usr/src/sys/cddl/contrib/opensolaris/uts/common -I/usr/src/sys -I/usr/src/sys/cddl/contrib/opensolaris/common/zfs -I/usr/src/sys/cddl/contrib/opensolaris/common -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/sys/GENERIC64vtsc-NODBG/opt_global.h -I. -I/usr/src/sys -fno-common -g -fno-omit-frame-pointer -I/usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/sys/GENERIC64vtsc-NODBG  -mno-altivec -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith  -msoft-float  -std=iso9899:1999 -include /usr/src/sys/cddl/compat/opensolaris/sys/debug_compat.h -c /usr/src/sys/cddl/contrib/opensolaris/common/avl/avl.c -o avl.o
CMD ctfconvert -L VERSION -g avl.o
CWD /usr/obj/powerpc64vtsc_clang_altbinutils_kernel/powerpc.powerpc64/usr/src/sys/GENERIC64vtsc-NODBG/modules/usr/src/sys/modules/zfs
TARGET avl.o
-- command output --
clang: error: unknown argument: '-mminimal-toc'
*** Error code 1
Comment 1 Mark Millard 2016-12-07 04:51:06 UTC
(In reply to Mark Millard from comment #0)

Looks like the powerpc64 -mminimal-toc has
been around since 2011-Feb-27:

https://svnweb.freebsd.org/base/head/sys/modules/zfs/Makefile?revision=219089&view=markup

So clang 3.9.0 apparently lost having it compared to my
earlier clang 3.8.0 tests --or back then this zfs code
was not built for powerpc64.
Comment 2 Mark Millard 2016-12-07 05:00:41 UTC
(In reply to Mark Millard from comment #1)

Just in case it matters: This was a cross build from amd64.
Comment 3 Mark Millard 2016-12-07 05:05:22 UTC
(In reply to Mark Millard from comment #1)

The comparison to clang 3.8.0 is mistaken:

I had only used powerpc64-xtoolchain-gcc for
powerpc64's kernel.

The -mminimal-toc issue could have existed
with clang for a long time based on what I've
done.
Comment 4 Mark Millard 2016-12-09 02:31:51 UTC
(In reply to Mark Millard from comment #2)

I commented out the addition of -mminimal-toc to
CFLAGS in sys/modules/zfs/Makefile and doing so
allowed buildkernel to continue: There are no
other uses of -mminimial-toc that were run into.

In fact (with another patch present for a
different issue): buildkernel completed.

Unfortunately the build does not boot.

But nothing says that the boot failure is tied to
the lack of -minimial-toc.

So it might be possible to sidestep clang 3.9.0
not having -mminimal-toc byt simply not using the
option in sys/modules/zfs/Makefile .
Comment 5 Mark Millard 2016-12-09 02:41:32 UTC
Created attachment 177813 [details]
patch to remove -mminima-loc use for pwoerpc64 in modules/zfs

buildkernel does not need -mminimal-toc to complete
for clang 3.9.0 targetting powerpc64 (given other
patche(s) for other issues): no other examples
for powerpc64.

Note: buildworld did not run into the -mminimal-toc
issue for powerpc64. So if the kernel also avoids it
clang 3.9.0 might well not need to have support
added.


Side note:

Just what it will take to build a bootable kernel is
a separate question at this point. There is some
list activity about the boot failures that result
(varying details depending on the binutils variant
used).
Comment 6 Mark Millard 2017-01-10 09:23:43 UTC
Created attachment 178693 [details]
Corrected patch to track compiler type

Since at least gcc 4.2.1 requires the -mminimal-toc usage
have the patch track the COMPILER_TYPE (gcc vs. not) for
if -mminimal-toc is used vs. not.
Comment 7 Mark Millard 2017-01-10 20:33:21 UTC
Comment on attachment 178693 [details]
Corrected patch to track compiler type

An alternate if supported in the context is:

CFLAGS.gcc+=-mminimal-toc
Comment 8 Justin Hibbits freebsd_committer 2017-02-01 02:45:57 UTC
Fixed by r313005, will be MFC'd with the other clang changes.
Comment 9 Justin Hibbits freebsd_committer 2017-04-01 19:31:03 UTC
MFC'd to stable/11 316369