Summary: | mips build with Clang + LLD fails | ||
---|---|---|---|
Product: | Base System | Reporter: | Ed Maste <emaste> |
Component: | misc | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed Overcome By Events | ||
Severity: | Affects Only Me | CC: | Andrew, dnelson_1901, jhb, kevans |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | mips | ||
OS: | Any | ||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228919 |
Description
Ed Maste
![]() ![]() What build flags need to be set to reproduce this? (In reply to Andrew Turner from comment #1) I saw this in a tinderbox build from my wipbsd branch https://github.com/emaste/freebsd/tree/wipbsd.20181109 I enabled Clang for mips in https://github.com/emaste/freebsd/commit/d676ebee94e317b93d61d3fc346eaab75bb8b5be I think that it should be reproducible with these src.conf knobs: WITH_CLANG WITH_CLANG_BOOTSTRAP WITH_CLANG_IS_CC WITH_LLD WITH_LLD_BOOTSTRAP WITH_LLD_IS_LD (I used to have some additional compiler fixes for mips in an earlier wipbsd branch but I seem to have lost them.) This appears to be a clang 7.0 regression. External GCC is able to build this fine. In addition, the old crt bits in contrib/gcc use the same logic (.cpload without a .cprestore), and while clang compiled that during a buildworld WITHOUT_BSD_CRTBEGIN=yes, clang now chokes trying to link libc:
ld: error: can't create dynamic relocation R_MIPS_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in cancelpoints_sem_new.pico
>>> referenced by cancelpoints_sem_new.c
>>> cancelpoints_sem_new.pico:(.eh_frame+0x1C)
So, clang 7.0 seems to be busted compared to clang 6 + patches. :-/ I haven't tried mips64 yet, only 32-bit mips. Cheri only tests 64-bit mips, so it might be that 64-bit works ok and only 32-bit mips is broken.
A gcc build actually does generate the same warning message, but doesn't fail the compile. It looks like gcc doesn't add "--fatal-warnings" to the gas commandline when gcc is in -Werror mode, so the assembly warnings are ignored. I use the following patch in my local mips-llvm branch: commit 9783fdf63c8a4e1775a494b47b7f3648b65779ab Author: Kyle Evans <kevans@FreeBSD.org> Date: Mon Aug 19 13:18:47 2019 -0500 Hack around .cprestore anger diff --git a/lib/csu/mips/crt.h b/lib/csu/mips/crt.h index 1d967b73ffe..a90d8661f34 100644 --- a/lib/csu/mips/crt.h +++ b/lib/csu/mips/crt.h @@ -29,12 +29,14 @@ #define HAVE_CTORS #define CTORS_CONSTRUCTORS #ifdef __mips_o32 +/* The .cprestore is bogus, as we do elsewhere */ #define INIT_CALL_SEQ(func) \ ".set noreorder \n" \ "bal 1f \n" \ "nop \n" \ "1: \n" \ ".cpload $ra \n" \ + ".cprestore 12 \n" \ ".set reorder \n" \ ".local " __STRING(func) "\n" \ "jal " __STRING(func) I fake the .cprestore based on what we do for _mcount in ^/sys/mips/include/profile.h. Whether this is wrong or not, I do not know, but it results in a functional world along with the rest of my mips-llvm patches (https://github.com/freebsd/freebsd/compare/master...kevans91:mips-llvm?expand=1), some of which were stolen from jhb. This branch results in a functional CLANG_BOOTSTRAP+LLD_BOOTSTRAP world and kernel for mips32, but mips64 kernel is horribly broken in weird ways with both llvm8 and projects/clang900-import and CLANG_BOOTSTRAP+LD_BOOTSTRAP. Update headline to remove mention of BSD_CRTBEGIN, it is on by default for MIPS now and works. all in-tree archs build with clang & lld now |