Glibc - "undefined symbol: __sfp_handle_exceptions"
NR
nroycea+gnu@gmail.com
Tue Jun 17 02:12:12 GMT 2025
On Sat, Jun 14, 2025 at 6:18 PM NR <nroycea+gnu@gmail.com> wrote:
>
> On Sat, Jun 14, 2025 at 1:44 PM NR <nroycea+gnu@gmail.com> wrote:
> >
> > On Sat, Jun 14, 2025 at 10:45 AM NR <nroycea+gnu@gmail.com> wrote:
> > >
> > > On Fri, Jun 13, 2025 at 1:19 AM NR <nroycea+gnu@gmail.com> wrote:
> > > >
> > > > On Thu, Jun 12, 2025 at 3:07 PM NR <nroycea+gnu@gmail.com> wrote:
> > > > >
> > > > > On Thu, Jun 12, 2025 at 1:38 PM Adhemerval Zanella Netto
> > > > > <adhemerval.zanella@linaro.org> wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 12/06/25 05:52, NR wrote:
> > > > > > > On Wed, Jun 11, 2025 at 6:39 AM NR <nroycea+gnu@gmail.com> wrote:
> > > > > > >>
> > > > > > >> On Tue, Jun 10, 2025 at 3:44 PM Adhemerval Zanella Netto
> > > > > > >> <adhemerval.zanella@linaro.org> wrote:
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>> On 09/06/25 15:50, NR wrote:
> > > > > > >>>> On Mon, Jun 9, 2025 at 1:03 PM Adhemerval Zanella Netto
> > > > > > >>>> <adhemerval.zanella@linaro.org> wrote:
> > > > > > >>>>> On 09/06/25 12:16, NR wrote:
> > > > > > >>>>>> 1) Install kernel headers into empty directory
> > > > > > >>>>>> 2) Install glibc headers (and "touch" "<sysroot>/usr/include/gnu/stubs.h")
> > > > > > >>>>>> 3) Install LLVM runtime builtins
> > > > > > >>>>>> 4) Build glibc against sysroot
> > > > > > >>>>>>
> > > > > > >>>>>> ```
> > > > > > >>>>>> /<pathTo>/toolchain/bin/clang -shared -static-libgcc -Wl,-O1
> > > > > > >>>>>> -Wl,-z,defs -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2
> > > > > > >>>>>> -Wl,-z,pack-relative-relocs -B/<pathTo>/build/csu/
> > > > > > >>>>>> -Wl,--version-script=/<pathTo>/build/libm.map -Wl,--undefined-version
> > > > > > >>>>>> -Wl,-soname=libm.so.6 -Wl,-z,relro -Wl,-z,now -L/<pathTo>/build
> > > > > > >>>>>> -L/<pathTo>/build/math -L/<pathTo>/build/elf -L/<pathTo>/build/dlfcn
> > > > > > >>>>>> -L/<pathTo>/build/nss -L/<pathTo>/build/nis -L/<pathTo>/build/rt
> > > > > > >>>>>> -L/<pathTo>/build/resolv -L/<pathTo>/build/mathvec
> > > > > > >>>>>> -L/<pathTo>/build/support -L/<pathTo>/build/misc
> > > > > > >>>>>> -L/<pathTo>/build/debug -L/<pathTo>/build/nptl
> > > > > > >>>>>> -Wl,-rpath-link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > > > > > >>>>>> -o /<pathTo>/build/math/libm.so /<pathTo>/build/csu/abi-note.o
> > > > > > >>>>>> -Wl,--whole-archive /<pathTo>/build/math/libm_pic.a
> > > > > > >>>>>> -Wl,--no-whole-archive -Wl,--start-group /<pathTo>/build/libc.so
> > > > > > >>>>>> /<pathTo>/build/libc_nonshared.a -Wl,--as-needed
> > > > > > >>>>>> /<pathTo>/build/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
> > > > > > >>>>>> ld.lld: warning: attempt to reassign symbol 'exp2l' of version
> > > > > > >>>>>> 'GLIBC_2.2.5' to version 'GLIBC_2.4'
> > > > > > >>>>>> ld.lld: error: undefined symbol: __sfp_handle_exceptions
> > > > > > >>>>>>>>> referenced by e_sqrtf128.c
> > > > > > >>>>>>>>> e_sqrtf128.os:(__ieee754_sqrtf128) in archive /<pathTo>/build/math/libm_pic.a
> > > > > > >>>>>> clang: error: linker command failed with exit code 1
> > > > > > >>>>>> ```
> > > > > > >>>>>>
> > > > > > >>>>>> I also found it odd that even though I set "LDFLAGS" to include
> > > > > > >>>>>> sysroot and "-v", it didn't produce ld.lld verbose output (only
> > > > > > >>>>>> clang). It does with other projects.
> > > > > > >>>>>> My CFLAGS were included in "config.make", but no LDFLAGS.
> > > > > > >>>>>>
> > > > > > >>>>>> I was trying to think where I've seen "undefined symbol" before and
> > > > > > >>>>>> just now remembered it was when I stripped binaries for musl and ended
> > > > > > >>>>>> up finding out the entry "_start" was ripped out.
> > > > > > >>>>>> That doesn't apply here I don't think, as no install even happened yet.
> > > > > > >>>>>>
> > > > > > >>>>>> I see other "attempt to reassign symbol" warnings and read about using
> > > > > > >>>>>> "-Wl,--undefined-version" to LDFLAGS, but that didn't make any
> > > > > > >>>>>> difference (not sure why it would since they aren't "undefined").
> > > > > > >>>>>>
> > > > > > >>>>>> A search led me to
> > > > > > >>>>>> https://inbox.sourceware.org/glibc-cvs/?t=20240410130446 with some
> > > > > > >>>>>> "sfp" related stuff.
> > > > > > >>>>>> I don't know when `sysdeps/x86_64/configure` ends up occurring.
> > > > > > >>>>>>
> > > > > > >>>>>
> > > > > > >>>>> The __sfp_handle_exceptions is used internally by x86_64 and powerpc64le for
> > > > > > >>>>> the soft-fp implementation (soft-fp/), used to implement float128
> > > > > > >>>>> support (or for the case of powerpc64le with -mabi=ieeelongdouble, the
> > > > > > >>>>> long double), and it is provided by *libgcc*. Afaiu, this was a deliberate
> > > > > > >>>>> decision since glibc is/was the main source for the soft-fp implementation;
> > > > > > >>>>> and for some targets glibc still supports such symbols as compat one, and
> > > > > > >>>>> using libgcc will result in duplicated symbol and required some hacks to
> > > > > > >>>>> make the build correct (like .wrap we do for sparc).
> > > > > > >>>>>
> > > > > > >>>>> The last time I tried to check glibc build with clang and llvm runtime I noted
> > > > > > >>>>> that compiler-rt does not provide __sfp_handle_exceptions, nor its soft-fp routines
> > > > > > >>>>> (for long double / _Float128) support floating point rounding mode different than
> > > > > > >>>>> default (FE_TONEAREST) nor floating point exceptions for some operation (like
> > > > > > >>>>> overflow/underflow or invalid operations). I think this is true even for
> > > > > > >>>>> today.
> > > > > > >>>>>
> > > > > > >>>>> In this experiment I used a glibc where I copied the gcc implementation
> > > > > > >>>>> (libgcc/config/i386/sfp-exceptions.c). Sometime ago I tried to add a SSE
> > > > > > >>>>> only implementation on glibc (460ee50de054396cc9791ff4cfdc2f5029fb923d),
> > > > > > >>>>> but I had to revert it (f721171632d67f397e712db52b9ce36bb46fdd96).
> > > > > > >>>>>
> > > > > > >>>>> I think we recent minimum gcc version required to build glibc we can instead
> > > > > > >>>>> link against libgcc instead of resorting to our own soft-fp implementation.
> > > > > > >>>>> This would require some make changes to avoid doing this for some target
> > > > > > >>>>> (like powerpc).
> > > > > > >>>>>
> > > > > > >>>>> Another possibility would just to copy __sfp_handle_exceptions from libgcc
> > > > > > >>>>> to glibc for the ABI that requires it.
> > > > > > >>>>>
> > > > > > >>>>> On llvm side, one possibility would be to add __sfp_handle_exceptions for
> > > > > > >>>>> llvm-libgcc runtime.
> > > > > > >>>>
> > > > > > >>>> Okay, so from what I'm gathering, the azanella/clang branch is
> > > > > > >>>> expected to NOT build successfully without libgcc being installed
> > > > > > >>>> first. So, my options are:
> > > > > > >>>> a) I build `libgcc` first (easiest route (supposedly))
> > > > > > >>>> b) I copy `https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/ia64/sfp-exceptions.c`
> > > > > > >>>> to `sysdeps/x86/fpu/` and add it somewhere in the `Makefile`
> > > > > > >>>> (shouldn't this just already be done in the azanella/clang branch
> > > > > > >>>> itself?)
> > > > > > >>>
> > > > > > >>> It should be libgcc/config/*i386*/sfp-exceptions (ia64 is a defunct
> > > > > > >>> architecture not supported by glibc anymore).
> > > > > > >>>
> > > > > > >>> And I have not added it yet because I got stalled on other projects,
> > > > > > >>> and my focus now is to at least get clang+glibc is a workable state
> > > > > > >>> with libgcc.
> > > > > > >>>
> > > > > > >>>> c) I copy `https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/ia64/sfp-exceptions.c`
> > > > > > >>>> to `llvm-project/llvm-libgcc/` and add it somewhere in
> > > > > > >>>> `CMakeLists.txt` (probably not since I'd doubt llvm would want to
> > > > > > >>>> accept such a PR)
> > > > > > >>>
> > > > > > >>> I doubt as well, since __sfp_handle_exceptions is really and implementation
> > > > > > >>> detail for the soft-fp support on GNU systems. I am not sure why it was
> > > > > > >>> not copied on glibc at first place, since most of the other soft-fp were.
> > > > > > >>>
> > > > > > >>>> d) It's dead-in-the-water, and I should give musl another look (was in
> > > > > > >>>> a fiery discussion regarding it and systemd, but yocto seems made for
> > > > > > >>>> it)
> > > > > > >>>>
> > > > > > >>>> I'll start with exploring b) when I'm rested, but am welcoming of
> > > > > > >>>> insight if I'm mistaken in any of my assumptions, or any further
> > > > > > >>>> advice.
> > > > > > >>>
> > > > > > >>> Could you check https://github.com/zatrazz/glibc/tree/azanella/clang-rtlib ?
> > > > > > >>>
> > > > > > >>> I have added a patch to build a __sfp_handle_exceptions if the selected
> > > > > > >>> compiler runtime does not provide it. The glibc now builds with
> > > > > > >>>
> > > > > > >>> -target x86_64-linux-gnu -Wno-unused-command-line-argument --rtlib=compiler-rt
> > > > > > >>>
> > > > > > >>> Although some tests still fails because of missing _Unwind_Backtrace (which
> > > > > > >>> was the original required support that motivated llvm-libgcc runtime). I have
> > > > > > >>> not check the C++ supports, neither if it has any regression (which mostly
> > > > > > >>> likely it does).
> > > > > > >>
> > > > > > >> I had moved this to the correct ML (though I don't know if it should
> > > > > > >> be taken back out since we're working on your branch/repo).
> > > > > > >>
> > > > > > >> In any case, yes, your change worked (also saw you've been busy with a
> > > > > > >> whole bunch of commits over the past day).
> > > > > > >>
> > > > > > >> On the flip side (and may warrant a separate report (to your repo?)),
> > > > > > >> I tried using a different arch (armv6) and needed to add a flag to
> > > > > > >> counter:
> > > > > > >> ```
> > > > > > >> error: overriding currently unsupported rounding mode on this target
> > > > > > >> [-Werror,-Wunsupported-floating-point-opt]
> > > > > > >> error: overriding currently unsupported use of floating point
> > > > > > >> exceptions on this target [-Werror,-Wunsupported-floating-point-opt]
> > > > > > >> ```
> > > > > > >> Added `-Wno-unsupported-floating-point-opt` to CFLAGS.
> > > > > > >>
> > > > > > >> Later, I found the triple for the `build` (as opposed to the
> > > > > > >> `--host=`) system was being used when building an Assembly file:
> > > > > > >> ```
> > > > > > >> /<pathTo>/toolchain/bin/clang ../sysdeps/unix/sysv/linux/arm/sysdep.S
> > > > > > >> -c -v -I../include -I/<pathTo>/build/csu -I/<pathTo>/build
> > > > > > >> -I../sysdeps/unix/sysv/linux/arm/le -I../sysdeps/unix/sysv/linux/arm
> > > > > > >> -I../sysdeps/arm/nptl -I../sysdeps/unix/sysv/linux/include
> > > > > > >> -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread
> > > > > > >> -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv
> > > > > > >> -I../sysdeps/unix/arm -I../sysdeps/unix -I../sysdeps/posix
> > > > > > >> -I../sysdeps/arm/le/armv6 -I../sysdeps/arm/armv6
> > > > > > >> -I../sysdeps/arm/le/nofpu -I../sysdeps/arm/nofpu
> > > > > > >> -I../sysdeps/ieee754/soft-fp -I../sysdeps/arm/le
> > > > > > >> -I../sysdeps/arm/include -I../sysdeps/arm -I../sysdeps/wordsize-32
> > > > > > >> -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64
> > > > > > >> -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I.
> > > > > > >> -D_LIBC_REENTRANT -include /<pathTo>/build/libc-modules.h
> > > > > > >> -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC
> > > > > > >> -DTOP_NAMESPACE=glibc -DASSEMBLER -I/<pathTo>/build/csu/.
> > > > > > >> -Werror=undef -o /<pathTo>/build/csu/sysdep.o -MD -MP -MF
> > > > > > >> /<pathTo>/build/csu/sysdep.o.dt -MT /<pathTo>/build/csu/sysdep.o
> > > > > > >> clang version 21.0.0git
> > > > > > >> Target: x86_64-unknown-linux-gnu
> > > > > > >> Thread model: posix
> > > > > > >> InstalledDir: /<pathTo>/toolchain/bin
> > > > > > >> Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1
> > > > > > >> Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1
> > > > > > >> Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1
> > > > > > >> Candidate multilib: .;@m64
> > > > > > >> Candidate multilib: 32;@m32
> > > > > > >> Selected multilib: .;@m64
> > > > > > >> "/<pathTo>/toolchain/bin/clang-21" -cc1 -triple
> > > > > > >> x86_64-unknown-linux-gnu -E -disable-free -clear-ast-before-backend
> > > > > > >> -disable-llvm-verifier -discard-value-names -main-file-name sysdep.S
> > > > > > >> -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all
> > > > > > >> -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases
> > > > > > >> -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic
> > > > > > >> -debugger-tuning=gdb -fdebug-compilation-dir=/<pathTo>/glibc/csu -v
> > > > > > >> -fcoverage-compilation-dir=/<pathTo>/glibc/csu -resource-dir
> > > > > > >> /<pathTo>/toolchain/lib/clang/21 -dependency-file
> > > > > > >> /<pathTo>/build/csu/sysdep.o.dt -MT /<pathTo>/build/csu/sysdep.o
> > > > > > >> -sys-header-deps -MP -include /<pathTo>/build/libc-modules.h -include
> > > > > > >> ../include/libc-symbols.h -I ../include -I /<pathTo>/build/csu -I
> > > > > > >> /<pathTo>/build -I ../sysdeps/unix/sysv/linux/arm/le -I
> > > > > > >> ../sysdeps/unix/sysv/linux/arm -I ../sysdeps/arm/nptl -I
> > > > > > >> ../sysdeps/unix/sysv/linux/include -I ../sysdeps/unix/sysv/linux -I
> > > > > > >> ../sysdeps/nptl -I ../sysdeps/pthread -I ../sysdeps/gnu -I
> > > > > > >> ../sysdeps/unix/inet -I ../sysdeps/unix/sysv -I ../sysdeps/unix/arm -I
> > > > > > >> ../sysdeps/unix -I ../sysdeps/posix -I ../sysdeps/arm/le/armv6 -I
> > > > > > >> ../sysdeps/arm/armv6 -I ../sysdeps/arm/le/nofpu -I
> > > > > > >> ../sysdeps/arm/nofpu -I ../sysdeps/ieee754/soft-fp -I
> > > > > > >> ../sysdeps/arm/le -I ../sysdeps/arm/include -I ../sysdeps/arm -I
> > > > > > >> ../sysdeps/wordsize-32 -I ../sysdeps/ieee754/flt-32 -I
> > > > > > >> ../sysdeps/ieee754/dbl-64 -I ../sysdeps/ieee754 -I ../sysdeps/generic
> > > > > > >> -I .. -I ../libio -I . -D _LIBC_REENTRANT -D MODULE_NAME=libc -D PIC
> > > > > > >> -D TOP_NAMESPACE=glibc -D ASSEMBLER -I /<pathTo>/build/csu/.
> > > > > > >> -internal-isystem /<pathTo>/toolchain/lib/clang/21/include
> > > > > > >> -internal-isystem /usr/local/include -internal-isystem
> > > > > > >> /usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include
> > > > > > >> -internal-externc-isystem /include -internal-externc-isystem
> > > > > > >> /usr/include -Werror=undef -ferror-limit 19 -fgnuc-version=4.2.1
> > > > > > >> -fskip-odr-check-in-gmf -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
> > > > > > >> /tmp/sysdep-f5bf6d.s -x assembler-with-cpp
> > > > > > >> ../sysdeps/unix/sysv/linux/arm/sysdep.S
> > > > > > >> clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target
> > > > > > >> x86_64-unknown-linux-gnu
> > > > > > >> ignoring nonexistent directory
> > > > > > >> "/usr/lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../x86_64-pc-linux-gnu/include"
> > > > > > >> ignoring nonexistent directory "/include"
> > > > > > >> ignoring duplicate directory "/<pathTo>/build/csu/."
> > > > > > >> #include "..." search starts here:
> > > > > > >> #include <...> search starts here:
> > > > > > >> ../include
> > > > > > >> /<pathTo>/build/csu
> > > > > > >> /<pathTo>/build
> > > > > > >> ../sysdeps/unix/sysv/linux/arm/le
> > > > > > >> ../sysdeps/unix/sysv/linux/arm
> > > > > > >> ../sysdeps/arm/nptl
> > > > > > >> ../sysdeps/unix/sysv/linux/include
> > > > > > >> ../sysdeps/unix/sysv/linux
> > > > > > >> ../sysdeps/nptl
> > > > > > >> ../sysdeps/pthread
> > > > > > >> ../sysdeps/gnu
> > > > > > >> ../sysdeps/unix/inet
> > > > > > >> ../sysdeps/unix/sysv
> > > > > > >> ../sysdeps/unix/arm
> > > > > > >> ../sysdeps/unix
> > > > > > >> ../sysdeps/posix
> > > > > > >> ../sysdeps/arm/le/armv6
> > > > > > >> ../sysdeps/arm/armv6
> > > > > > >> ../sysdeps/arm/le/nofpu
> > > > > > >> ../sysdeps/arm/nofpu
> > > > > > >> ../sysdeps/ieee754/soft-fp
> > > > > > >> ../sysdeps/arm/le
> > > > > > >> ../sysdeps/arm/include
> > > > > > >> ../sysdeps/arm
> > > > > > >> ../sysdeps/wordsize-32
> > > > > > >> ../sysdeps/ieee754/flt-32
> > > > > > >> ../sysdeps/ieee754/dbl-64
> > > > > > >> ../sysdeps/ieee754
> > > > > > >> ../sysdeps/generic
> > > > > > >> ..
> > > > > > >> ../libio
> > > > > > >> .
> > > > > > >> /<pathTo>/toolchain/lib/clang/21/include
> > > > > > >> /usr/local/include
> > > > > > >> /usr/include
> > > > > > >> End of search list.
> > > > > > >> In file included from ../sysdeps/unix/sysv/linux/arm/sysdep.S:18:
> > > > > > >> In file included from ../sysdeps/unix/sysv/linux/arm/sysdep.h:23:
> > > > > > >> In file included from ../sysdeps/unix/arm/sysdep.h:19:
> > > > > > >> ../sysdeps/arm/sysdep.h:49:4: error: unknown arm architecture
> > > > > > >> 49 | # error unknown arm architecture
> > > > > > >> | ^
> > > > > > >> ../sysdeps/arm/sysdep.h:53:5: error: '__ARM_ARCH' is not defined,
> > > > > > >> evaluates to 0 [-Werror,-Wundef]
> > > > > > >> 53 | #if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__)
> > > > > > >> | ^
> > > > > > >> ../sysdeps/arm/sysdep.h:56:5: error: '__ARM_ARCH' is not defined,
> > > > > > >> evaluates to 0 [-Werror,-Wundef]
> > > > > > >> 56 | #if __ARM_ARCH > 4
> > > > > > >> | ^
> > > > > > >> ../sysdeps/arm/sysdep.h:59:5: error: '__ARM_ARCH' is not defined,
> > > > > > >> evaluates to 0 [-Werror,-Wundef]
> > > > > > >> 59 | #if __ARM_ARCH > 6 || defined (__ARM_ARCH_6K__) || defined
> > > > > > >> (__ARM_ARCH_6ZK__)
> > > > > > >> | ^
> > > > > > >> ../sysdeps/arm/sysdep.h:62:5: error: '__ARM_ARCH' is not defined,
> > > > > > >> evaluates to 0 [-Werror,-Wundef]
> > > > > > >> 62 | #if __ARM_ARCH > 6 || defined (__ARM_ARCH_6T2__)
> > > > > > >> | ^
> > > > > > >> 5 errors generated.
> > > > > > >> make[2]: *** [/<pathTo>/build/sysd-rules:41:
> > > > > > >> /<pathTo>/build/csu/sysdep.o] Error 1
> > > > > > >> make[2]: Leaving directory '/<pathTo>/glibc/csu'
> > > > > > >> make[1]: *** [Makefile:484: csu/subdir_lib] Error 2
> > > > > > >> make[1]: Leaving directory '/<pathTo>/glibc'
> > > > > > >> make: *** [Makefile:20: all] Error 2
> > > > > > >> ```
> > > > > > >>
> > > > > > >> You can see `-triple x86_64-unknown-linux-gnu` being used even though
> > > > > > >> `--target=armv6-pc-linux-gnueabi` is set in CFLAGS.
> > > > > > >> I didn't notice any ASFLAGS in `--help`, but set it anyway with no
> > > > > > >> difference in the result.
> > > > > > >> I see mention of `ASFLAGS_config` in `configure.ac`
> > > > > > >> In `config.make`, I see:
> > > > > > >> ```
> > > > > > >> cflags-cpu =
> > > > > > >> asflags-cpu =
> > > > > > >> CFLAGS = <my stuff>
> > > > > > >> ASFLAGS-config = -Wa,--noexecstack
> > > > > > >> ```
> > > > > > >> That seems relevant/important that the *-cpu isn't set, and my
> > > > > > >> `ASFLAGS` wasn't used.
> > > > > > >
> > > > > > > That issue was due to me not having made the LLVM builtins yet (you'll
> > > > > > > see the `triple` reflect that change below)...
> > > > > > > I did that now but lld is still making considerations for `x86_64`:
> > > > > >
> > > > > > I added two more patch on azanella/clang-rtlib [1] to try improve
> > > > > > building with only LLVM runtime libraries. The ca45908e57 changes
> > > > > > how to handle have-cc-with-libunwind to use -lunwind if compiler
> > > > > > does not support -lgcc_eh for unwinding; while c7ff5c9d08
> > > > > > uses -print-libgcc-file-name at configure time to figure out which
> > > > > > compiler runtime to use (-lclang_rt.builtins for the case of
> > > > > > --rtlib=compiler-rt).
> > > > > >
> > > > > > These are still WIP and I don't have my LLVM environment to fully
> > > > > > exclude system libraries (so clang with --rtlib=libgcc still works),
> > > > > > but at least it can build with clang along with --rtlib=compiler-rt
> > > > > > and --libunwind=unwind.
> > > > > >
> > > > > > The testcase still shows a lot of regression, mostly due float128
> > > > > > support; I still need to correctly handle libc++/libc++abi; and
> > > > > > the pthread cancellation support still tried to load/use libgcc_s.so.
> > > > > >
> > > > > > Currently I have only tested on x86_64, and I will finish it on
> > > > > > aarch64 as well. The arm32 is not really the focus yet.
> > > > > >
> > > > > > [1] https://github.com/zatrazz/glibc/tree/azanella/clang-rtlib
> > > > >
> > > > > Yup, I saw the 7784c9f2f3e410c184d0d8d8b443fe739655d1ef commit (now on
> > > > > 3e1d75bb500f46b484fb04ebb37a9d48a68eb4e5), and started to configure
> > > > > with it, but immediately was met with an issue about libunwind and
> > > > > others missing:
> > > > > ```
> > > > > configure:7098: /<pathTo>/toolchain/bin/clang -pipe
> > > > > --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot -o conftest
> > > > > -pipe --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot -v -O2
> > > > > -Wno-unsupported-floating-point-opt -fPIC -pipe
> > > > > --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot -v -pipe
> > > > > --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot -v
> > > > > -Wl,--undef
> > > > > ined-version conftest.c -lunwind >&5
> > > > > clang version 21.0.0git
> > > > > Target: aarch64-pc-linux-gnu
> > > > > Thread model: posix
> > > > > InstalledDir: /<pathTo>/toolchain/bin
> > > > > "/<pathTo>/toolchain/bin/clang-21" -cc1 -triple aarch64-pc-linux-gnu
> > > > > -emit-obj -dumpdir conftest- -disable-free -clear-ast-before-backend
> > > > > -disable-llvm-verifier -discard-value-names -main-file-name conftest.c
> > > > > -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition
> > > > > -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on
> > > > > -fno-rounding-math -mconstructor-aliases -funwind-tables=2
> > > > > -enable-tlsdesc -target-cpu generic -target-feature +v8a
> > > > > -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs
> > > > > -debugger-tuning=gdb -fdebug-compilation-dir=/<pathTo>/build -v -v -v
> > > > > -fcoverage-compilation-dir=/<pathTo>/build -resource-dir
> > > > > /<pathTo>/toolchain/lib/clang/21 -isysroot /<pathTo>/sysroot
> > > > > -internal-isystem /<pathTo>/toolchain/lib/clang/21/include
> > > > > -internal-isystem /<pathTo>/sysroot/usr/local/include
> > > > > -internal-externc-isystem /<pathTo>/sysroot/include
> > > > > -internal-externc-isystem /<pathTo>/sysroot/usr/include -O2
> > > > > -Wno-unsupported-floating-point-opt -ferror-limit 19 -fno-signed-char
> > > > > -fgnuc-
> > > > > version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp
> > > > > -target-feature +outline-atomics -faddrsig
> > > > > -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/conftest-acfbb9.o -x c
> > > > > conftest.c
> > > > > clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target
> > > > > x86_64-unknown-linux-gnu
> > > > > ignoring nonexistent directory "/<pathTo>/sysroot/usr/local/include"
> > > > > ignoring nonexistent directory "/<pathTo>/sysroot/include"
> > > > > #include "..." search starts here:
> > > > > #include <...> search starts here:
> > > > > /<pathTo>/toolchain/lib/clang/21/include
> > > > > /<pathTo>/sysroot/usr/include
> > > > > End of search list.
> > > > > "/<pathTo>/toolchain/bin/ld.lld" --sysroot=/<pathTo>/sysroot -EL
> > > > > --hash-style=gnu --eh-frame-hdr -m aarch64linux -pie -dynamic-linker
> > > > > /lib/ld-linux-aarch64.so.1 -o conftest Scrt1.o crti.o
> > > > > /<pathTo>/toolchain/lib/clang/21/lib/linux/clang_rt.crtbegin-aarch64.o
> > > > > -L/<pathTo>/sysroot/lib/../lib64 -L/<pathTo>/sysroot/usr/lib64
> > > > > -L/<pathTo>/sysroot/lib -L/<pathTo>/sysroot/usr/lib
> > > > > --undefined-version /tmp/conftest-acfbb9.o -lunwind
> > > > > /<pathTo>/toolchain/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a
> > > > > --as-needed -lunwind --no-as-needed -lc
> > > > > /<pathTo>/toolchain/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a
> > > > > --as-needed -lunwind --no-as-needed
> > > > > /<pathTo>/toolchain/lib/clang/21/lib/linux/clang_rt.crtend-aarch64.o
> > > > > crtn.o
> > > > > ld.lld: error: cannot open Scrt1.o: No such file or directory
> > > > > ld.lld: error: cannot open crti.o: No such file or directory
> > > > > ld.lld: error: unable to find library -lunwind
> > > > > ld.lld: error: unable to find library -lunwind
> > > > > ld.lld: error: unable to find library -lc //<<--- umm, really? We're
> > > > > building this, heh (guessing that would be part of compiler-rt, as
> > > > > well as the others except for libunwind)
> > > > > ld.lld: error: unable to find library -lunwind
> > > > > ld.lld: error: cannot open crtn.o: No such file or directory
> > > > > clang: error: linker command failed with exit code 1 (use -v to see invocation)
> > > > > configure:7098: $? = 1
> > > > > configure: failed program was:
> > > > > | /* confdefs.h */
> > > > > | #define PACKAGE_NAME "GNU C Library"
> > > > > | #define PACKAGE_TARNAME "glibc"
> > > > > | #define PACKAGE_VERSION "(see version.h)"
> > > > > | #define PACKAGE_STRING "GNU C Library (see version.h)"
> > > > > | #define PACKAGE_BUGREPORT "https://sourceware.org/bugzilla/"
> > > > > | #define PACKAGE_URL "https://www.gnu.org/software/glibc/"
> > > > > | #define PKGVERSION "(GNU libc) "
> > > > > | #define REPORT_BUGS_TO "<https://www.gnu.org/software/libc/bugs.html>"
> > > > > | #define TIMEOUTFACTOR 1
> > > > > | #define USE_PPC_SCV 1
> > > > > | #define HAVE_CC_NO_STACK_PROTECTOR 1
> > > > > | #define HAVE_TEST_CC_NO_STACK_PROTECTOR 1
> > > > > | #define STACK_PROTECTOR_LEVEL 0
> > > > > | #define HAVE_GNU_RETAIN 1
> > > > > | #define USE_MULTIARCH 1
> > > > > | #define HAVE_ASM_SET_DIRECTIVE 1
> > > > > | /* end confdefs.h. */
> > > > > | extern long int _Unwind_GetIP (void *);
> > > > > | int
> > > > > | main (void)
> > > > > | {
> > > > > | _Unwind_GetIP (0)
> > > > > | ;
> > > > > | return 0;
> > > > > | }
> > > > > configure:7108: error: in '/<pathTo>/build':
> > > > > configure:7110: error: no compiler support found for unwind
> > > > > ```
> > > > >
> > > > > So I just passed `libc_cv_cc_with_libunwind=no` env var to it, but
> > > > > that ended up failing late into the build:
> > > > > ```
> > > > > /<pathTo>/toolchain/bin/clang -pipe --target=aarch64-pc-linux-gnu
> > > > > --sysroot=/<pathTo>/sysroot -pipe --target=aarch64-pc-linux-gnu
> > > > > --sysroot=/<pathTo>/sysroot -v -Wl,--undefined-version -nostdlib
> > > > > -nostartfiles -r -o /<pathTo>/build/elf/librtld.map.o
> > > > > /<pathTo>/build/elf/librtld.mapT.o '-Wl,-('
> > > > > /<pathTo>/build/elf/dl-allobjs.os /<pathTo>/build/libc_pic.a
> > > > > -lclang_rt.builtins '-Wl,-)'
> > > > > -Wl,-Map,/<pathTo>/build/elf/librtld.mapT
> > > > > clang version 21.0.0git
> > > > > Target: aarch64-pc-linux-gnu
> > > > > Thread model: posix
> > > > > InstalledDir: /<pathTo>/toolchain/bin
> > > > > "/<pathTo>/toolchain/bin/ld.lld" --sysroot=/<pathTo>/sysroot -EL
> > > > > --hash-style=gnu --eh-frame-hdr -m aarch64linux -o
> > > > > /<pathTo>/build/elf/librtld.map.o -L/<pathTo>/sysroot/lib/../lib64
> > > > > -L/<pathTo>/sysroot/usr/lib64 -L/<pathTo>/sysroot/lib
> > > > > -L/<pathTo>/sysroot/usr/lib --undefined-version -r
> > > > > /<pathTo>/build/elf/librtld.mapT.o -(
> > > > > /<pathTo>/build/elf/dl-allobjs.os /<pathTo>/build/libc_pic.a
> > > > > -lclang_rt.builtins -) -Map /<pathTo>/build/elf/librtld.mapT
> > > > > ld.lld: error: unable to find library -lclang_rt.builtins
> > > > > clang: error: linker command failed with exit code 1 (use -v to see invocation)
> > > > > make[2]: *** [Makefile:1501: /<pathTo>/build/elf/librtld.map] Error 1
> > > > > make[2]: Leaving directory '/<pathTo>/glibc/elf'
> > > > > make[1]: *** [Makefile:484: elf/subdir_lib] Error 2
> > > > > make[1]: Leaving directory '/<pathTo>/glibc'
> > > > > make: *** [Makefile:20: all] Error 2
> > > > > ```
> > > > > Yet, `<pathTo>/toolchain/bin/clang -target aarch64-pc-linux-gnu
> > > > > -print-libgcc-file-name` yields:
> > > > > `<pathTo>/toolchain/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a`,
> > > > > which exists.
> > > > > I don't know if it's to be expected to have libunwind for
> > > > > cross-building at this early stage.
> > > > > I had used mstorjo's repo as guidance for how to proceed with creating
> > > > > a linux-from-scratch musl-based system (really just the toolchain and
> > > > > builtins).
> > > > > At this point, we would have done stage1 build of LLVM, install kernel
> > > > > and musl (glibc instead for this) headers, builtins, compile musl
> > > > > (glibc instead. *we are here), then libcxx and libunwind into sysroot.
> > > > > Hmm, using `find`, I do see
> > > > > <pathTo>/toolchain/lib/x86_64-unknown-linux-gnu/libunwind.a, so is
> > > > > that something that would get built this early, along with
> > > > > compiler-rt-builtins rather than just for the stage1 default LLVM
> > > > > build?
> > > >
> > > > Okay, for this issue, I found `configure.ac:
> > > > libc_cv_libgcc=-lclang_rt.builtins` is hardcoded, but doesn't
> > > > represent the *default* reality of LLVM's builtins build, where
> > > > `COMPILER_RT_INSTALL_LIBRARY_DIR:PATH=lib/linux`.
> > > > It's a known (and old) issue: https://github.com/llvm/llvm-project/issues/57781
> > > >
> > > > I think what could be done is have configure run `${CC-cc} -target
> > > > ${config_machine} -print-libgcc-file-name`, then set the '-l' by
> > > > stripping the prefix (${<var>##*/}) from the path provided to get the
> > > > file portion only.
> > > > Honestly, I think if the runtime-dir is being searched anyway, there's
> > > > no reason `COMPILER_RT_INSTALL_LIBRARY_DIR` should be set the way it
> > > > is.
> > > > I'm going to change mine to where `-print-runtime-dir` expects it, but
> > > > that won't help other *default* builders.
> > > > Nope, that's also problematic... `$ clang -target aarch64-pc-linux-gnu
> > > > -print-runtime-dir` ->
> > > > `<pathTo>/toolchain/lib/clang/21/lib/aarch64-pc-linux-gnu` ->
> > > > `libclang_rt.builtins-aarch64.a`
> > > > So a cross-build user is going to have `-$host_cpu` appended to the
> > > > archive anyway. I had hoped and expected it would not given the dir is
> > > > the full tuple anyway.
> > > > Looks like using/parsing `-print-libgcc-file-name` output is the best
> > > > route as far as I can see now. First run it, then `-d` test if it
> > > > exists (because using a non-existent builtin like
> > > > notarealarch-pc-linux-gnu will still provide a path), then parse it.
> > >
> > > I just realized you already DID use/parse -print-libgcc-file-name
> > > (mentioned earlier by you) with `libgcc_name`, but also hardcoded
> > > `libc_cv_libgcc` later?
> > >
> > > With a change to configure's
> > > `libc_cv_libgcc=-lclang_rt.builtins-$host_cpu`, I got past that and
> > > encountered an issue with the wrong objcopy being used, so I added the
> > > `OBJCOPY` env var to llvm's for configure's command.
> > > ```
> > > /<pathTo>/toolchain/bin/clang -pipe --target=aarch64-pc-linux-gnu
> > > --sysroot=/<pathTo>/sysroot -pipe --target=aarch64-pc-linux-gnu
> > > --sysroot=/<pathTo>/sysroot -v -Wl,--undefined-version -shared
> > > -static-libgcc -Wl,-O1 -Wl,-z,defs
> > > -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1
> > > -Wl,-z,pack-relative-relocs -B/<pathTo>/build/csu/
> > > -Wl,--version-script=/<pathTo>/build/libc.map -Wl,--undefined-version
> > > -Wl,-soname=libc.so.6 -Wl,-z,relro -nostdlib -nostartfiles -e
> > > __libc_main -L/<pathTo>/build -L/<pathTo>/build/math
> > > -L/<pathTo>/build/elf -L/<pathTo>/build/dlfcn -L/<pathTo>/build/nss
> > > -L/<pathTo>/build/nis -L/<pathTo>/build/rt -L/<pathTo>/build/resolv
> > > -L/<pathTo>/build/mathvec -L/<pathTo>/build/support
> > > -L/<pathTo>/build/misc -L/<pathTo>/build/debug -L/<pathTo>/build/nptl
> > > -Wl,-rpath-link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > > -o /<pathTo>/build/libc.so /<pathTo>/build/csu/abi-note.o
> > > /<pathTo>/build/libc_pic.os.clean /<pathTo>/build/elf/interp.os
> > > /<pathTo>/build/elf/ld.so -lclang_rt.builtins-aarch64
> > > /<pathTo>/build/elf/sofini.os
> > > clang version 21.0.0git
> > > Target: aarch64-pc-linux-gnu
> > > Thread model: posix
> > > InstalledDir: /<pathTo>/toolchain/bin
> > > clang: warning: argument unused during compilation: '-static-libgcc'
> > > [-Wunused-command-line-argument]
> > > "/<pathTo>/toolchain/bin/ld.lld" --sysroot=/<pathTo>/sysroot -EL
> > > --hash-style=gnu --eh-frame-hdr -m aarch64linux -shared -o
> > > /<pathTo>/build/libc.so -L/<pathTo>/build -L/<pathTo>/build/math
> > > -L/<pathTo>/build/elf -L/<pathTo>/build/dlfcn -L/<pathTo>/build/nss
> > > -L/<pathTo>/build/nis -L/<pathTo>/build/rt -L/<pathTo>/build/resolv
> > > -L/<pathTo>/build/mathvec -L/<pathTo>/build/support
> > > -L/<pathTo>/build/misc -L/<pathTo>/build/debug -L/<pathTo>/build/nptl
> > > -L/<pathTo>/toolchain/lib/clang/21/lib/aarch64-pc-linux-gnu
> > > -L/<pathTo>/sysroot/lib/../lib64 -L/<pathTo>/sysroot/usr/lib64
> > > -L/<pathTo>/sysroot/lib -L/<pathTo>/sysroot/usr/lib
> > > --undefined-version -O1 -z defs
> > > -dynamic-linker=/lib/ld-linux-aarch64.so.1 -z pack-relative-relocs
> > > --version-script=/<pathTo>/build/libc.map --undefined-version
> > > -soname=libc.so.6 -z relro -e __libc_main
> > > -rpath-link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > > /<pathTo>/build/csu/abi-note.o /<pathTo>/build/libc_pic.os.clean
> > > /<pathTo>/build/elf/interp.os /<pathTo>/build/elf/ld.so
> > > -lclang_rt.builtins-aarch64 /<pathTo>/build/elf/sofini.os
> > > ld.lld: warning: attempt to reassign symbol 'gnu_dev_major' of version
> > > 'GLIBC_2.17' to version 'GLIBC_2.25'
> > > ld.lld: warning: attempt to reassign symbol 'gnu_dev_minor' of version
> > > 'GLIBC_2.17' to version 'GLIBC_2.25'
> > > ld.lld: warning: attempt to reassign symbol 'gnu_dev_makedev' of
> > > version 'GLIBC_2.17' to version 'GLIBC_2.25'
> > > ld.lld: warning: attempt to reassign symbol 'fcntl' of version
> > > 'GLIBC_2.17' to version 'GLIBC_2.28'
> > > ld.lld: warning: attempt to reassign symbol '__sched_get_priority_min'
> > > of version 'GLIBC_2.17' to version 'GLIBC_PRIVATE'
> > > ld.lld: warning: attempt to reassign symbol '__sched_get_priority_max'
> > > of version 'GLIBC_2.17' to version 'GLIBC_PRIVATE'
> > > cd /<pathTo>/build && /<pathTo>/toolchain/bin/llvm-ar cruv
> > > libc_nonshared.a `cat csu/stamp.oS iconv/stamp.oS locale/stamp.oS
> > > localedata/stamp.oS iconvdata/stamp.oS assert/stamp.oS ctype/stamp.oS
> > > intl/stamp.oS catgets/stamp.oS math/stamp.oS setjmp/stamp.oS
> > > signal/stamp.oS stdlib/stamp.oS stdio-common/stamp.oS libio/stamp.oS
> > > dlfcn/stamp.oS nptl/stamp.oS rt/stamp.oS malloc/stamp.oS
> > > string/stamp.oS wcsmbs/stamp.oS timezone/stamp.oS time/stamp.oS
> > > dirent/stamp.oS posix/stamp.oS io/stamp.oS termios/stamp.oS
> > > resource/stamp.oS misc/stamp.oS socket/stamp.oS sysvipc/stamp.oS
> > > gmon/stamp.oS gnulib/stamp.oS wctype/stamp.oS manual/stamp.oS
> > > po/stamp.oS argp/stamp.oS conform/stamp.oS debug/stamp.oS
> > > mathvec/stamp.oS support/stamp.oS nptl_db/stamp.oS inet/stamp.oS
> > > resolv/stamp.oS nss/stamp.oS hesiod/stamp.oS sunrpc/stamp.oS
> > > nis/stamp.oS nscd/stamp.oS login/stamp.oS elf/stamp.oS stamp.oS`
> > > /<pathTo>/toolchain/bin/clang -pipe --target=aarch64-pc-linux-gnu
> > > --sysroot=/<pathTo>/sysroot -pipe --target=aarch64-pc-linux-gnu
> > > --sysroot=/<pathTo>/sysroot -v -Wl,--undefined-version -shared
> > > -static-libgcc -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1
> > > -Wl,-z,defs -Wl,-z,pack-relative-relocs -B/<pathTo>/build/csu/
> > > -Wl,--undefined-version -Wl,-z,relro -L/<pathTo>/build
> > > -L/<pathTo>/build/math -L/<pathTo>/build/elf -L/<pathTo>/build/dlfcn
> > > -L/<pathTo>/build/nss -L/<pathTo>/build/nis -L/<pathTo>/build/rt
> > > -L/<pathTo>/build/resolv -L/<pathTo>/build/mathvec
> > > -L/<pathTo>/build/support -L/<pathTo>/build/misc
> > > -L/<pathTo>/build/debug -L/<pathTo>/build/nptl
> > > -Wl,-rpath-link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > > -Wl,--as-needed -lgcc_s -Wl,--no-as-needed -o
> > > /<pathTo>/build/elf/sotruss-lib.so /<pathTo>/build/csu/abi-note.o
> > > -Wl,--as-needed /<pathTo>/build/elf/sotruss-lib.os -Wl,--no-as-needed
> > > -Wl,--start-group /<pathTo>/build/libc.so
> > > /<pathTo>/build/libc_nonshared.a -Wl,--as-needed
> > > /<pathTo>/build/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
> > > clang version 21.0.0git
> > > Target: aarch64-pc-linux-gnu
> > > Thread model: posix
> > > InstalledDir: /<pathTo>/toolchain/bin
> > > "/<pathTo>/toolchain/bin/ld.lld" --sysroot=/<pathTo>/sysroot -EL
> > > --hash-style=gnu --eh-frame-hdr -m aarch64linux -shared -o
> > > /<pathTo>/build/elf/sotruss-lib.so /<pathTo>/build/csu/crti.o
> > > /<pathTo>/toolchain/lib/clang/21/lib/linux/clang_rt.crtbegin-aarch64.o
> > > -L/<pathTo>/build -L/<pathTo>/build/math -L/<pathTo>/build/elf
> > > -L/<pathTo>/build/dlfcn -L/<pathTo>/build/nss -L/<pathTo>/build/nis
> > > -L/<pathTo>/build/rt -L/<pathTo>/build/resolv
> > > -L/<pathTo>/build/mathvec -L/<pathTo>/build/support
> > > -L/<pathTo>/build/misc -L/<pathTo>/build/debug -L/<pathTo>/build/nptl
> > > -L/<pathTo>/toolchain/lib/clang/21/lib/aarch64-pc-linux-gnu
> > > -L/<pathTo>/sysroot/lib/../lib64 -L/<pathTo>/sysroot/usr/lib64
> > > -L/<pathTo>/sysroot/lib -L/<pathTo>/sysroot/usr/lib
> > > --undefined-version -dynamic-linker=/lib/ld-linux-aarch64.so.1 -z defs
> > > -z pack-relative-relocs --undefined-version -z relro
> > > -rpath-link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > > --as-needed -lgcc_s --no-as-needed /<pathTo>/build/csu/abi-note.o
> > > --as-needed /<pathTo>/build/elf/sotruss-lib.os --no-as-needed
> > > --start-group /<pathTo>/build/libc.so /<pathTo>/build/libc_nonshared.a
> > > --as-needed /<pathTo>/build/elf/ld.so --no-as-needed --end-group
> > > /<pathTo>/toolchain/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a
> > > -l:libunwind.a -lc
> > > /<pathTo>/toolchain/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a
> > > -l:libunwind.a /<pathTo>/toolchain/lib/clang/21/lib/linux/clang_rt.crtend-aarch64.o
> > > /<pathTo>/build/csu/crtn.o
> > > ld.lld: error: unable to find library -lgcc_s
> > > ld.lld: error: unable to find library -l:libunwind.a
> > > ld.lld: error: unable to find library -l:libunwind.a
> > > clang: error: linker command failed with exit code 1 (use -v to see invocation)
> > > make[2]: *** [Makefile:250: /<pathTo>/build/elf/sotruss-lib.so] Error 1
> > > make[2]: Leaving directory '/<pathTo>/glibc/elf'
> > > make[1]: *** [Makefile:484: elf/subdir_lib] Error 2
> > > make[1]: Leaving directory '/<pathTo>/glibc'
> > > make: *** [Makefile:20: all] Error 2
> > > ```
> > >
> > > This made my head scratch a bit because it seemed like you did
> > > everything right in terms of what `config.make` was telling me...
> > > `-static-libgcc` (unrelated, but noticed the warning):
> > > ```
> > > Makerules:$(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
> > > Makerules:$(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
> > > ```
> > >
> > > gcc_s | unwind:
> > > ```
> > > config.make:have-cc-with-libunwind = no
> > > config.make:have-libgcc_s = no
> > > Makeconfig: libunwind = -lunwind $(libgcc-name)
> > > ```
> > >
> > > Then I came across Makeconfig's: `@@ -708,7 +708,7 @@ ifneq
> > > ($(have-cc-with-libunwind),yes)`
> > > I *think* you may have mixed up the condition (ifneq yes, not ifeq yes)?
> > > When I switched it up, I got past the missing gcc_s, but still have
> > > the missing `-l:libunwind.a` even though I did NOT include `-lunwind`
> > > in that Makeconfig (even removing it from the `else` part just for
> > > good measure. Also never seen the ':' usage before either). I'm truly
> > > flummoxed as to where that comes from.
Coming back to this part regarding `-lclang_rt.builtins`, I'm
realizing I did something different to get the above to "work", and I
don't recall exactly what that was, but based on my testing/changes
just now, I *think* it would be me installing compiler-builtins into
the sysroot.
But not even just that, because it defaults to "lib/linux", I would
have copied those to "lib".
So now instead I am setting LDFLAGS with `-L` set to the prefix of
clang's `-print-libgcc-file-name` (sans libgcc/clang_rt.builtins
filename) result.
Nope, that made no difference.
elf/Makefile:
`$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a`
`$(reloc-link) -o $@.o $@T.o '-Wl,-(' $^ $(gnulib) '-Wl,-)' -Wl,-Map,$@T`
An oddity, the LDFLAGS I set during configure, where I'd add an `-L`
to the builtins path, isn't being used for that linking part.
So my workaround was to also use LDFLAGS for the `make` (
-L$(libPath=$(${CC} ${CFLAGS} -print-libgcc-file-name); \printf
"${libPath%/*}") ).
As far as my previous issue with cross-compiling libcxx ("reference to
unresolved using declaration"), I guess the issue was me using
`-iwithsysroot` to the c++ include path. Once I removed that, the
build completed. Why? No clue.
Minor output annoyance: `Makerules:COMPILE.S = $(CC) -c $(CPPFLAGS)
$(S-CPPFLAGS) \` the `-c` results in `-Wunused-command-line-argument`.
I didn't see if there's a clang equivalent.
I also just saw `-static-libgcc` fly by (also unused):
`Makerules:$(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \`
`Makerules:$(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \`
Huh, that's weird...
`/usr/share/doc/clang/html/ClangCommandLineReference.html` shows that
is valid for clang?
Switching to armv6, I see you've already dealt with "error: result of
comparison of constant"
(https://sourceware.org/pipermail/glibc-cvs/2022q4/081226.html), so I
find it odd that I still hit it as an error.
It doesn't look like that patch is included in your repo? stdlib/strtod_l.c:
```
875 }
876 assert (dig_no <= (uintmax_t) INTMAX_MAX);
877
878 /* Remember start of exponent (if any). */
```
As an aside, I found that stripping glibc binaries, even with
"--strip-unneeded", results in a build fail for ncurses because
"atexit" symbol wasn't found. While I could use that for musl, I will
now use "--no-strip-all" for glibc.
> > So, good news with libunwind, I CAN build libunwind without needing
> > any libraries. Just: kernel headers -> c headers -> c++ headers ->
> > libunwind (static, otherwise shared fails to build).
> > Still, it was never needed with building musl.
> > But this leads to another issue:
> > ```
> > mv -f /<pathTo>/build/libc.so.6.new /<pathTo>/build/libc.so.6
> > /<pathTo>/toolchain/bin/clang -pipe --target=aarch64-pc-linux-gnu
> > --sysroot=/<pathTo>/sysroot -Wl,-rpath
> > link=/<pathTo>/build:/<pathTo>/build/math:/<pathTo>/build/elf:/<pathTo>/build/dlfcn:/<pathTo>/build/nss:/<pathTo>/build/nis:/<pathTo>/build/rt:/<pathTo>/build/resolv:/<pathTo>/build/mathvec:/<pathTo>/build/support:/<pathTo>/build/misc:/<pathTo>/build/debug:/<pathTo>/build/nptl
> > -o /<pathTo>/build/iconv/iconvconfig -pie -Wl,-z,pack-relative-relocs
> > -Wl,-O1 -nostdlib -nostartfiles -pipe --target=aarch64-pc-linux-gnu
> > --sysroot=/<pathTo>/sysroot -v -Wl,--undefined-version -Wl,-z,relro
> > /<pathTo>/build/csu/Scrt1.o /<pathTo>/build/csu/crti.o
> > `/<pathTo>/toolchain/bin/clang -pipe --target=aarch64-pc-linux-gnu
> > --sysroot=/<pathTo>/sysroot --print-file-name=crtbeginS.o`
> > /<pathTo>/build/iconv/iconvconfig.o /<pathTo>/build/iconv/strtab.o
> > /<pathTo>/build/iconv/xmalloc.o /<pathTo>/build/iconv/xasprintf.o
> > /<pathTo>/build/iconv/xstrdup.o /<pathTo>/build/iconv/hash-string.o
> > -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1
> > /<pathTo>/build/libc.so.6 /<pathTo>/build/libc_nonshared.a
> > -Wl,--as-needed /<pathTo>/build/elf/ld.so -Wl,--no-as-needed
> > -lclang_rt.builtins-aarch64 `/<pathTo>/toolchain/bin/clang -pipe
> > --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot
> > --print-file-name=crtendS.o` /<pathTo>/build/csu/crtn.o
> > clang version 21.0.0git
> > Target: aarch64-pc-linux-gnu
> > Thread model: posix
> > InstalledDir: /<pathTo>/toolchain/bin
> > clang: error: no such file or directory: 'crtbeginS.o'
> > clang: error: no such file or directory: 'crtendS.o'
> > make[2]: *** [../Rules:240: /<pathTo>/build/iconv/iconvconfig] Error 1
> > make[2]: Leaving directory '/<pathTo>/glibc/iconv'
> > make[1]: *** [Makefile:484: iconv/others] Error 2
> > make[1]: Leaving directory '/<pathTo>/glibc'
> > make: *** [Makefile:20: all] Error 2
> > ```
> > I presume those would equate to the builtins like `clang_rt.crtbegin-aarch64.o`?
> > There's 6 instances like `Makeconfig:+prector = `$(CC)
> > $(sysdep-LDFLAGS) --print-file-name=crtbegin.o``.
>
> Success! (somewhat)
> I finally got it to cross-compile, but dash wouldn't build.
> I found that the wrong objdump was being used and libc.so would say it
> was `elf64-little`.
> `Makerules: $(OBJDUMP) -f $@.so | sed -n 's/.*file format
> \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@`
> When I saw that and related it to objdump, I set the OBJDUMP env var
> to the llvm-objdump of my toolchain.
> `build/libc_pic.os: file format elf64-little`
> ->
> `build/libc_pic.os: file format elf64-littleaarch64`
>
> I think something that would be nice is to determine the compiler, and
> if `clang`, check for used `llvm-`*, using `-print-prog-name=`, test
> with shell `-x` (fallback with `command -v <llvm-?>`), and set them
> accordingly unless the env vars are already set.
>
> Dash is working under chroot now, but I noticed an error during the
> libcxxabi build (I'll look more into it when rested):
> LLVM `-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;"` (builds
> fine for musl, and already made sure `-DLIBCXX_HAS_MUSL_LIBC=FALSE`):
> ```
> cd /<pathTo>/build/libcxxabi/src && /<pathTo>/toolchain/bin/clang++
> --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot/
> -DHAVE___CXA_THREAD_ATEXIT_IMPL -DLIBCXX_BUILDING_LIBCXXABI
> -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
> -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_LINK_PTHREAD_LIB
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -I/<pathTo>/llvm_project/libunwind/include
> -I/<pathTo>/llvm_project/libcxxabi/../libcxx/src
> -I/<pathTo>/build/include/c++/v1
> -I/<pathTo>/llvm_project/libcxxabi/include -pipe
> --target=aarch64-pc-linux-gnu --sysroot=/<pathTo>/sysroot
> -iwithsysroot/usr/include/c++/v1 -iwithsysroot/usr/include -g -Og
> -fvisibility-inlines-hidden -Werror=date-time
> -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter
> -Wwrite-strings -Wcast-qual -Wmissing-field-initializers
> -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override
> -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported
> -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++23 -fPIC
> -nostdinc++ -fstrict-aliasing -funwind-tables -D_DEBUG -UNDEBUG -Wall
> -Wextra -Wnewline-eof -Wshadow -Wwrite-strings -Wno-unused-parameter
> -Wno-long-long -Werror=return-type -Wextra-semi -Wundef
> -Wunused-template -Wformat-nonliteral -Wzero-length-array
> -Wdeprecated-redundant-constexpr-static-def
> -Wno-nullability-completeness -Wno-user-defined-literals
> -Wno-covered-switch-default -Wno-suggest-override -Wno-error
> -fsized-deallocation -MD -MT
> libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_default_handlers.cpp.o
> -MF CMakeFiles/cxxabi_shared_objects.dir/cxa_default_handlers.cpp.o.d
> -o CMakeFiles/cxxabi_shared_objects.dir/cxa_default_handlers.cpp.o -c
> /<pathTo>/llvm_project/libcxxabi/src/cxa_default_handlers.cpp
> In file included from
> /<pathTo>/llvm_project/libcxxabi/src/cxa_default_handlers.cpp:20:
> In file included from
> /<pathTo>/llvm_project/libcxxabi/../libcxx/src/include/atomic_support.h:13:
> In file included from /<pathTo>/build/include/c++/v1/memory:947:
> In file included from /<pathTo>/build/include/c++/v1/__memory/inout_ptr.h:16:
> In file included from /<pathTo>/build/include/c++/v1/__memory/shared_ptr.h:36:
> In file included from /<pathTo>/build/include/c++/v1/__memory/unique_ptr.h:20:
> /<pathTo>/build/include/c++/v1/__functional/hash.h:37:8: error:
> reference to unresolved using declaration
> 37 | std::memcpy(std::addressof(__r), __p, sizeof(__r));
> | ^
> /<pathTo>/build/include/c++/v1/cstring:82:1: note: using declaration
> annotated with 'using_if_exists' here
> 82 | using ::memcpy _LIBCPP_USING_IF_EXISTS;
> | ^
> 1 error generated.
> make[2]: *** [libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/build.make:93:
> libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/cxa_default_handlers.cpp.o]
> Error 1
> make[2]: Leaving directory '/<pathTo>/build'
> make[1]: *** [CMakeFiles/Makefile2:1222:
> libcxxabi/src/CMakeFiles/cxxabi_shared_objects.dir/all] Error 2
> make[1]: Leaving directory '/<pathTo>/build'
> make: *** [Makefile:136: all] Error 2
> ```
> > > > > > > ```
> > > > > > > clang version 21.0.0git
> > > > > > > Target: aarch64-pc-linux-gnu
> > > > > > > Thread model: posix
> > > > > > > InstalledDir: /<pathTo>/toolchain/bin
> > > > > > > (in-process)
> > > > > > > "/<pathTo>/toolchain/bin/clang-21" -cc1 -triple aarch64-pc-linux-gnu
> > > > > > > -emit-obj -disable-free -clear-ast-before-backend
> > > > > > > -disable-llvm-verifier -discard-value-names -main-file-name
> > > > > > > static-reloc.c -mrelocation-model pic -pic-level 2 -pic-is-pie
> > > > > > > -fmerge-all-constants -mframe-pointer=non-leaf -fmath-errno
> > > > > > > -ffp-contract=on -frounding-math -ffp-exception-behavior=strict
> > > > > > > -mconstructor-aliases -funwind-tables=2 -enable-tlsdesc -target-cpu
> > > > > > > generic -target-feature +v8a -target-feature +fp-armv8 -target-feature
> > > > > > > +neon -target-abi aapcs -debugger-tuning=gdb
> > > > > > > -fdebug-compilation-dir=/<pathTo>/glibc/csu -v -v
> > > > > > > -fcoverage-compilation-dir=/<pathTo>/glibc/csu -resource-dir
> > > > > > > /<pathTo>/toolchain/lib/clang/21 -dependency-file
> > > > > > > /<pathTo>/build/csu/static-reloc.o.dt -MT
> > > > > > > /<pathTo>/build/csu/static-reloc.o -sys-header-deps -MP -include
> > > > > > > /<pathTo>/build/libc-modules.h -include ../include/libc-symbols.h -U
> > > > > > > _FORTIFY_SOURCE -D STACK_PROTECTOR_LEVEL=0 -I ../include -I
> > > > > > > /<pathTo>/build/csu -I /<pathTo>/build -I
> > > > > > > ../sysdeps/unix/sysv/linux/aarch64 -I ../sysdeps/aarch64/nptl -I
> > > > > > > ../sysdeps/unix/sysv/linux/wordsize-64 -I
> > > > > > > ../sysdeps/unix/sysv/linux/include -I ../sysdeps/unix/sysv/linux -I
> > > > > > > ../sysdeps/nptl -I ../sysdeps/pthread -I ../sysdeps/gnu -I
> > > > > > > ../sysdeps/unix/inet -I ../sysdeps/unix/sysv -I ../sysdeps/unix -I
> > > > > > > ../sysdeps/posix -I ../sysdeps/aarch64/fpu -I
> > > > > > > ../sysdeps/aarch64/multiarch -I ../sysdeps/aarch64 -I
> > > > > > > ../sysdeps/wordsize-64 -I ../sysdeps/ieee754/ldbl-128 -I
> > > > > > > ../sysdeps/ieee754/dbl-64 -I ../sysdeps/ieee754/flt-32 -I
> > > > > > > ../sysdeps/ieee754 -I ../sysdeps/generic -I .. -I ../libio -I . -D
> > > > > > > _LIBC_REENTRANT -D MODULE_NAME=libc -D PIC -D TOP_NAMESPACE=glibc
> > > > > > > -isysroot /<pathTo>/sysroot -internal-isystem
> > > > > > > /<pathTo>/toolchain/lib/clang/21/include -internal-isystem
> > > > > > > /<pathTo>/sysroot/usr/local/include -internal-externc-isystem
> > > > > > > /<pathTo>/sysroot/include -internal-externc-isystem
> > > > > > > /<pathTo>/sysroot/usr/include -O2 -Wno-unsupported-floating-point-opt
> > > > > > > -Wall -Wwrite-strings -Wundef -Wimplicit-fallthrough -Werror
> > > > > > > -Wstrict-prototypes -Wold-style-definition -std=gnu11 -fconst-strings
> > > > > > > -ferror-limit 19 -ftls-model=initial-exec -fno-signed-char
> > > > > > > -fgnuc-version=4.2.1 -fgnu89-inline -fskip-odr-check-in-gmf
> > > > > > > -vectorize-loops -vectorize-slp -target-feature +outline-atomics
> > > > > > > -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
> > > > > > > /<pathTo>/build/csu/static-reloc.o -x c static-reloc.c
> > > > > > > clang -cc1 version 21.0.0git based upon LLVM 21.0.0git default target
> > > > > > > x86_64-unknown-linux-gnu
> > > > > > > ignoring nonexistent directory "/<pathTo>/sysroot/usr/local/include"
> > > > > > > ignoring nonexistent directory "/<pathTo>/sysroot/include"
> > > > > > > #include "..." search starts here:
> > > > > > > #include <...> search starts here:
> > > > > > > ../include
> > > > > > > /<pathTo>/build/csu
> > > > > > > /<pathTo>/build
> > > > > > > ../sysdeps/unix/sysv/linux/aarch64
> > > > > > > ../sysdeps/aarch64/nptl
> > > > > > > ../sysdeps/unix/sysv/linux/wordsize-64
> > > > > > > ../sysdeps/unix/sysv/linux/include
> > > > > > > ../sysdeps/unix/sysv/linux
> > > > > > > ../sysdeps/nptl
> > > > > > > ../sysdeps/pthread
> > > > > > > ../sysdeps/gnu
> > > > > > > ../sysdeps/unix/inet
> > > > > > > ../sysdeps/unix/sysv
> > > > > > > ../sysdeps/unix
> > > > > > > ../sysdeps/posix
> > > > > > > ../sysdeps/aarch64/fpu
> > > > > > > ../sysdeps/aarch64/multiarch
> > > > > > > ../sysdeps/aarch64
> > > > > > > ../sysdeps/wordsize-64
> > > > > > > ../sysdeps/ieee754/ldbl-128
> > > > > > > ../sysdeps/ieee754/dbl-64
> > > > > > > ../sysdeps/ieee754/flt-32
> > > > > > > ../sysdeps/ieee754
> > > > > > > ../sysdeps/generic
> > > > > > > ..
> > > > > > > ../libio
> > > > > > > .
> > > > > > > /<pathTo>/toolchain/lib/clang/21/include
> > > > > > > /<pathTo>/sysroot/usr/include
> > > > > > > End of search list.
> > > > > > > /<pathTo>/toolchain/bin/clang -nostdlib -nostartfiles -r -o
> > > > > > > /<pathTo>/build/csu/crt1.o /<pathTo>/build/csu/start.o
> > > > > > > /<pathTo>/build/csu/abi-note.o /<pathTo>/build/csu/init.o
> > > > > > > /<pathTo>/build/csu/static-reloc.o
> > > > > > > ld.lld: error: /<pathTo>/build/csu/start.o is incompatible with elf_x86_64
> > > > > > > ld.lld: error: /<pathTo>/build/csu/abi-note.o is incompatible with elf_x86_64
> > > > > > > ld.lld: error: /<pathTo>/build/csu/init.o is incompatible with elf_x86_64
> > > > > > > ld.lld: error: /<pathTo>/build/csu/static-reloc.o is incompatible with
> > > > > > > elf_x86_64
> > > > > > > clang: error: linker command failed with exit code 1 (use -v to see invocation)
> > > > > > > make[2]: *** [Makefile:185: /<pathTo>/build/csu/crt1.o] Error 1
> > > > > > > make[2]: Leaving directory '/<pathTo>/glibc/csu'
> > > > > > > make[1]: *** [Makefile:484: csu/subdir_lib] Error 2
> > > > > > > make[1]: Leaving directory '/<pathTo>/glibc'
> > > > > > > make: *** [Makefile:20: all] Error 2
> > > > > > > ```
> > > > > > >
> > > > > > > Again, I don't know why it isn't showing the verbose linker output
> > > > > > > when I used `-v` in LDFLAGS (along with sysroot and target).
> > > > > >
More information about the Libc-help
mailing list