# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/glibc/glibc.conf # Copyright (C) 2004 - 2025 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 # --- T2-COPYRIGHT-END --- # overwrite prefix to not point to the tools, but the real root for the headers if atstage toolchain; then # hack due to sane variable not available and prefix is tools prefix # -ReneR confopt="--prefix=$sysroot/$prefix --enable-hacker-mode \ --with-headers=$sysroot/usr/include \$confopt" includedir="/../../usr/include" # MIPS injects -mabi - the host CC does not know about it for header gen var_append SYSCC_WRAPPER_REMOVE ' ' '-mabi*' var_append SYSCPP_WRAPPER_REMOVE ' ' '-mabi*' case "$arch" in arm64) var_append confopt ' ' --disable-mathvec ;; loongarch*) var_append CPPFLAGS ' ' -D__loongarch_double_float=1 var_append CPPFLAGS ' ' -D__loongarch_lp64=1 export CPPFLAGS ;; riscv*) var_append CPPFLAGS ' ' "-D__riscv_xlen=$((arch_sizeof_char_p * 8)) -D__riscv_atomic=1" if [ "$SDECFG_SOFTFLOAT" = 1 ]; then var_append CPPFLAGS ' ' -D__riscv_float_abi_soft=1 else var_append CPPFLAGS ' ' "-D__riscv_flen=64 -D__riscv_float_abi_double=1" fi export CPPFLAGS var_append SYSGCC_WRAPPER_INSERT ' ' $CPPFLAGS ;; esac else var_append confopt ' ' --with-headers=$root/usr/include fi var_append confopt ' ' --enable-kernel=2.6.32 if [ $SDECFG_SOFTFLOAT -eq 1 ]; then # Disable hardware floating point and use software floating point var_append confopt ' ' --without-fp else var_append confopt ' ' --with-fp fi # use at least "-O" when build without optimisation for debugging ... var_remove GCC_WRAPPER_INSERT ' ' -O0 var_insert GCC_WRAPPER_INSERT ' ' -O var_remove SYSGCC_WRAPPER_INSERT ' ' -O0 # can't fully strip for valgrind, needing some symbols var_remove GCC_WRAPPER_APPEND ' ' -c?:-s var_append GCC_WRAPPER_APPEND ' ' -fno-builtin-strlen case "$arch" in arm64) # configure: WARNING: mathvec is enabled but assembler does not support SVE. # configure: error: use a compatible toolchain or configure with --disable-mathvec (this results in incomplete ABI). var_remove GCC_WRAPPER_REMOVE ' ' '-march*' # gettimeofday.c:56:29: error: 'gettimeofday' alias between functions of incompatible types ... var_append confopt ' ' --disable-multi-arch ;; powerpc64) # s_modff128.c:(.text+0x0): multiple definition of `__modff128_power8' ... var_append confopt ' ' --disable-multi-arch ;; esac # glibc does not like -ffast-math var_remove GCC_WRAPPER_APPEND ' ' -ffast-math var_remove GCC_WRAPPER_INSERT ' ' -ffast-math # We must use an 'objdir' directory for building glibc # Disable glibc internal debuging but build debuging and profile # code so we can use this glibc to debug other programs. var_append confopt ' ' "--with-gnu-binutils --build=${arch_build} --host=${arch_target}" # toolchain needs some guidance when we do not yet have a compiler if atstage toolchain; then # t2 only auto adds it in the cross stage var_append confopt ' ' --cache-file=config.cache hook_add preconf 3 "echo 'libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_gcc_exceptions=yes libc_cv_arm_tls=yes libc_cv_mips_tls=yes libc_cv_asm_cfi_directive_sections=yes ac_cv_header_cpuid_h=yes libc_cv_mlong_double_128=yes libc_cv_mlong_double_128ibm=yes # ppc libc_cv_ppc_rel16=yes libc_cv_ppc_machine=yes libc_cv_sparcv8=yes libc_cv_z_relro=yes # sparc64 libc_mips_float=hard # $SDECFG_SOFTFLOAT libc_cv_no_gnu_attr_ok=yes # powerpc64le libc_cv_target_power8_ok=yes # powerpc64le libc_cv_gcc_builtin_tbegin=yes # s390 ' >> config.cache" fi if ! atstage native; then var_append confopt ' ' --without-gd [ "$SDECFG_POWERPC64_ELF_ABI" = elfv2 ] && export libc_cv_ppc64_elfv2_abi=yes elif pkginstalled libgd; then var_append confopt ' ' "--with-gd=/usr --with-gd-lib=/usr/lib --with-gd-include=/usr/include" fi # build and install the obsolete RPC code var_append confopt ' ' --enable-obsolete-rpc # control whether to include profiling support if [ $SDECFG_PKG_GLIBC_ENABLE_PROFILE = 1 ]; then var_append confopt ' ' --enable-profile else var_append confopt ' ' --disable-profile fi var_remove_regex makeopt " " "prefix=.*" var_remove_regex makeinstopt " " "prefix=.*" var_append makeopt ' ' slibdir=/\$slibdir var_append makeinstopt ' ' "slibdir=/\$slibdir install_root=\$root PERL=no" glibc_prepatch() { for tarball in `match_source_file -p ports` \ `match_source_file -p linuxthread` do tar $taropt $tarball # rename without surrounding glibc-*-version tarball=${tarball##*/} tarball=${tarball#*-} tarball=${tarball%%-*} mv glibc-${tarball}-* ${tarball} # remove CVS from the newly extracted files, glibc tries to # automatically commit newly generated files :-! find $tarball -name CVS | xargs rm -rfv done mkdir -p $root$includedir/gnu/ mkdir -p $root$libdir/pkgconfig/ if [ $pkg == glibc ]; then # touch is not enough to add it, "echo -n "" >>" neither? addStub() { for f; do dd if=/dev/null of="$f" count=0; done } addStub $root$includedir/gnu/stubs.h if [ $slibdir != lib ]; then addStub $root$includedir/gnu/stubs{,-32,-64}.h addStub $root$includedir/gnu/stubs-o32_hard.h if [ "$SDECFG_MIPS64_N32" = 1 ]; then addStub $root$includedir/gnu/stubs-{n32,n64}_hard.h fi fi fi } glibc_postmake() { if atstage toolchain; then cp -v ../include/features.h $root$includedir mkdir -p $includedir/{bits,gnu} [ -e $root$includedir/bits/stdio_lim.h ] || touch $root$includedir/bits/stdio_lim.h return fi # Misc. stuff # cp ../localedata/SUPPORTED $root/usr/share/i18n/ # at least prepare the locale dir mkdir -p $root$libdir/locale #eval $MAKE localedata/install-locales # NSCD Init script and config # cp $base/package/*/glibc/{nscd,nsswitch}.conf $root/etc/ # Install ld.so.conf # if [ "$SDECFG_MULTILIB" = 1 -a $slibdir != lib ]; then cat > $root/etc/ld.so.conf <<-EOT /$slibdir /lib /usr/$slibdir /usr/lib /usr/X11/$slibdir /usr/X11/lib /opt/*/$slibdir /opt/*/lib /usr/local/$slibdir /usr/local/lib EOT else cat > $root/etc/ld.so.conf <<-EOT /$slibdir /usr/$slibdir /usr/X11/$slibdir /opt/*/$slibdir /usr/local/$slibdir EOT fi # Move 'ldconfig' and 'sln' binaries # if [ -f "$root/usr/sbin/ldconfig" ]; then mv -v $root/usr/sbin/ldconfig $root/sbin/ldconfig fi if [ -f "$root/usr/sbin/sln" ]; then mv -v $root/usr/sbin/sln $root/sbin/sln fi # Create /lib/ld-lsb.so.1 symlink # if [ -f $root$slibdir/ld-linux-$arch_machine.so.2 ]; then ln -vfs ld-linux-$arch_machine.so.2 $root$slibdir/ld-lsb.so.1 elif [ -f $root$slibdir/ld-linux.so.2 ]; then ln -vfs ld-linux.so.2 $root$slibdir/ld-lsb.so.1 fi } # in stage 0 we only extract the headers and all is a bit easier ... if atstage toolchain; then makeopt= makeinstopt="-k cross-compiling=yes install-headers" fi [[ $libdir == *lib ]] && slibdir=lib || slibdir="${libdir##*/}" if atstage cross; then # hotfix gclibc-2.24 :1:19: fatal error: cstdlib: No such file or directory CXX= fi hook_add prepatch 3 "glibc_prepatch" hook_add postmake 5 "glibc_postmake"