Code Monkey home page Code Monkey logo

cmlfs's Introduction

CMLFS - Clang Musl Linux From Scratch

CMLFS can either mean "Clang-built Musl Linux from Scratch" or "Clang MLFS". It started as a hobby to see if a Linux system can be built with clang as primary toolchain and GCC as secondary (for packages that cannot be built with clang). This is based on Linux From Scratch and my previous work MLFS. Big thanks to Chimera-Linux that had patches that fixed a lot of issues.

DISCLAIMER

Use at you own risk. This builds a Unix-like system that may not be stable enough as a 'daily driver' for most users. Security-hardening of the built system is beyound the scope of this project. This repo started as means to backup and archive my work.

Getting Started

The master branch may be unstable when I am working on upgrading CMLFS.

To build this project, pick a branch other than master OR choose a tag. Each branch & tag are based on the LLVM version. As of this writing, llvm-15.0.6 is stable. Older branches maybe incomplete or unstable (may not compile).

When I have time later, I will write a more thorough introduction for users new to CMLFS.

Specification

  • C Runtime Library (system libc): Musl
  • Default C Compiler: clang (LLVM)
  • Default C++ compiler: clang++ (LLVM)
  • Default linker: lld (LLVM)
  • Default binary tools: elftoolchain
  • Secondary C Compiler: GCC
  • Secondary C++ compiler: GCC
  • Secondary binary tools: GNU Binutils & LLVM
  • Secondary linker(s): bfd, gold
  • C++ standard library: libcxx (LLVM)
  • C++ ABI library: libcxxabi (LLVM)
  • Unwinding Library: libunwind (LLVM)
  • Init system: skarnet's S6 & S6-rc
  • Device manager: Udev
  • TLS Implementaion: LibreSSL
  • Secondary TLS Implementaion: OpenSSL
  • System Shell: Bash
  • System Gettext: gettext-tiny
  • Curses Library: netbsd-curses

Supported Architectures

  • AMD64/x86_64: Toolchains and final system build sucessfully (musl & glibc hosts) .
  • i686: Pending
  • AARCH64/ARM64: Pending
  • ARMV7L: Pending

Goals

  • Build a toolchain (llvmtools) with LLVM+stage1_clang but without GCC
  • Build final root filesystem with LLVM
  • Set default linker as lld(LLVM)
  • Set default C++ standard library as libcxx(LLVM)
  • Set default C++ ABI library as libcxxabi(LLVM)
  • Set default stack unwinding library as libunwind(LLVM)
  • Eliminate dependacy on GCC's libgcc_s
  • Build GCC as a secondary systen compiler.
  • Build toolchain (llvmtools) with GCC as secondary compiler
  • Merge cross-tools build with cgnutools
  • Build successfully on a Glibc host
  • Build final system without GCC
  • Replace binutils with elftoolchain
  • Reduce LLVM size & build time for cgnutools and llvmtools
  • Create initramfs with busybox & mdev
  • Build on aarch64

Host System Requirements

  • CMake
  • Ninja/Samurai
  • wget/cURL

Required Base Development tools (may refer to LFS)

  • bash 3.2 (/bin/sh should be a symbolic or hard link to bash)
  • binutils 2.25
  • bison 2.7 (/usr/bin/yacc should be a link to bison or small script that executes bison)
  • bzip2 1.0.4
  • coreutils 6.9
  • diffutils 2.8.1
  • findutils 4.2.31
  • gawk 4.0.1 (/usr/bin/awk should be a link to gawk)
  • GCC 6.2 (including the C++ compiler, g++)
  • Glibc 2.11 / Musl Libc 1.20
  • Grep 2.5.1a
  • gzip 1.3.12
  • linux kernel 3.2 (not sure if it matters, as most distros are running 4.x/5.x kernels
  • m4 1.4.10
  • make 4.0
  • patch 2.5.4
  • Python 3.4
  • sed 4.1.5
  • tar 1.22
  • texinfo 4.7
  • xz 5.0.0
* (if hostdistro is MLFS/LFS, then all development packages are installed)

Current Method

Build 'cross-tools' with Mussel to cross-compile a stage0 LLVM+clang. This stage0 clang will still link to libgcc_s [in cgnutools] but will later be used to build a stage1 clang free of libbgcc_s. The goal is to build clang+friends with clang and not GCC.

  • Some packages can be built once to be used by the toolchain [llvmtools] and the final system, but will be built twice to make it easy to implement a package managment system [which is outside the scope of this project].
  1. Bootstrap build of cgnutools with mussel
  2. Use mussel-built toolchain (cgnutools) to build stage0 LLVM+clang
  3. Use cgnutools to build stage1 LLVM+clang with sysroot at llvmtools with stage0 LLVM+clang
  4. Build enough of llvmtools to enter a chroot with stage1 LLVM+clang
  5. Build the rest of llvmtools under chroot
  6. Build final system with llvmtools

Issues

  • Test for C++11/14 fails when testing stage0 & stage1 LLVM's. Not sure what issue this will cause or if test needs to be revised..
  • Coreutils will not build for llvmtools under 32-bit x86 (i386/i586/i686)
  • Ninja for llvmtools fails to compile with python3. For now use cmake instead of python3

Change log

  • 4.0.0: Upgraded to LLVM 17.0.5
  • 3.0.0: Upgraded to LLVM-15.0.6. cgnutools is now bootstrapped with mussel. Replaced binutils with elftoolchain. Most of llvmtools will be build under chroot to avoid contamination from host.
  • 2.0.0: Upgraded to LLVM-12.0.0. Upgraded GCC to 10.3.1-x Replace ninja with samurai. Replace zlib with zlib-ng. Patched elfutils to build libelf under clang. No longer using /llvmtools/gnu and /opt/gnu.
  • 1.2.0: Incomplete: LLVM-11.0.0, Install GCC & Binutils in /llvmtools & /usr instead of /llvmtools/gnu and /opt/gnu
  • 1.1.0: Sucessfully merged cross-tools and cgnutools to include GCC & binutils.
  • 1.0.0: Sucessfully built on x86_64. GCC built as secondary compiler in /opt/gnu
  • 0.1.3: Configure Stage1 clang correctly with x86_64-pc-linux-musl.cfg.
  • 0.1.2: Use stage0 to build a stage1 clang...Stage1 clang will be used in chroot. Stage1 clang fails to compile
  • 0.1.1: Build stage0 clang by building clang, lld, compiler-rt, libunwind, libcxxabi, libcxx together in llvm source tree. Stage0 builds binaries with host's dynamic linker in /lib
  • 0.1.0: Build cross-tools with GCC to build stage 1 clang... first build libunwind, libcxxabi & libcxx - stage1 Clang broken
  • 0.0.0: First attempt, modeled afer Genshen's repo: Stage 2 clang fails to build.

Projects of Interest

cmlfs's People

Contributors

dslm4515 avatar firasuke avatar konimex avatar takusuman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmlfs's Issues

Any "real" advantages over MLFS?

As the title states, are there any real advantages to CMLFS over MLFS other than that the toolchain is a bit more bloated now as it uses both LLVM/GCC, and that LLVM is a bit worse at optimizations?

CMLFS/3-chroot/010-utmps: utmps Segmentation Fault

I have found the reason why utmps fails to build using Clang 12 from /llvmtools/bin. Since I am trying to build the end system without gcc or binutils, this was a pretty big issue for me.

After some short investigation, I found that somehow the static binaries generated by utmps were claiming to have an interpreter:

# file utmps-utmpd
utmps-utmpd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped

And when debugging with lldb:

* thread #1, name = 'utmps-utmpd', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x00007ffff7fbe950 libc.so`decode_vec(v=0x0000000000000000, a=0x00007fffffffe118, cnt=32) at dynlink.c:198:10

But ldd correctly recognizes the binaries:

$ ldd utmps-utmpd
ldd: utmps-utmpd: Not a valid dynamic program

I found it extremely strange why a statically linked binary would have an interpreter listed by file, and why lldb showed the source of the Segmentation Fault was from within libc.so. So I did a bit more digging.

With CC=x86_64-cmlfs-linux-musl-clang, Clang seems to always pass -dynamic-linker, even for -static (for brevity the linked objects are replaced with ...):

"/llvmtools/bin/ld.lld" --sysroot=/usr --eh-frame-hdr -m elf_x86_64 -static -o utmps-utmpd /usr/lib/crt1.o /usr/lib/crti.o /llvmtools/lib/clang/12.0.0/lib/linux/clang_rt.crtbegin-x86_64.o -L/usr/lib -dynamic-linker /lib/ld-musl-x86_64.so.1 ... -lskarnet --verbose --start-group /llvmtools/lib/clang/12.0.0/lib/linux/libclang_rt.builtins-x86_64.a -l:libunwind.a -lc --end-group /llvmtools/lib/clang/12.0.0/lib/linux/clang_rt.crtend-x86_64.o /usr/lib/crtn.o

With CC=clang, the -dynamic-linker flag is no longer present, however some of the paths are broken, and I must manually pass -L/usr/lib:

"/llvmtools/bin/ld.lld" --sysroot=/llvmtools --eh-frame-hdr -m elf_x86_64 -static -o utmps-utmpd /llvmtools/bin/../lib/crt1.o /llvmtools/bin/../lib/crti.o /llvmtools/lib/clang/12.0.0/lib/linux/clang_rt.crtbegin-x86_64.o -L/usr/lib -L/llvmtools/bin/../lib -L/llvmtools/lib ... -lskarnet --verbose --start-group /llvmtools/lib/clang/12.0.0/lib/linux/libclang_rt.builtins-x86_64.a -l:libunwind.a -lc --end-group /llvmtools/lib/clang/12.0.0/lib/linux/clang_rt.crtend-x86_64.o /llvmtools/bin/../lib/crtn.o

Here's how those are symlinked:

# ls -lah `which x86_64-cmlfs-linux-musl-clang`
lrwxrwxrwx 1 root root 8 Jun 29 07:23 /llvmtools/bin/x86_64-cmlfs-linux-musl-clang -> clang-12
# ls -lah `which clang`
lrwxrwxrwx 1 root root 8 Jun 29 03:44 /llvmtools/bin/clang -> clang-12

Moreover, when building with CC=clang, the build not only succeeds, utmps-utmpd runs without issue:

# ./utmps-utmpd 
utmps-utmpd: fatal: unable to get $IPCREMOTEEUID from environment

This seems to suggest to me that the out of tree cross compilation of LLVM for /llvmtools is somehow broken.

The host system is musl Void Linux running under WSL 2 on x86_64. The target system is also x86_64.

GCC Build Fails: cannot find -lz

Building GCC with /cross-tools ends prematurely with build unable to find zlib:

/cross-tools/lib/gcc/x86_64-mlfs-linux-musl/10.2.1/../../../../x86_64-mlfs-linux-musl/bin/ld: warning: libc.musl-x86_64.so.1, needed by /opt/gnu/lib/libmpc.so, not found (try using -rpath or -rpath-link)
x86_64-mlfs-linux-musl-g++ -no-pie   -g -O2 -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  gcov.o json.o \
        hash-table.o ggc-none.o libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a  -lz -o gcov
/cross-tools/lib/gcc/x86_64-mlfs-linux-musl/10.2.1/../../../../x86_64-mlfs-linux-musl/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:3014: gcov] Error 1
make[2]: Leaving directory '/sources/gcc-10.2.1_pre2/build/gcc'
make[1]: *** [Makefile:4400: all-gcc] Error 2
make[1]: Leaving directory '/sources/gcc-10.2.1_pre2/build'
make: *** [Makefile:963: all] Error 2

