Error cross building for the Power PC

Hi,

I build clang/LLVM using libcxx, libcxxabi, musl (C standard library), and compiiler-rt. As sort of a sanity test, I then use that clang/LLVM to cross build itself for for arm, armeb, i386, mips, mipsel, and ppc. (My host is x86_64). For the last month or so the ppc build has been failing when linking clang related things. The ppc code generator seems to want __*ti3 run time support, which it apparently didn't in the past. I suspect I may be missing something when I build compiler-rt. Any suggestions?

-Rich

P.S.: I get errors like:

/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x168): undefined reference to `__ashlti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x184): undefined reference to `__ashlti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x1a4): undefined reference to `__lshrti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x1cc): undefined reference to `__lshrti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x23c): undefined reference to `__lshrti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x274): undefined reference to `__ashlti3'
/home/rich/ellcc/llvm/tools/clang/lib/Basic/Warnings.cpp:(.text._ZN5clang21ProcessWarningOptionsERNS_17DiagnosticsEngineERKNS_17DiagnosticOptionsEb+0x294): undefined reference to `__lshrti3'
ecc: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [/home/rich/ellcc/llvm-build-ppc-linux/Release+Asserts/bin/c-index-test] Error 1
make[4]: Leaving directory `/home/rich/ellcc/llvm-build-ppc-linux/tools/clang/tools/c-index-test'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/rich/ellcc/llvm-build-ppc-linux/tools/clang/tools'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/rich/ellcc/llvm-build-ppc-linux/tools/clang'
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/home/rich/ellcc/llvm-build-ppc-linux/tools'
make: *** [all] Error 1
[~/ellcc/llvm-build-ppc-linux] dev%

From: "Richard Pennington" <rich@pennware.com>
To: "LLVM Developers Mailing List" <llvmdev@cs.uiuc.edu>, "cfe-dev@cs.uiuc.edu Developers" <cfe-dev@cs.uiuc.edu>
Sent: Sunday, May 11, 2014 5:51:29 AM
Subject: [cfe-dev] Error cross building for the Power PC

Hi,

I build clang/LLVM using libcxx, libcxxabi, musl (C standard
library),
and compiiler-rt. As sort of a sanity test, I then use that
clang/LLVM
to cross build itself for for arm, armeb, i386, mips, mipsel, and
ppc.
(My host is x86_64). For the last month or so the ppc build has been
failing when linking clang related things. The ppc code generator
seems
to want __*ti3 run time support, which it apparently didn't in the
past.
I suspect I may be missing something when I build compiler-rt. Any
suggestions?

It looks like the function exists (http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/builtins/ashlti3.c), but requires CRT_HAS_128BIT to be defined during the build process.

Furthermore, it looks like the dependence on CRT_HAS_128BIT was introduced in r201909, and is defined in lib/builtins/int_types.h only when __LP64__ is defined (which explains why you're not getting it on PPC32). I'm pretty sure this is not quite right because PPC32 also has __int128 support. Can you try adjusting the header so that CRT_HAS_128BIT will also be defined if __ppc__ is defined, and let me know if that fixes things?

-Hal