Date: Fri, 19 Oct 2018 07:23:58 -0700 From: Mark Millard <marklmi@yahoo.com> To: FreeBSD Toolchain <freebsd-toolchain@freebsd.org>, John Baldwin <jhb@freebsd.org>, Sean Fertile <sd.fertile@gmail.com> Cc: Justin Hibbits <chmeeedalf@gmail.com>, Nathan Whitehorn <nwhitehorn@freebsd.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org> Subject: Re: Reasons to still not build buildworld buildkernel via system-clang --John Baldwin notes one I was unaware of Message-ID: <CF792C64-96D5-4C64-BEAA-D5878C96021C@yahoo.com> In-Reply-To: <CA%2BD7ZeEwOnshEmnRepH6_y3ns2bF859k5i-1fEspYwt0mWJ_gg@mail.gmail.com> References: <23400842-E5CB-4251-BFE5-78D524A64012@yahoo.com> <CA%2BD7ZeEwOnshEmnRepH6_y3ns2bF859k5i-1fEspYwt0mWJ_gg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[I'm adding toolchain and John B. to the TO: list. John B. may want to reply to Sean F. I'm also adding a /lib/libgcc_s.so related item to the list of 3 known issues.] > On 2018-Oct-19, at 6:21 AM, Sean Fertile <sd.fertile at gmail.com> = wrote: >=20 > Clang isn't getting the tls model wrong, it actually generates pic = code by default as if -fpic were specified. I think the original intent = behind switching=20 > to pic by default was due to incorrectly thinking gcc was pic by = default (I'm not sure if this was meant as only gcc on BSD or gcc on = powerpc64 in general),=20 > as well as working around some problems that clangs non-pic codegen = has/had for the ELF V1 abi. There are some patches on phabricator for = switching > the default back to non-pic codegen, but they leave the pic default = for BSD: https://reviews.llvm.org/D53384 and = https://reviews.llvm.org/D53383 >=20 > According to what you and John are saying the pic default is incorrect = for BSD as well. If thats the case please either comment on the reviews = to let Stefan know, > or let me know here and we can update the patches accordingly. >=20 > Thanks > Sean >=20 >=20 >=20 >> On Thu, Oct 18, 2018 at 11:27 AM Mark Millard via freebsd-ppc = <freebsd-ppc@freebsd.org> wrote: >> I described to John Baldwin what I know of for why clang is >> not yet appropriate to buildworld buildkernel for powerpc64 >> and powerpc: >>=20 >> QUOTE >> Unfortunately, clang is broken in other ways for buildworld >> buildkernel use for targeting powerpc64 or powerpc: >>=20 >> A) it silently ignores __builtin_eh_return(offset,handler) >> and so produces system-library code that is broken >> relative to handling thrown C++ exceptions. >>=20 >> B) it produces types of linkage for buildkernel that >> FreeBSD does not handle, leading to dynamic loads >> of .ko files that crash the system. (Back in clang >> 4 days it did not have this problem and I was >> running kernels built by clang.) >> END QUOTE >>=20 >> John Baldwin reported back something of which I was unaware: >>=20 >> QUOTE >> It will also get the TLS model wrong for powerpc. Both MIPS and = powerpc >> have an implicit default to PIC mode and llvm interprets this = implicit >> PIC to mean that it should use dynamic TLS models (intended for use = in >> shared libraries) always. GCC only uses dynamic models if -fPIC is >> explicitly passed on the command line. I have a hack to force the = TLS model >> for static libraries and binaries for MIPS in bsd.*.mk that isn't = in-tree, >> but it really needs to be fixed in clang and llvm. >> END QUOTE >>=20 >> I wonder if there is anything in llvm's bugzilla about this, or >> FreeBSD's bugzilla for that matter. >>=20 >> Are there other known issues not covered by the above 3? >>=20 One other item that I should have mentioned (so 4 overall): /lib/libgcc_s.so does not push and pop the CFA (Cannonical Frame Address) information during DW_CFA_remember_state and DW_CFA_restore_state and so _Unwind_RaiseException can end up stuck looping looking at the same frame over and over when the compiler happens to generate these: The default stack register plus an offset of 0 ends up being used as the CFA rule. Other register information tends to be defined relative to the CFA. clang does generate DW_CFA_remember_state and DW_CFA_restore_state in some contexts. Some of the /usr/tests/Kyuafile tests for use with devel/kyua timeout this way and so end up as classified as broken (instead of as failed). If llvm's libunwind were made to work for FreeBSD's powerpc family ABIs , then switching to it would be one way to fix this. llvm's libunwind currently fails to compile for FreeBSD. One reason is it uses Darwin specific powerpc family assembler notation in a .S file (for example, lack of % before rN register notation). Another reason is the .S file in question requires the C preprocessor to be run on it to select the right code for the architecture but FreeBSD doe not do so when targeting powerpc64 (or, likely, powerpc). I do not claim that is all there may be to getting llvm's libunwind working for powerpc64 and powerpc FreeBSD. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CF792C64-96D5-4C64-BEAA-D5878C96021C>