TO-DO: Libc++'s __config_site misplaced

Looks like CMake fails to build due too misplaced __config_site header for libc++.

It is at:

/cgnutools/include/x86_64-pc-linux-musl/c++/v1/

But shold be here with __config

/cgnutools/include/c++/v1/

For a work around, just use links:

ln -sv ../../x86_64-pc-linux-musl/c++/v1/__config_site /cgnutools/include/c++/v1/__config_site
ln -sv ../../x86_64-pc-linux-musl/c++/v1/module.modulemap cgnutools/include/c++/v1/module.modulemap

extra/alt: llvm-12 fails to compile with netbsd-curses at stage 8 of cgnutools

I was compiling llvm and then i got this error:
2021-09-12-224038_1013x672_scrot
Full text log: https://termbin.com/eibv
As you can see, it's trying to "call"/link to libc.so.6 from the host system, not the toolchain one.
So, just to be sure, i ran ldd both from the toolchain and from the host just to see where exactly libterminfo.so was trying to link:
2021-09-12-225110_1003x179_scrot
And yes; apparently, when i built netbsd-curses, it was linked to the wrong libc.

I'm not sure if i will fix this right now -- it's late and i have to study and work tomorrow -- , so take this as a reminder and as an advice.

LLVM12: Building LLVM+clang for llvmtools fails

is this issue related to build llvm in llvmtools?

For LLVM 12, I just fine while building. See #12 (comment)

Now moving to chroot steps. I'll report if an issue appeared.

Originally posted by @owl4ce in #14 (comment)

So I switched back to building CMLFS with LLVM12. Still not successful. I accidentally used ninja instead of make:

 [1619/3634] Building CXX object projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o
FAILED: projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o 
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang++  -DHAVE_RPC_XDR_H=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/sanitizer_common -I../projects/compiler-rt/lib/sanitizer_common -Iinclude -I../include -I../projects/compiler-rt/lib/sanitizer_common/.. -g -g1  -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG    -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wframe-larger-than=570 -Wglobal-constructors -std=c++14 -MD -MT projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o -MF projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o.d -o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o -c ../projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
../projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:30:10: fatal error: 'asm/param.h' file not found
#include <asm/param.h>
         ^~~~~~~~~~~~~
1 error generated.
[1620/3634] Building CXX object utils/yaml-bench/CMakeFiles/yaml-bench.dir/YAMLBench.cpp.o
ninja: build stopped: subcommand failed.

Section 3-chroot/072-grub - need check mess in re-link (needed as.gnu also)

In section 3-chroot/072-grub

Build still tries to use clang. Temporarily switch to GCC
mv -v /usr/bin/{gcc,gcc.clang}
ln -sv gcc.gnu /usr/bin/gcc

There a little mess.

  1. It shows "/usr/bin/gcc - no such file"
    Need to add ln -sv gcc.gnu /usr/bin/gcc
  2. Reg. this instruction, configure fails with "wrong assembler" - it looking at "as from clang", not GNU
    I added ln -sv /usr/bin/as.gnu /usr/bin/as
    After these fixes configuration and compile OK

Libcxx, __divti3: symbol not found

when checking libc++.so.1.0 with ldd:

$ LD_LIBRARY_PATH=/cgnutools/lib ldd build/lib/libc++.so.1.0 
        ldd (0x7fd1cf4b8000)
        libc.so => ldd (0x7fd1cf4b8000)
        libunwind.so.1 => /cgnutools/lib/libunwind.so.1 (0x7fd1cf30c000)
        libc++abi.so.1 => /cgnutools/lib/libc++abi.so.1 (0x7fd1cf2b6000)
Error relocating build/lib/libc++.so.1.0: __divti3: symbol not found

What provides __divti3 ?

How do I build this?

Tried emailing you but your account doesn't have obvious email address and user@github bounced because of "organizational settings"?

I cloned your "build llvm with musl" repo, but after reading the README I'm not entirely sure how to run the build? It seems to want me to download another one of your projects and... create a chroot to run it in maybe?

I have my own build script that was building a musl-based llvm Hexagon cross compiler (based off the build plumbing the Hexagon guys checked into the kvm test suite: their test involved building a compiler to build their vm image), but when I tried to run it again llvm died trying to link the rtsanitizer code to libc, which obviously didn't exist yet because you need a compiler to build the C library with. (There was also some discussion on the toybox mailing list about this in... July of last year, I think? I can dig up a link if you're curious.)

How do I build your toolchain project, and have you checked for regressions recently?

Rob

llvmtools: Failed to build Cmake under Glibc

...

[ 28%] Building C object Source/kwsys/CMakeFiles/cmsysTestSharedForward.dir/testSharedForward.c.o
[ 28%] Building C object Source/kwsys/CMakeFiles/cmsysTestsC.dir/testEncode.c.o
[ 28%] Building C object Source/kwsys/CMakeFiles/cmsysTestsC.dir/cmsysTestsC.c.o
[ 29%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_acl.c.o
[ 29%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_check_magic.c.o
In file included from /mnt/cmlfs/sources/pkgs/cmake-3.20.5/Utilities/cmlibarchive/libarchive/archive_acl.c:37:
/usr/include/wchar.h:600:9: error: unknown type name '__gnuc_va_list'
                      __gnuc_va_list __arg)
                      ^
/usr/include/wchar.h:607:8: error: unknown type name '__gnuc_va_list'
                     __gnuc_va_list __arg)
                     ^
/usr/include/wchar.h:613:9: error: unknown type name '__gnuc_va_list'
                      __gnuc_va_list __arg)
                      ^
/usr/include/wchar.h:675:8: error: unknown type name '__gnuc_va_list'
                     __gnuc_va_list __arg)
                     ^
/usr/include/wchar.h:682:7: error: unknown type name '__gnuc_va_list'
                    __gnuc_va_list __arg)
                    ^
/usr/include/wchar.h:687:8: error: unknown type name '__gnuc_va_list'
                     __gnuc_va_list __arg)
                     ^
/usr/include/wchar.h:698:7: error: unknown type name '__gnuc_va_list'
                                  __gnuc_va_list __arg), __isoc99_vfwscanf)
                                  ^
/usr/include/wchar.h:701:6: error: unknown type name '__gnuc_va_list'
                                 __gnuc_va_list __arg), __isoc99_vwscanf)
                                 ^
/usr/include/wchar.h:705:11: error: unknown type name '__gnuc_va_list'
                                      __gnuc_va_list __arg), __isoc99_vswscanf)
                                      ^

... so many errors here ...

I don't know how to override headers PATH to /llvmtools/include, when I try to configure with CFLAGS="-I/llvmtools/include" CXXFLAGS="-I/llvmtools/include" ./bootstrap still fails to build.

LLVM12 :: cgnutools: Fail to build LLVM, cannot find libcurses

On a musl host, LLVM fails to build due to liker not able to find -lcurses:

[  5%] Built target LLVMTableGenGlobalISel
make[2]: Entering directory '/mnt/cmlto/sources/llvm/build'
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make[2]: Entering directory '/mnt/cmlto/sources/llvm/build'
[  5%] Linking CXX executable ../../bin/llvm-tblgen
/mnt/cmlto/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: error: cannot find -lcurses
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:336: error: undefined reference to 'setupterm'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:354: error: undefined reference to 'tigetnum'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:358: error: undefined reference to 'set_curterm'
/mnt/cmlto/sources/llvm/lib/Support/Unix/Process.inc:359: error: undefined reference to 'del_curterm'
collect2: error: ld returned 1 exit status
make[2]: *** [utils/TableGen/CMakeFiles/llvm-tblgen.dir/build.make:192: bin/llvm-tblgen] Error 1
make[2]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:6927: utils/TableGen/CMakeFiles/llvm-tblgen.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlto/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlto/sources/llvm/build'

Same issue on hosts running MLFS 9.0.0 and CMLFS 2.0.0 (with LTO)

First attempt was building cgnutools with LTO. Same error for LLVM. Then I tried again with out LTO: same error.

Libc++.so.1 (llvmtools) requires libatomic.so.1

llvmtools' libc++.so.1 from libcxx should NOT rely on libatomic.so.1, which is provided by GCC.

$ ldd /llvmtools/lib/libc++.so.1
        ldd (0x7fb67cb49000)
        libc.so => ldd (0x7fb67cb49000)
Error loading shared library libatomic.so.1: No such file or directory (needed by /llvmtools/lib/libc++.so.1)
        libunwind.so.1 => /llvmtools/lib/../lib/libunwind.so.1 (0x7fb67ca6b000)
        libc++abi.so.1 => /llvmtools/lib/../lib/libc++abi.so.1 (0x7fb67ca0f000)

This will require to build LLVM for llvmtools with a LD_LIBARARY_PATH hack

[patch] Build `Libelf from Elfutils` with Clang under musl

After so many days of searching .. I finally found it.

elfutils-musl-clang.patch

diff --git a/configure.ac b/configure.ac
index ad046bc2..32524e8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,29 +105,6 @@ AC_CHECK_TOOL([NM], [nm])
 # https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
 # Arrays of Variable Length
 # https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
-AC_CACHE_CHECK([for gcc with GNU99 support], ac_cv_c99, [dnl
-old_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -std=gnu99"
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
-int foo (int a)
-{
-  for (int i = 0; i < a; ++i) if (i % 4) break; int s = a; return s;
-}
-
-double bar (double a, double b)
-{
-  double square (double z) { return z * z; }
-  return square (a) + square (b);
-}
-
-void baz (int n)
-{
-  struct S { int x[[n]]; };
-}])],
-		  ac_cv_c99=yes, ac_cv_c99=no)
-CFLAGS="$old_CFLAGS"])
-AS_IF([test "x$ac_cv_c99" != xyes],
-      AC_MSG_ERROR([gcc with GNU99 support required]))
 
 AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
 	ac_cv_visibility, [dnl
diff --git a/src/elfcompress.c b/src/elfcompress.c
index c5ba6c34..96518a32 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -37,6 +37,10 @@
 #include "libeu.h"
 #include "printversion.h"
 
+#ifndef FNM_EXTMATCH
+# define FNM_EXTMATCH   (1 << 5)        /* Use ksh-like extended matching. */
+#endif
+
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
 
diff --git a/src/readelf.c b/src/readelf.c
index b9740455..26aac82f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -8763,12 +8763,12 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
       /* Apply the "operation advance" from a special opcode
 	 or DW_LNS_advance_pc (as per DWARF4 6.2.5.1).  */
       unsigned int op_addr_advance;
-      inline void advance_pc (unsigned int op_advance)
-      {
-	op_addr_advance = minimum_instr_len * ((op_index + op_advance)
-					       / max_ops_per_instr);
-	address += op_addr_advance;
-	op_index = (op_index + op_advance) % max_ops_per_instr;
+#define advance_pc(op_advance) \
+      {\
+	op_addr_advance = minimum_instr_len * ((op_index + op_advance)\
+					       / max_ops_per_instr);\
+	address += op_addr_advance;\
+	op_index = (op_index + op_advance) % max_ops_per_instr;\
       }
 
       if (max_ops_per_instr == 0)
diff --git a/src/strip.c b/src/strip.c
index 7a5d4e4c..f10775d0 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -46,6 +46,10 @@
 #include <system.h>
 #include <printversion.h>
 
+#ifndef FNM_EXTMATCH
+# define FNM_EXTMATCH	(1 << 5)	/* Use ksh-like extended matching. */
+#endif
+
 typedef uint8_t GElf_Byte;
 
 /* Name and version of program.  */

Apply above patch before autoreconf step, then the magic appears.

Unable to build GCC with Clang (LLVM)

While in chroot, building GCC to install in /opt/gnu with clang fails. GMP, MPC, MPFR, and Binutils are installed in /opt/gnu.

make[1]: Entering directory '/sources/gcc-10.2.1_pre2/build'
make[2]: Entering directory '/sources/gcc-10.2.1_pre2/build/libiberty'
rm -f ./libiberty.a pic/./libiberty.a noasan/./libiberty.a
/opt/gnu/bin/as rc ./libiberty.a \
  ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o ./alloca.o ./argv.o ./choose-temp.o ./concat.o ./cp-demint.o ./crc32.o ./d-demangle.o ./dwarfnames.o ./dyn-string.o ./fdmatch.o ./fibheap.o ./filedescriptor.o ./filename_cmp.o ./floatformat.o ./fnmatch.o ./fopen_unlocked.o ./getopt.o ./getopt1.o ./getpwd.o ./getruntime.o ./hashtab.o ./hex.o ./lbasename.o ./lrealpath.o ./make-relative-prefix.o ./make-temp-file.o ./objalloc.o ./obstack.o ./partition.o ./pexecute.o ./physmem.o ./pex-common.o ./pex-one.o ./pex-unix.o ./vprintf-support.o ./rust-demangle.o ./safe-ctype.o ./simple-object.o ./simple-object-coff.o ./simple-object-elf.o ./simple-object-mach-o.o ./simple-object-xcoff.o ./sort.o ./spaces.o ./splay-tree.o ./stack-limit.o ./strerror.o ./strsignal.o ./timeval-utils.o ./unlink-if-ordinary.o ./xasprintf.o ./xatexit.o ./xexit.o ./xmalloc.o ./xmemdup.o ./xstrdup.o ./xstrerror.o ./xstrndup.o ./xvasprintf.o  ./sigsetmask.o ./setproctitle.o
Assembler messages:
Error: can't open rc for reading: No such file or directory
rc: Error: can't open ./libiberty.a for reading: No such file or directory
./regex.o:1: Error: junk at end of line, first unrecognized character valued 0x7f

and ends with:

./setproctitle.o:4: Error: junk at end of line, first unrecognized character valued 0x8
./setproctitle.o:4: Error: junk at end of line, first unrecognized character valued 0x18
make[2]: *** [Makefile:252: libiberty.a] Error 1
make[2]: Leaving directory '/sources/gcc-10.2.1_pre2/build/libiberty'
make[1]: *** [Makefile:8362: all-libiberty] Error 2
make[1]: Leaving directory '/sources/gcc-10.2.1_pre2/build'
make: *** [Makefile:963: all] Error 2

Stage1 Clang uses GCC

While in chroot and building the final system, I noticed stage1 clang uses GCC:

llvmtools 3.0.0 clang version 15.0.5
Target: x86_64-pc-linux-musl
Thread model: posix
InstalledDir: /llvmtools/bin
Configuration file: /llvmtools/bin/x86_64-pc-linux-musl.cfg
Found candidate GCC installation: /llvmtools/bin/../lib/gcc/x86_64-pc-linux-musl/12.2.0
Selected GCC installation: /llvmtools/bin/../lib/gcc/x86_64-pc-linux-musl/12.2.0

I only built GCC as a backup if a package is hard coded to compile with GCC only.
I have not completely built the final system, so I do not know what specific packages need GCC.

Minor bugs & mistakes

Let's put in this issue that bugs like misplacing in configure scripts, misplacing of files, patches, etc. In general, everything of that should be fixed by maintainer not in first turn and you can fix it temporarly by yourselves. But in the end it must be fixed.

  1. 3-chroot/34-flex. In configure script HELPMAN equals to /tools/bin/true, but in CMLFS we don't use it. HELPMAN should be equal to /llvmtools/bin/true.

llvmtools/01-kernel-headers fails to build in glibc environment

That's may be the stupidiest bug, but who cares. When I try to make kernel headers via executing

ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ make headers

this command fails with following error:

HOSTCC  scripts/basic/fixdep
/bin/sh: line 1: scripts/basic/fixdep: No such file or directory
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127
make[1]: *** Deleting file 'scripts/basic/fixdep'
make: *** [Makefile:536: scripts_basic] Error 2

This error doesn't appear in MLFS environment that's why I suggested to make minimal MLFS environment and then build CMLFS entirely.
How this bug could be fixed without creating of MLFS?

CMLFS/1-cgnutools/3-GCC-static => Configure error while executing "make all-gcc all-target-libgcc -j4"

Here is my config.log that the make program told me to take a look at details.
http://0x0.st/oTbw.log

checking for x86_64-meth-linux-musl-gcc...  /mnt/cmlfs/sources/pkgs/gcc-10.3.1_git20210424/build/./gcc/xgcc -B/mnt/cmlfs/sources/pkgs/gcc-10.3.1_git20210424/build/./gcc/ -B/cgnutools/x86_64-meth-linux-musl/bin/ -B/cgnutools/x86_64-meth-linux-musl/lib/ -isystem /cgnutools/x86_64-meth-linux-musl/include -isystem /cgnutools/x86_64-meth-linux-musl/sys-include   
checking for suffix of object files... configure: error: in `/mnt/cmlfs/sources/pkgs/gcc-10.3.1_git20210424/build/x86_64-meth-linux-musl/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details
make: *** [Makefile:12848: configure-target-libgcc] Error 1

This part causes the problem.

Perl 5.36.0 + perl-cross-1.4: Fails to build for llvmtools

Perl wil not cross compile after copying perl-cross over it:

make[1]: Leaving directory '/mnt/cmlfs/sources/perl-5.36.0'
make dynaloader
make[1]: Entering directory '/mnt/cmlfs/sources/perl-5.36.0'
sh cflags.SH
cflags.SH: Adding -Werror=pointer-arith.
cflags.SH: Adding -Werror=vla.
cflags.SH: Adding -Wextra.
cflags.SH: Adding -Wno-long-long.
cflags.SH: Adding -Wno-declaration-after-statement.
cflags.SH: Adding -Wc++-compat.
cflags.SH: Adding -Wwrite-strings.
cflags.SH: cc       = x86_64-pc-linux-musl-clang
cflags.SH: ccflags  = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
cflags.SH: stdflags = 
cflags.SH: optimize = 
cflags.SH: warn     =  -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings
Extracting cflags (with variable substitutions)
./miniperl_top make_patchnum.pl
make[1]: *** [Makefile:204: lib/Config_git.pl] Segmentation fault
make[1]: Leaving directory '/mnt/cmlfs/sources/perl-5.36.0'
make: *** [Makefile:81: all] Error 2

What is the operating system you're using to cross-compile CMLFS?

I'm thinking of trying to compile CMLFS here to actually try to find errors and actually try to help in something on the project, but i'm in doubt about how to build it correctly.
What is the host you're using? I'm currently using Devuan Beowulf (equivalent to Debian 10).

I think things like this are worth to be put in a documentation-- or better, an index containing tested/compatible hosts for cross-compiling it.

Cannot build libc++ with Localization

When building LLVM of cgnutools, libc++ will not compile if localization is enabled:

-DLIBCXX_ENABLE_LOCALIZATION=ON

If turned on, build fails:

In file included from /mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__locale:44:
/mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__support/musl/xlocale.h:28:68: error: 'abi_tag' attribute applied to extern "C" declaration 'long long int strtoll_l(const char*, char**, int, locale_t)'
   28 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
      |                                                                    ^
/mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__support/musl/xlocale.h:33:69: error: 'abi_tag' attribute applied to extern "C" declaration 'long long unsigned int strtoull_l(const char*, char**, int, locale_t)'
   33 | strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
      |                                                                     ^
/mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__support/musl/xlocale.h:38:74: error: 'abi_tag' attribute applied to extern "C" declaration 'long long int wcstoll_l(const wchar_t*, wchar_t**, int, locale_t)'
   38 | wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
      |                                                                          ^
/mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__support/musl/xlocale.h:43:75: error: 'abi_tag' attribute applied to extern "C" declaration 'long long int wcstoull_l(const wchar_t*, wchar_t**, int, locale_t)'
   43 | wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
      |                                                                           ^
/mnt/cmlfs/sources/llvm-rl/build/include/c++/v1/__support/musl/xlocale.h:48:62: error: 'abi_tag' attribute applied to extern "C" declaration 'long double wcstold_l(const wchar_t*, wchar_t**, locale_t)'
   48 | wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
      |                                                              ^
ninja: build stopped: subcommand failed.

Even with patch from Alpine Linux, issue persists.

Grub 2.06 fails to install boot loader

Grub builds fine under chroot. When it is time to use grub-install to install grub as boot loader, install fails as diskboot.img is too large at 129Mb. Correct size is 512 Kb.

Replacing image (with correct size) from an older build, install progresses but fails again with boot.img too large at 535 Kb instead of 512 Kb.

Replace boot.img from an older build (with correct size) and now install succeeds.

Build More of llvmtools under choot

Just like LFS 10+, build a very minimal llvmtools with cgnutools and build the rest of llvmtools under chroot.

Hopefully, this will drop the need for perl-cross, as it seems perl > 5.32.1 will not cross compile

perl fails to build with zlib-ng

Looks like zlib-ng (with zlib-compat) isn't compatible with perl?

Perl fails to build:

In file included from Zlib.xs:34:
/usr/include/zlib.h:1781:31: error: unknown type name 'gzFile'
Z_EXTERN int Z_EXPORT gzgetc_(gzFile file);  /* backward compatibility */
                              ^
/usr/include/zlib.h:1818:13: error: unknown type name 'gzFile'
   Z_EXTERN gzFile Z_EXPORT gzopen(const char *, const char *);
            ^
/usr/include/zlib.h:1819:45: error: unexpected type name 'off_t': expected identifier
   Z_EXTERN z_off_t Z_EXPORT gzseek(gzFile, z_off_t, int);
                                            ^
/usr/include/zconf.h:159:21: note: expanded from macro 'z_off_t'
#    define z_off_t off_t
                    ^
In file included from Zlib.xs:34:
/usr/include/zlib.h:1819:54: error: expected identifier
   Z_EXTERN z_off_t Z_EXPORT gzseek(gzFile, z_off_t, int);
                                                     ^
/usr/include/zlib.h:1820:37: error: a parameter list without types is only allowed in a function definition
   Z_EXTERN z_off_t Z_EXPORT gztell(gzFile); 
                                    ^
/usr/include/zlib.h:1821:39: error: a parameter list without types is only allowed in a function definition
   Z_EXTERN z_off_t Z_EXPORT gzoffset(gzFile);   
                                      ^
/usr/include/zlib.h:1840:35: error: unknown type name 'gzFile'
Z_EXTERN int Z_EXPORTVA gzvprintf(gzFile file, const char *format, va_list va);
                                  ^
In file included from Zlib.xs:743:
./constants.h:370:18: warning: incompatible pointer to integer conversion assigning to 'IV' (aka 'long') from 'void *' [-Wint-conversion]
      *iv_return = Z_NULL;
                 ^ ~~~~~~

Alternate Packages

And maybe pigz instead of gzip, but pigz requires zlib (zlib-ng works too). Cons: pigz doesn't have wrapper script such as for grep (zgrep). Can be installed for both, gzip just for wrapper script if needed 😄 lol

Originally posted by @owl4ce in #14 (comment)

TableGen fails to Compile

Tablegen fails to compile:

FAILED: utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o 
/cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/cmlfs/sources/llvm-project-15.0.5.src/build/utils/TableGen -I/mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/utils/TableGen -I/mnt/cmlfs/sources/llvm-project-15.0.5.src/build/include -I/mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/include -nostdinc++ -nodefaultlibs -isystem /cgnutools/include/c++/v1 -L/cgnutools/lib -Wl,-rpath,/cgnutools/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc  -g -g1 -Wl,--as-needed -lexecinfo -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++14 -MD -MT utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o -MF utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o.d -o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o -c /mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/utils/TableGen/CodeGenSchedule.cpp
In file included from /cgnutools/include/c++/v1/__functional/invoke.h:17,
                 from /cgnutools/include/c++/v1/type_traits:421,
                 from /cgnutools/include/c++/v1/limits:107,
                 from /cgnutools/include/c++/v1/math.h:309,
                 from /cgnutools/include/c++/v1/cmath:309,
                 from /mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/include/llvm/Support/MathExtras.h:19,
                 from /mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/include/llvm/ADT/APInt.h:19,
                 from /mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/utils/TableGen/CodeGenSchedule.h:17,
                 from /mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/utils/TableGen/CodeGenSchedule.cpp:14:
/cgnutools/include/c++/v1/__type_traits/decay.h: In instantiation of 'struct std::__1::__decay<const llvm::APInt&, true>':
/cgnutools/include/c++/v1/__type_traits/decay.h:56:89:   required from 'struct std::__1::decay<const llvm::APInt&&>'
/cgnutools/include/c++/v1/__utility/pair.h:132:16:   required by substitution of 'template<class _Tuple, typename std::__1::enable_if<typename std::__1::conditional<(std::__1::__tuple_like_with_size<_Tuple, 2, typename std::__1::remove_cv<typename std::__1::remove_reference<_Tp>::type>::type>::value && (! std::__1::is_same<typename std::__1::decay<_Tp>::type, std::__1::pair<const llvm::Record*, llvm::OpcodeInfo> >::value)), std::__1::pair<const llvm::Record*, llvm::OpcodeInfo>::_CheckTupleLikeConstructor, std::__1::__check_tuple_constructor_fail>::type::__enable_implicit<_Tuple>(), void>::type* <anonymous> > constexpr std::__1::pair<const llvm::Record*, llvm::OpcodeInfo>::pair(_Tuple&&) [with _Tuple = const llvm::APInt&&; typename std::__1::enable_if<typename std::__1::conditional<(std::__1::__tuple_like_with_size<_Tuple, 2, typename std::__1::remove_cv<typename std::__1::remove_reference<_Tp>::type>::type>::value && (! std::__1::is_same<typename std::__1::decay<_Tp>::type, std::__1::pair<const llvm::Record*, llvm::OpcodeInfo> >::value)), std::__1::pair<const llvm::Record*, llvm::OpcodeInfo>::_CheckTupleLikeConstructor, std::__1::__check_tuple_constructor_fail>::type::__enable_implicit<_Tuple>(), void>::type* <anonymous> = <missing>]'
/mnt/cmlfs/sources/llvm-project-15.0.5.src/llvm/utils/TableGen/CodeGenSchedule.cpp:372:69:   required from here
/cgnutools/include/c++/v1/__type_traits/decay.h:47:30: error: forming pointer to reference type 'std::__1::remove_extent<const llvm::APInt&>::type' {aka 'const llvm::APInt&'}
   47 |                      >::type type;
      |                              ^~~~
ninja: build stopped: subcommand failed.

This will cause lld, 'clang', and `libclang' to fail to compile (dependency)

Missing lvm-c headers

When building mesa, build fails due to missing llvm-c headers:

In file included from ../src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c:44:
../src/amd/llvm/ac_llvm_util.h:31:10: fatal error: 'llvm-c/TargetMachine.h' file not found
#include <llvm-c/TargetMachine.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

If I check that directory on the system:

/usr/include/llvm-c
├── Remarks.h
└── lto.h

... and compare it to the LLVM built in MLFS:

usr/
└── include
    └── llvm-c
        ├── Analysis.h
        ├── BitReader.h
        ├── BitWriter.h
        ├── Comdat.h
        ├── Core.h
        ├── DataTypes.h
        ├── DebugInfo.h
        ├── Disassembler.h
        ├── DisassemblerTypes.h
        ├── Error.h
        ├── ErrorHandling.h
        ├── ExecutionEngine.h
        ├── ExternC.h
        ├── IRReader.h
        ├── Initialization.h
        ├── LinkTimeOptimizer.h
        ├── Linker.h
        ├── Object.h
        ├── Orc.h
        ├── OrcBindings.h
        ├── Remarks.h
        ├── Support.h
        ├── Target.h
        ├── TargetMachine.h
        ├── Transforms
        │   ├── AggressiveInstCombine.h
        │   ├── Coroutines.h
        │   ├── IPO.h
        │   ├── InstCombine.h
        │   ├── PassManagerBuilder.h
        │   ├── Scalar.h
        │   ├── Utils.h
        │   └── Vectorize.h
        ├── Types.h
        └── lto.h

Looks like when the system LLVM was built, some headers were not copied/generated. I will compare builds between CMLFS and BMLFS, as both should be identical (assuming both were compiled by the same patches and source)

Could we have a more "friendly" license in this?

As i've seen, this isn't licensed formally yet, so i was going to suggest that we use something like the z-lib license for plain-text documentation.
I think that a more copycenter license would help when linking/using content from here in something licensed under a liberal license, like a Wiki licensed under CC-BY, for example.

Sorry for any broken english, i'm still praticing it.

Stage2 clang: llvm-tblgen will not compile

Under chroot, LLD and clang will not compile because llvm-tblgen fails to compile:

[14/22] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenHwModes.cpp.o
In file included from /sources/llvm-project-15.0.5.src/llvm/utils/TableGen/DAGISelMatcherOpt.cpp:14:
/sources/llvm-project-15.0.5.src/llvm/utils/TableGen/CodeGenDAGPatterns.h:1046:23: error: expected expression
    return Operands[ON];
                      ^
1 error generated.

Possible Wrong Search Path for C Runtime objects

When Clang(llvm) is built under chroot and tested, LLD searches for the C Runtime objects in this directory:

ld.lld: /usr/bin/../lib/Scrt1.o
ld.lld: /usr/bin/../lib/crti.o
ld.lld: /usr/bin/../lib/crtn.o

Which resolves to /usr/lib/*crt[1in].o

Once GCC is built under chroot after or before LLVM, LLD now searches for C runtime objects in:

ld. lld: /usr/lib/gcc/x86_64-linux-musl/10.3.1/../../../Scrt1.o
ld.lld: /usr/lib/gcc/x86_64-linux-musl/10.3.1/../../../crti.o
ld.lld: /usr/lib/gcc/x86_64-linux-musl/10.3.1/../../../crtn.o

Which resolves to /usr/lib/*crt[1in].o

Why does the search path change (even though both paths point to the same directory)?

And, can it be set to just /usr/lib ?

Libexecinfo still required

LLVM of cgnutools still looks for headers for libexecinfo:

[ 15%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o
In file included from /mnt/cmlfs/sources/llvm/lib/Support/Unix/Unix.h:21,
                 from /mnt/cmlfs/sources/llvm/lib/Support/Unix/Signals.inc:35,
                 from /mnt/cmlfs/sources/llvm/lib/Support/Signals.cpp:225:
/mnt/cmlfs/sources/llvm/build/include/llvm/Config/config.h:25:26: fatal error: execinfo.h: No such 
file or directory
   25 | #define BACKTRACE_HEADER <execinfo.h>
      |                          ^
compilation terminated.
make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/build.make:1882: lib/Support/CMakeFiles/LLVMSu
pport.dir/Signals.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:6560: lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/build'

even though i have it turned off:

export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF "

Stage 3-chroot/018-binutils - hanging in llvm mode

Stage 3-chroot/018-binutils
Issue: on configure stage, system hanging with huge load and memory leaks at stage:
checking whether compiler driver understands Ada...
It taken a hour, then I break process.
Tried to switch from ( set-llvm-mode && set-llvm-bin-mode ) --> ( set-gcc-mode && set-gnu-bin-mode )
Configuration stage completed pretty fast and OK
checking whether compiler driver understands Ada... no
But compilation failed with:

../../bfd/compress.c:22:10: fatal error: 'zlib.h' file not found

locate zlib.h(out of chroot)

/mnt/cmlfs/llvmtools/include/bzlib.h
/mnt/cmlfs/usr/include/zlib.h

llvmtools: 01-kernel-headers fails to compile using `LLVM=1`

Gives me an error:

  HOSTCC  scripts/basic/fixdep
/bin/sh: line 1: scripts/basic/fixdep: No such file or directory
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127
make[1]: *** Deleting file 'scripts/basic/fixdep'
make: *** [Makefile:535: scripts_basic] Error 2

Know issue: scripts/basic/fixdep.c failed to compile when using stage0 clang/llvm

Kmod fails to build with zlib-ng

checking for liblzma... yes
checking for zlib... no
configure: error: Package requirements (zlib) were not met:

Package 'zlib', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables zlib_CFLAGS
and zlib_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

llvmtools: Failed to build Cmake under Glibc #19

--
  |
  |
  |  
  |
  | <title>Dukungan Mozilla</title>
  |  
  |  
  |
  |
  |
  |
  |
  |
  |
  |  
  |  
  |
  |  
  |  
  |
  |  
  |  
  |  
  |  
  |
  |  
  |
  |  
  |
  |  
  |  
  |  
  |
  |  
  |  
  |
  |  
  |  
  |
  |  
  |
  |  
  |
  |  
  | <script type="text/javascript" src="https://static-media-prod-cdn.itsre-sumo.mozilla.net/static/build/gtm-snippet-min.98ca663fd559.js" charset="utf-8"></script>
  |  
  |
  |
  |  
  | <body class="html-ltr logged-out responsive id"
  | data-readonly="false"
  | data-usernames-api="/id/users/api/usernames"
  | data-static-url="https://static-media-prod-cdn.itsre-sumo.mozilla.net/static/"
  | data-media-url="https://user-media-prod-cdn.itsre-sumo.mozilla.net/"
  |  
  | >
  |  
  |  
  |  
  |


  |  
  |  
  |  
  |

  |  
  |

  |

  | <button class="mzp-c-notification-bar-button close-button" data-close-id="announce-geoip-suggestion" type="button"
  | data-close-memory="remember"
  | data-close-type="remove" >
  |
  |


  |

  |  
  |  
  |  
  |  
  |

  |  
  |
  |

  |

  |

  | Mozilla Support Logo
  |

  |  
  | Search
  | Menu
  |
  |  
  | Avatar for Username
  |  
  |  
  |
  |

  |

  |
  |  
  |
  |  
  |
  |

  |

  |  
  |

  |

  |
  |  
  |

      |  
      |  
      |

  •   |  
      | <form data-instant-search="form" id="support-search" action="/id/search" method="get"
      | class="simple-search-form">
      |  
      | <input spellcheck="true" type="search" autocomplete="off" name="q" aria-required="true"
      | placeholder="Find help..." class="searchbox" id="search-q" />
      | Cari
      |
      |  
      |  
      |  
      |  
      | <a href="https://www.mozilla.org/firefox/new/?utm_source=support.mozilla.org&amp;utm_medium=referral&amp;utm_campaign=non-fx-button&amp;utm_content=header-download-button"
      | class="firefox-download-button hidden sumo-button primary-button button-lg" data-event-category="Download Button"
      | data-event-action="Firefox for Desktop">Mozilla Firefox
      |  
      |

  •   |  
      |  
      | <li
      | class="mzp-c-menu-category logged-out-button-row ">
      |  
      | <a href="/id/users/auth" class="sumo-button secondary-button button-lg" data-event-category="navigation"
      | data-event-action="main navigation" data-event-label="Sign In">Sign In/Up
      |  
      |
      |  
      |

  |  
  |
  |

  |

  |

  |

  |
  |  
  | <form data-instant-search="form" id="mobile-search-results" action="/id/search" method="get"
  | class="simple-search-form">
  |  
  | <input spellcheck="true" type="search" autocomplete="off" name="q" aria-required="true"
  | placeholder="Find help..." class="searchbox" id="search-q" />
  | Cari
  |
  |  
  |
  |

  |

  |

  |

  |
  |  
  |  
  |  
  |  
  |  
  |

  |

  |

  |

Search Support


  |  
  | <form data-instant-search="form" id="support-search-masthead" action="/id/search" method="get"
  | class="simple-search-form">
  |  
  | <input spellcheck="true" type="search" autocomplete="off" name="q" aria-required="true"
  | placeholder="Find help..." class="searchbox" id="search-q" />
  | Cari
  |
  |  
  |  
  |


  | Popular Searches:
  | Firefox Accounts
  | VPN
  | Tracking Protection
  |


  |

  |

  |

  |  
  |  
  |  
  |  
  |  
  |

  |

  |

  |

Get Help


  |

Pick your product


  |

  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox
  |

  |


  |
  | Firefox
  |

  |


  |

Peramban web untuk Windows, Mac, dan Linux


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox untuk Android
  |

  |


  |
  | Firefox untuk Android
  |

  |


  |

Peramban web untuk ponsel dan tablet Android


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox untuk iOS
  |

  |


  |
  | Firefox untuk iOS
  |

  |


  |

Firefox untuk iPhone, iPad dan iPod touch


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox untuk Enterprise
  |

  |


  |
  | Firefox untuk Enterprise
  |

  |


  |

Firefox Quantum untuk bisnis


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox Lite
  |

  |


  |
  | Firefox Lite
  |

  |


  |

Mobile browser for Indonesia, India, The Philippines, and Thailand


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox Reality
  |

  |


  |
  | Firefox Reality
  |

  |


  |

Peramban web untuk headset realitas virtual


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Mozilla VPN
  |

  |


  |
  | Mozilla VPN
  |

  |


  |

VPN for Windows 10, Mac, Linux, Android, and iOS devices


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox Private Network
  |

  |


  |
  | Firefox Private Network
  |

  |


  |

Browse securely on public Wi-Fi using a Firefox add-on.


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox Lockwise
  |

  |


  |
  | Firefox Lockwise
  |

  |


  |

Mobile app that gives you access to passwords you've saved to Firefox.


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox ScreenshotGo
  |

  |


  |
  | Firefox ScreenshotGo
  |

  |


  |

Aplikasi cuplikan layar bergerak


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Hubs
  |

  |


  |
  | Hubs
  |

  |


  |

Virtual 3D meeting spaces for collaborating with friends, family, and colleagues on your browser or VR headset


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox untuk Peranti Amazon
  |

  |


  |
  | Firefox untuk Peranti Amazon
  |

  |


  |

Peramban untuk peranti Amazon


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Thunderbird
  |

  |


  |
  | Thunderbird
  |

  |


  |

Perangkat surel untuk Windows, Mac, dan Linux


  |

  |

  |  
  |

  |  
  |  
  |  
  |  
  | Firefox Focus
  |

  |


  |
  | Firefox Focus
  |

  |


  |

Peramban otomatis berprivasi dan pemblokir konten


  |

  |

  |  
  |

  |

  |

  |  
  |

  |

  |

Featured Articles


  |

  |  
  |

  |

  |  
  |

  | Pengaturan
  |

  |


  | <a class="expand-this-link" href="/id/kb/Pengaturan" data-event-category="link click" data-event-action="product"
  | data-event-label="#Pengaturan">Pengaturan
  |


  |


  | Panel Opsi/Preferensi memberikan Anda akses ke pengaturan Firefox. Artikel berikut menjabarkan tipe pengaturan seperti apa saja yang tersedia pada tiap panel.
  |


  |

  |

  |  
  |

  | Memperbarui Firefox
  |

  |


  | <a class="expand-this-link" href="/id/kb/update-firefox-latest-version" data-event-category="link click" data-event-action="product"
  | data-event-label="#Memperbarui Firefox">Memperbarui Firefox
  |


  |


  | Secara baku, Firefox akan diperbarui secara otomatis, namun bisa juga dilakukan secara manual. Pelajari cara melakukan pembaruan di Windows, Mac, atau Linux.
  |


  |

  |

  |  
  |

  | Peringatan Kata Sandi Tidak Aman di Firefox
  |

  |


  | <a class="expand-this-link" href="/id/kb/peringatan-kata-sandi-tidak-aman-di-firefox" data-event-category="link click" data-event-action="product"
  | data-event-label="#Peringatan Kata Sandi Tidak Aman di Firefox">Peringatan Kata Sandi Tidak Aman di Firefox
  |


  |


  | Firefox akan memberi peringatan ketika Anda masuk secara tidak aman dan jika ada kemungkinan informasi Anda dapat dicuri.
  |


  |

  |

  |  
  |

  | Koneksi aman gagal dan Firefox tidak tersambung
  |

  |


  | <a class="expand-this-link" href="/id/kb/koneksi-aman-gagal-dan-firefox-tidak-tersambung" data-event-category="link click" data-event-action="product"
  | data-event-label="#Koneksi aman gagal dan Firefox tidak tersambung">Koneksi aman gagal dan Firefox tidak tersambung
  |


  |


  | Jika situs web gagal membuat koneksi aman, Firefox tidak akan tersambung dan akan menampilkan pesan galat pada laman. Pelajari lebih lanjut.
  |


  |

  |

  |  
  |

  |

  |  
  |

  |  
  |

  |

  |

  | Illustration of community
  |

  |

Join Our Community


  |

Grow and share your expertise with others. Answer questions and improve our knowledge base.


  |

Learn More


  |

  |

  |

  |

  |

  |  
  |  
  |
  |

  |
  |

  |

  |
Mozilla

  |
  |

  |  
  |

  |
Firefox

  |
  |

  |  
  |

  |
Firefox for Developers

  |
  |

  |  
  |

  |
Firefox Accounts

  |
  |

  |  
  |

  |
  | Bahasa
  | Bahasa
  | <select id="mzp-c-language-switcher-select" class="mzp-js-language-switcher-select"
  | name="lang">
  |  
  | Afrikaans
  |  
  | عربي
  |  
  | Azərbaycanca
  |  
  | Български
  |  
  | Bamanankan
  |  
  | বাংলা
  |  
  | Bosanski
  |  
  | català
  |  
  | Čeština
  |  
  | Dansk
  |  
  | Deutsch
  |  
  | Èʋegbe
  |  
  | Ελληνικά
  |  
  | English
  |  
  | Español
  |  
  | eesti keel
  |  
  | Euskara
  |  
  | فارسی
  |  
  | suomi
  |  
  | Français
  |  
  | Frysk
  |  
  | Gaeilge (Éire)
  |  
  | Galego
  |  
  | Avañe'ẽ
  |  
  | ગુજરાતી
  |  
  | هَرْشَن هَوْسَ
  |  
  | עברית
  |  
  | हिन्दी (भारत)
  |  
  | Hrvatski
  |  
  | Magyar
  |  
  | Dolnoserbšćina
  |  
  | Hornjoserbsce
  |  
  | Bahasa Indonesia
  |  
  | Asụsụ Igbo
  |  
  | Italiano
  |  
  | 日本語
  |  
  | ქართული
  |  
  | ខ្មែរ
  |  
  | ಕನ್ನಡ
  |  
  | 한국어
  |  
  | Lingála
  |  
  | lietuvių kalba
  |  
  | Malagasy
  |  
  | Македонски
  |  
  | മലയാളം
  |  
  | Bahasa Melayu
  |  
  | नेपाली
  |  
  | Nederlands
  |  
  | Norsk
  |  
  | Polski
  |  
  | Português (do Brasil)
  |  
  | Português (Europeu)
  |  
  | română
  |  
  | Русский
  |  
  | සිංහල
  |  
  | slovenčina
  |  
  | slovenščina
  |  
  | Shqip
  |  
  | Српски
  |  
  | Kiswahili
  |  
  | Svenska
  |  
  | தமிழ்
  |  
  | தமிழ் (இலங்கை)
  |  
  | తెలుగు
  |  
  | ไทย
  |  
  | Setswana
  |  
  | Türkçe
  |  
  | Українська
  |  
  | اُردو
  |  
  | Tiếng Việt
  |  
  | Wolof
  |  
  | isiXhosa
  |  
  | èdè Yorùbá
  |  
  | 中文 (简体)
  |  
  | 正體中文 (繁體)
  |  
  | isiZulu
  |  
  |
  |
  | Cari
  |
  |
  |

  |  
  |

  |
  |  
  |
  |

  |
  |

  |
  |

  |

  |

  |


  | Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
  |


  |


  | Portions of this content are ©1998–2021 by individual mozilla.org contributors. Content available under a Creative Commons license.
  |


  |

  |
  |

  |
  |  
  |  
  | <script src="https://static-media-prod-cdn.itsre-sumo.mozilla.net/static/jsi18n/id/djangojs-min.cec784ebd855.js"></script>
  |  
  |  
  |  
  | <script type="text/javascript" src="https://static-media-prod-cdn.itsre-sumo.mozilla.net/static/build/common-min.ac530427a7b9.js" charset="utf-8"></script>
  |  
  |  
  | <script type="text/javascript" src="https://static-media-prod-cdn.itsre-sumo.mozilla.net/static/build/show-fx-download.4fef4fded9ba.js" charset="utf-8"></script>
  |  
  |  
  |  
  |  
  |  
  |  
  |

![t](https://user-images.githubusercontent.com/58392246/125586113-e805feba-ab85-4eef-a99f-1ae2363c8f7e.jpg)

LLVM11: llvmtools: LLVM fails to build llvm-tblgen

Re-built llvmtools and made sure libcxx did not require libatomic.

now llvm/clang for llvmtools fails to build:

FAILED: include/llvm/IR/Attributes.inc 
cd /mnt/cmlfs/sources/llvm/build && /mnt/cmlfs/sources/llvm/build/bin/llvm-tblgen -gen-attrs -I /mnt/cmlfs/sources/llvm/include/llvm/IR -I /mnt/cmlfs/sources/llvm/build/include -I /mnt/cmlfs/sources/llvm/include /mnt/cmlfs/sources/llvm/include/llvm/IR/Attributes.td --write-if-changed -o include/llvm/IR/Attributes.inc -d include/llvm/IR/Attributes.inc.d
/bin/sh: /mnt/cmlfs/sources/llvm/build/bin/llvm-tblgen: No such file or directory
[220/3316] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackDocument.cpp.o
ninja: build stopped: subcommand failed.

Originally posted by @dslm4515 in #12 (comment)

llvm compilation error.

llvm compilation error. All steps are made in accordance with the instructions. At the stage CMLFS / 1-cgnutools / 7-clang gives an error.

[ 17%] Building CXX object utils/not/CMakeFiles/not.dir/not.cpp.o
[ 17%] Built target LLVMBitstreamReader
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/Minidump.cpp.o
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackDocument.cpp.o
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackDocumentYAML.cpp.o
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackReader.cpp.o
[ 17%] Linking CXX executable ../../bin/not
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: warning: libc.so.6, needed by /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1, not found (try using -rpath or -rpath-link)
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to __stack_chk_fail@GLIBC_2.4' /mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to strlen@GLIBC_2.2.5'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to dladdr@GLIBC_2.34' /mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to free@GLIBC_2.2.5'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to realloc@GLIBC_2.2.5' /mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to malloc@GLIBC_2.2.5'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to snprintf@GLIBC_2.2.5' /mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/10.3.1/../../../../x86_64-cmlfs-linux-musl/bin/ld: /mnt/cmlfs/cgnutools/bin/../../cgnutools/lib/libexecinfo.so.1: undefined reference to write@GLIBC_2.2.5'
collect2: error: ld returned 1 exit status
make[2]: *** [utils/not/CMakeFiles/not.dir/build.make:98: bin/not] Error 1
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:13073: utils/not/CMakeFiles/not.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/MsgPackWriter.cpp.o
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/Wasm.cpp.o
[ 17%] Building CXX object lib/BinaryFormat/CMakeFiles/LLVMBinaryFormat.dir/XCOFF.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/Record.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/SetTheory.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/StringMatcher.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackend.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.cpp.o
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGLexer.cpp.o
[ 17%] Linking CXX shared library ../libLLVMOption.so
[ 17%] Linking CXX shared library ../libLLVMBinaryFormat.so
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[ 17%] Built target LLVMOption
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[ 17%] Built target LLVMBinaryFormat
[ 17%] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o
[ 17%] Linking CXX shared library ../libLLVMFileCheck.so
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[ 17%] Built target LLVMFileCheck
[ 17%] Linking CXX shared library ../libLLVMTableGen.so
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
[ 17%] Built target LLVMTableGen
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/build'

LLVM12 - llvmtools build breaks as libcxx

Building llvmtools with llvm-12.0.0 on a glibc host .... Build fails.

[ 70%] Building CXX object src/CMakeFiles/cxx_shared.dir/charconv.cpp.o                  [139/1822]
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:                  
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:    /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace; did you mean '__signbit'?
using ::signbit;
      ~~^~~~~~~
        __signbit
/llvmtools/include/math.h:93:5: note: '__signbit' declared here
int __signbit(double);
    ^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
using ::fpclassify;
      ~~^~~~~~~~~~
        __fpclassify
/llvmtools/include/math.h:51:5: note: '__fpclassify' declared here
int __fpclassify(double);
    ^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^~~~~~~~
        finite
/llvmtools/include/math.h:401:13: note: 'finite' declared here
int         finite(double);
            ^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:324:9: error: no membe[106/1822]sinf' in the global namespace
using ::isinf;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:327:9: error: no member named 'isgreater' in the global namespace; did you mean '__isgreater'?
using ::isgreater;
      ~~^~~~~~~~~
        __isgreater
/llvmtools/include/math.h:118:1: note: '__isgreater' declared here
__ISREL_DEF(greater, >, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:59:1: note: expanded from here
__isgreater
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:328:9: error: no member named 'isgreaterequal' in the global namespace; did you mean '__isgreaterequal'?
using ::isgreaterequal;
      ~~^~~~~~~~~~~~~~
        __isgreaterequal 
/llvmtools/include/math.h:121:1: note: '__isgreaterequal' declared here
__ISREL_DEF(greaterequal, >=, double_t)                                                   [72/1822]
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:62:1: note: expanded from here
__isgreaterequal
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace; did you mean '__isless'?
using ::isless;
      ~~^~~~~~
        __isless
/llvmtools/include/math.h:109:1: note: '__isless' declared here
__ISREL_DEF(less, <, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:50:1: note: expanded from here
__isless
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace; did you mean '__islessequal'?
using ::islessequal;
      ~~^~~~~~~~~~~
        __islessequal
/llvmtools/include/math.h:112:1: note: '__islessequal' declared here
__ISREL_DEF(lessequal, <=, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'                 [38/1822]
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:53:1: note: expanded from here
__islessequal
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace; did you mean '__islessgreater'?
using ::islessgreater;
      ~~^~~~~~~~~~~~~
        __islessgreater
/llvmtools/include/math.h:115:1: note: '__islessgreater' declared here
__ISREL_DEF(lessgreater, !=, double_t)
^
/llvmtools/include/math.h:105:21: note: expanded from macro '__ISREL_DEF'
static __inline int __is##rel(type __x, type __y) \
                    ^
<scratch space>:56:1: note: expanded from here
__islessgreater
^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:339:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'? 
using ::abs;                                                                               [4/1822]
      ~~^~~
        fabs
/llvmtools/include/math.h:203:13: note: 'fabs' declared here
double      fabs(double);
            ^
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/src/charconv.cpp:9:
In file included from /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/charconv:79:
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:644:26: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                         ^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:644:60: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                           ^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:645:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:645:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1/cmath:650:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/CMakeFiles/cxx_shared.dir/build.make:128: src/CMakeFiles/cxx_shared.dir/charconv.cpp.o] Error 1
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'
make[1]: *** [CMakeFiles/Makefile2:533: src/CMakeFiles/cxx_shared.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'
make: *** [Makefile:130: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/projects/libcxx/build'

Kernel 5.13 will not compile under Musl

Build fails due to 20 errors. This is the 2nd kernel version with bad typos in the source.

  CC      /sources/linux-5.13/tools/objtool/arch/x86/decode.o                                                                         [136/1913]
In file included from arch/x86/decode.c:10:                                                                                                     
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:10:                     
In file included from /usr/include/asm/byteorder.h:5:
In file included from /usr/include/linux/byteorder/little_endian.h:13:  
/usr/include/linux/swab.h:136:8: error: unknown type name '__always_inline'                                                                     
static __always_inline unsigned long __swab(const unsigned long y)                                                                              
       ^                                                                                                                                        
/usr/include/linux/swab.h:171:8: error: unknown type name '__always_inline'
static __always_inline __u16 __swab16p(const __u16 *p) 
       ^                                                                                                                                        
/usr/include/linux/swab.h:171:29: error: expected ';' after top level declarator                    
static __always_inline __u16 __swab16p(const __u16 *p)
                            ^                                           
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:97:8: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode);
       ^~~~~~~~~~~
       insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:99:8: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode,
       ^~~~~~~~~~~
       insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:101:11: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
                                             insn_attr_t esc_attr);
                                             ^~~~~~~~~~~
                                             insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
  MKELF   scripts/mod/elfconfig.h
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:102:8: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm,
       ^~~~~~~~~~~
       insn_byte_t
       ^~~~~~~~~~~                                                                                                                     [90/1913]
       insn_byte_t                                                                                                                              
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;                                      
                      ^                                                 
In file included from arch/x86/decode.c:10:                                                                                                     
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:                                                                 
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:104:10: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?               
                                            insn_attr_t esc_attr);                                                                              
                                            ^~~~~~~~~~~
                                            insn_byte_t                                                                                         
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;                                      
                      ^                                                 
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:105:8: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode,    
       ^~~~~~~~~~~
       insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:110:41: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_legacy_prefix(insn_attr_t attr)       
                                        ^~~~~~~~~~~
                                        insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:116:47: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_address_size_prefix(insn_attr_t attr)    
                                              ^~~~~~~~~~~
                                              insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
  HOSTCC  scripts/mod/modpost.o  
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:121:47: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_operand_size_prefix(insn_attr_t attr)
                                              ^~~~~~~~~~~
                                              insn_byte_t
                                              ^~~~~~~~~~~                                                                              [44/1913]
                                              insn_byte_t                                                                                       
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;                                      
                      ^                                                 
In file included from arch/x86/decode.c:10:                                                                                                     
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:                                                                 
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:126:38: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?               
static inline int inat_is_rex_prefix(insn_attr_t attr)                                                                                          
                                     ^~~~~~~~~~~       
                                     insn_byte_t                                                                                                
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;                                      
                      ^                                                 
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:131:39: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_last_prefix_id(insn_attr_t attr)          
                                      ^~~~~~~~~~~
                                      insn_byte_t
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:139:38: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_vex_prefix(insn_attr_t attr)          
                                     ^~~~~~~~~~~   
                                     insn_byte_t   
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:146:39: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_evex_prefix(insn_attr_t attr)            
                                      ^~~~~~~~~~~        
                                      insn_byte_t        
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
typedef unsigned char insn_byte_t;
                      ^
In file included from arch/x86/decode.c:10:
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:151:39: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_is_vex3_prefix(insn_attr_t attr)                                                                                         
                                      ^~~~~~~~~~~              
                                      insn_byte_t        
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here
static inline int inat_is_vex3_prefix(insn_attr_t attr)                                                                                 [0/1913]
                                      ^~~~~~~~~~~                                                                                               
                                      insn_byte_t                                                                                               /sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here                                            typedef unsigned char insn_byte_t;                                                                                                              
                      ^                                                                                                                         
In file included from arch/x86/decode.c:10:                                                                                                     
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:                                                                 /sources/linux-5.13/tools/arch/x86/include/asm/inat.h:156:34: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?               
static inline int inat_is_escape(insn_attr_t attr)                                                                                              
                                 ^~~~~~~~~~~                                                                                                    
                                 insn_byte_t                                                                                                    /sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here                                            typedef unsigned char insn_byte_t;                                                                                                              
                      ^                                                                                                                         
In file included from arch/x86/decode.c:10:                                                                                                     
In file included from /sources/linux-5.13/tools/arch/x86/include/asm/insn.h:12:                     
/sources/linux-5.13/tools/arch/x86/include/asm/inat.h:161:34: error: unknown type name 'insn_attr_t'; did you mean 'insn_byte_t'?
static inline int inat_escape_id(insn_attr_t attr)                                                                                              
                                 ^~~~~~~~~~~                                                                                                    
                                 insn_byte_t                                                                                                    
/sources/linux-5.13/tools/arch/x86/include/asm/inat_types.h:12:23: note: 'insn_byte_t' declared here                                            
typedef unsigned char insn_byte_t;                                      
                      ^                                                                                                                         
fatal error: too many errors emitted, stopping now [-ferror-limit=]                                                                             
20 errors generated.                                                                                                                            
make[4]: *** [/sources/linux-5.13/tools/build/Makefile.build:97: /sources/linux-5.13/tools/objtool/arch/x86/decode.o] Error 1
make[3]: *** [/sources/linux-5.13/tools/build/Makefile.build:139: arch/x86] Error 2
make[2]: *** [Makefile:56: /sources/linux-5.13/tools/objtool/objtool-in.o] Error 2                                                              
make[1]: *** [Makefile:69: objtool] Error 2                                                                                                     
make: *** [Makefile:1974: tools/objtool] Error 2                                                                                                
make: *** Waiting for unfinished jobs....         

LLVM 13.0 doesn't seem to work (cgnutools/7-clang)

Every other instruction before this command runs without any errors.

$ cmake -B build -DCMAKE_EXE_LINKER_FLAGS="${LINKERFLAGS}" -DCMAKE_SHARED_LINKER_FLAGS="${LINKERFLAGS}" ${CONFIG_TOOLS} ${CONFIG_TRUPLES} ${CONFIG_CRT} ${CONFIG_CLANG} ${CONFIG_OPTIONS} ${CONFIG_LIBUNWIND} ${CONFIG_LIBCXXABI} ${CONFIG_LIBCXX} ${CONFIG_PATHS} ${BUILD_OFF}

CMake Warning at cmake/modules/HandleLLVMStdlib.cmake:28 (message):
  Can't specify libc++ with '-stdlib='
Call Stack (most recent call first):
  cmake/config-ix.cmake:15 (include)
  CMakeLists.txt:684 (include)


-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Go bindings enabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-pc-linux-musl
-- LLVM default target triple: x86_64-pc-linux-musl
-- Building with -fPIC
-- Targeting X86
-- Could not find ParallelSTL, libc++abi will not attempt to use it but the build may fail if the libc++ in use needs it to be available.
-- Looking for cxxabi.h in /mnt/cmlfs/sources/llvm/projects/libcxx/../libcxxabi/include
-- Looking for cxxabi.h in /mnt/cmlfs/sources/llvm/projects/libcxx/../libcxxabi/include - found
-- Looking for __cxxabi_config.h in /mnt/cmlfs/sources/llvm/projects/libcxx/../libcxxabi/include
-- Looking for __cxxabi_config.h in /mnt/cmlfs/sources/llvm/projects/libcxx/../libcxxabi/include - found
-- Compiler-RT supported architectures: x86_64
-- Builtin supported architectures: x86_64
-- For x86_64 builtins preferring i386/fp_mode.c to fp_mode.c
-- For x86_64 builtins preferring x86_64/floatdidf.c to floatdidf.c
-- For x86_64 builtins preferring x86_64/floatdisf.c to floatdisf.c
-- For x86_64 builtins preferring x86_64/floatundidf.S to floatundidf.c
-- For x86_64 builtins preferring x86_64/floatundisf.S to floatundisf.c
-- For x86_64 builtins preferring x86_64/floatdixf.c to floatdixf.c
-- For x86_64 builtins preferring x86_64/floatundixf.S to floatundixf.c
CMake Error at projects/compiler-rt/cmake/Modules/AddCompilerRT.cmake:259 (message):
  Cannot find builtins library for the target architecture
Call Stack (most recent call first):
  projects/compiler-rt/lib/orc/CMakeLists.txt:93 (add_compiler_rt_runtime)

LLVM11 - libcxx fails to build, linux/futex.h not found

[ 2-llvmtools >> 04-libcxx ]
Building libcxx under llvm source fails to build:

[187/264] Building CXX object src/CMakeFiles/cxx_static.dir/atomic.cpp.o
FAILED: src/CMakeFiles/cxx_static.dir/atomic.cpp.o 
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang++  -DNDEBUG -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_N
O_PRAGMA_SYSTEM_HEADER -D_LIBCPP_LINK_PTHREAD_LIB -D_LIBCPP_LINK_RT_LIB -Iinclude/c++build -DLIBCXX
_BUILDING_LIBCXXABI -nostdinc++ -fvisibility-inlines-hidden -fvisibility=hidden -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wno-user-defined-literals -Wno-covered-switch-default -Wno-ignored-attributes -Wno-error -I /mnt/cmlfs/sources/llvm/projects/libcxx/build/include/c++/v1 -include /mnt/cmlfs/sources/llvm/projects/libcxx/build/__config_site -std=c++14 -MD -MT src/CMakeFiles/cxx_static.dir/atomic.cpp.o -MF src/CMakeFiles/cxx_static.dir/atomic.cpp.o.d -o src/CMakeFiles/cxx_static.dir/atomic.cpp.o -c ../src/atomic.cpp
../src/atomic.cpp:21:10: fatal error: 'linux/futex.h' file not found
#include <linux/futex.h>
         ^~~~~~~~~~~~~~~
1 error generated.
[188/264] Building CXX object src/CMakeFiles/cxx_static.dir/barrier.cpp.o
ninja: build stopped: subcommand failed.

Same error if built with make instead of ninja

lib & bin Merge

Need to update root file system tree to have:

  • /bin -> /usr/bin
  • /sbin -> /usr/sbin
  • /lib -> /usr/lib

cgnutools/08-clang: symbol not found

2021-09-24-124658_719x292_scrot
I got this.

This is the command line i used to configure cmake.
In fact, it's the same from the documentation.

LDFLAGS="-Wl,-rpath,/cgnutools/lib" CFLAGS= -g -g1 CXXFLAGS=$CFLAGS CONFIG_TOOLS="-DCMAKE_C_COMPILER=${COPA_TARGET}-gcc " CONFIG_TOOLS+="-DCMAKE_CXX_COMPILER=${COPA_TARGET}-g++ " CONFIG_TOOLS+="-DCMAKE_EXE_LINKER_FLAGS=-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1 " CONFIG_TOOLS+="-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1 " CONFIG_TOOLS+="-DCLANG_DEFAULT_LINKER=/cgnutools/bin/ld.lld " CONFIG_TRUPLES="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " CONFIG_TRUPLES+="-DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl " CONFIG_TRUPLES+="-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=x86_64-pc-linux-musl " CONFIG_CRT="-DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON " CONFIG_CRT+="-DCOMPILER_RT_BUILD_SANITIZERS=OFF" CONFIG_CRT+="-DCOMPILER_RT_BUILD_XRAY=OFF " CONFIG_CRT+="-DCOMPILER_RT_BUILD_PROFILE=OFF " CONFIG_CRT+="-DCOMPILER_RT_BUILD_LIBFUZZER=OFF " CONFIG_CRT+="-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF " CONFIG_CRT+="-DCOMPILER_RT_HWASAN_WITH_INTERCEPTORS=OFF " CONFIG_CLANG="-DCLANG_DEFAULT_CXX_STDLIB=libc++ " CONFIG_CLANG+="-DCLANG_DEFAULT_UNWINDLIB=libunwind " CONFIG_CLANG+="-DCLANG_DEFAULT_RTLIB=compiler-rt " CONFIG_CLANG+="-DCLANG_ENABLE_STATIC_ANALYZER=OFF " CONFIG_CLANG+="-DCLANG_ENABLE_ARCMT=OFF " CONFIG_LIBUNWIND="-DLIBUNWIND_ENABLE_STATIC=OFF " CONFIG_LIBCXXABI="-DLIBCXXABI_ENABLE_STATIC=OFF " CONFIG_LIBCXX="-DLIBCXX_ENABLE_STATIC=OFF " CONFIG_PATHS="-DICONV_LIBRARY_PATH=/cgnutools/lib/libc.so " BUILD_OFF="-DLLVM_BUILD_TESTS=OFF " BUILD_OFF+="-DLLVM_INCLUDE_GO_TESTS=OFF " BUILD_OFF+="-DLLVM_INCLUDE_TESTS=OFF " BUILD_OFF+="-DLLVM_INCLUDE_DOCS=OFF " BUILD_OFF+="-DLLVM_INCLUDE_EXAMPLES=OFF " BUILD_OFF+="-DLLVM_INCLUDE_BENCHMARKS=OFF " BUILD_OFF+="-DLLVM_ENABLE_OCAMLDOC=OFF " BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF " BUILD_OFF+="-DLLVM_ENABLE_LIBEDIT=OFF " BUILD_OFF+="-DLLVM_ENABLE_LIBXML2=OFF " BUILD_OFF+="-DLLVM_ENABLE_LIBPFM=OFF " BUILD_OFF+="-DLLVM_ENABLE_TERMINFO=OFF " BUILD_OFF+="-DLLVM_ENABLE_ZLIB=OFF " BUILD_OFF+="-DLLVM_ENABLE_Z3_SOLVER=OFF " BUILD_OFF+="-DLLVM_APPEND_VC_REV=OFF " BUILD_OFF+="-DLLVM_ENABLE_CRASH_OVERRIDES=OFF " BUILD_OFF+="-DLIBCXX_INCLUDE_BENCHMARKS=OFF " BUILD_OFF+="-DLIBCXX_ENABLE_DEBUG_MODE_SUPPORT=OFF " cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/cgnutools" -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_LIBCXX=ON -DLLVM_TARGET_ARCH="X86" -DLLVM_TARGETS_TO_BUILD="X86" -DLIBCXX_HAS_MUSL_LIBC=ON -DDEFAULT_SYSROOT="/cgnutools" ${CONFIG_TOOLS} ${CONFIG_TRUPLES} ${CONFIG_CRT} ${CONFIG_CLANG} ${CONFIG_LIBUNWIND} ${CONFIG_LIBCXXABI} ${CONFIG_LIBCXX} ${CONFIG_PATHS} ${BUILD_OFF} && make -C build

My .bashrc:

# Directories
COPA='/dsk/0v'
GNUC_TOOLS='/cgnutools'
LLVM_TOOLS='/llvmtools'
LFS="${COPA}"
LLVM_SRC=/usr/tmp/llvm

# PATH
PATH="${GNUC_TOOLS}/bin:${LLVM_TOOLS}/bin:/bin:/usr/bin"

# Target
COPA_TARGET="`uname -m`-pindoramaCOPACABANA-linux-musl"
CMLFS_TARGET="${COPA_TARGET}"
TARGET_TRUPLE="x86_64-pc-linux-musl"

# Host
COPA_HOST="$(echo ${MACHTYPE} | sed "s/$(echo $MACHTYPE | cut -d- -f2)/crossCOPACABANA/")"
CMLFS_HOST="${COPA_HOST}"

# CPU information
ARCH='x86'
CPU='x86-64'

# C COMPILER
CC="${COPA_TARGET}-gcc"
CXX="${COPA_TARGET}-g++"
AR="${COPA_TARGET}-ar"
AS="${COPA_TARGET}-as"
RANLIB="${COPA_TARGET}-ranlib"
LD="${COPA_TARGET}-ld"
STRIP="${COPA_TARGET}-strip"
export COPA GNUC_TOOLS LLVM_TOOLS LFS CMLFS PATH COPA_TARGET LFS_TARGET CMLFS_TARGET TARGET_TRUPLE COPA_HOST LFS_HOST ARCH CPU 

# Export C COMPILER 
export CC CXX AR AS RANLIB LD STRIP

cgnutools: 5-GCC-final broken `libstdc++.so`

Hi, nice repository. I'm not sure what the problem is (the title). However, libstdc++ becomes like this:

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so
	ldd (0x7f16150ee000)
	libc.so => ldd (0x7f16150ee000)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so)
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetRegionStart: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_RaiseException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume_or_Rethrow: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetIPInfo: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetGR: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_DeleteException: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: __popcountdi2: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_Resume: symbol not found
Error relocating /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so: _Unwind_SetIP: symbol not found

So it can't build on step 8-clang

$ LD_LIBRARY_PATH=/cgnutools/lib:/cgnutools/${CMLFS_TARGET}/lib:/usr/lib:/lib ninja -C build
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: /cgnutools/x86_64-cmlfs-linux-musl/lib/libstdc++.so.6: no version information available (required by ninja)
ninja: Relink `/cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1' with `/lib64/libc.so.6' for IFUNC symbol `memset'
Segmentation fault

Though, libgcc_s.so.1 is fine.

$ ldd /cgnutools/x86_64-cmlfs-linux-musl/lib/libgcc_s.so.1
	ldd (0x7f04a7038000)
	libc.so => ldd (0x7f04a7038000)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.