PKGNAME=glibc
PKGSEC=libs
PKGDEP="linux+api libxcrypt"
PKGRECOM__LOONGARCH64="glibc-legacy"
PKGRECOM__LOONGARCH64_NOSIMD="${PKGRECOM__LOONGARCH64}"
PKGPROV="libc-bin_spiral"
PKGDES="GNU C Library"

AUTOTOOLS_AFTER=(
    '--libexecdir=/usr/lib'
    '--with-headers=/usr/include'
    '--with-bugurl=https://github.com/AOSC-Dev/aosc-os-abbs/issues'
    '--disable-add-ons'
    '--enable-kernel=4.19.0'
    '--disable-profile'
    '--disable-tunables'
    '--enable-lock-elision'
    '--disable-multi-arch'
    '--disable-werror'
    '--enable-static'
    '--disable-multi-arch'
    '--with-__thread'
    '--enable-obsolete-nsl'
    '--enable-obsolete-rpc'
    '--enable-bind-now'
    '--enable-stackguard-randomization'
    '--enable-stack-protector=strong'
    '--enable-fortify-source=3'
    '--disable-crypt'
)
# Note: For control-flow protection via Intel CET.
AUTOTOOLS_AFTER__AMD64=(
    "${AUTOTOOLS_AFTER[@]}"
    '--enable-cet'
)
# Note: For MTE (Memory Tagging Extension) support.
AUTOTOOLS_AFTER__ARM64=(
    "${AUTOTOOLS_AFTER[@]}"
    '--enable-memory-tagging'
)

# Note: Needed for compilers and debuggers.
NOSTATIC=0

# /usr/bin/ld: /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/build/elf/librtld.os: in function `_dl_open_check':
# /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/elf/../sysdeps/x86/dl-prop.h:80:(.text+0xb308): undefined reference to `_dl_cet_open_check'
# /usr/bin/ld: /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/build/elf/librtld.os: in function `_dl_start_user':
# (.text+0x1c374): undefined reference to `_dl_cet_setup_features'
# /usr/bin/ld: /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/build/elf/librtld.os: in function `_rtld_main_check':
# /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/elf/../sysdeps/x86/dl-prop.h:71:(.text+0x1f611): undefined reference to `_dl_cet_check'
# /usr/bin/ld: /var/cache/acbs/build/acbs.qw8_5fk4/glibc-2.40/build/elf/ld.so.new: hidden symbol `_dl_cet_open_check' isn't defined
# /usr/bin/ld: final link failed: bad value
# collect2: error: ld returned 1 exit status
# Using hardening switches provided by the build system from glibc.
AB_FLAGS_FTF=0
AB_FLAGS_SSP=0
AB_FLAGS_SPECS=0

# FIXME: Causes linkage failure (2.38).
# /nscd/gai.o: in function `cancel_handler':
# /nscd/../sysdeps/unix/sysv/linux/check_pf.c:300:(.text+0x2570): undefined reference to `_Unwind_Resume'
# ...
# /usr/bin/ld: .../nscd/gai.o:(.data.rel.local.DW.ref.__gcc_personality_v0[DW.ref.__gcc_personality_v0]+0x0):
# undefined reference to `__gcc_personality_v0'
AB_FLAGS_EXC=0

# Note: -O3 bloats binary sizes, we don't want that for Afterglow.
AB_FLAGS_O3__RETRO=0

# Note: Enable building for all HWCAPS microarchitectures.
AB_HWCAPS=1

# error: "SIG_BLOCK" is not defined [-Werror=undef]
# LTO breaks build with a warning-as-error, not taking the chances though.
NOLTO=1

# Unset t64 macros during build.
AB_FLAGS_Y2038=0

# CAUTION: possible hazard while downgrading
# dpkg tries to run the postrm script after glibc in HWCAPS subdirectories
# has been removed, leading to a symbol lookup error.
# Since Bash is fork()ed and exec()ed, the dynamic linker still wants to
# load the non-existant libc in HWCAPS subdirectories. We tried various ways
# to address this, including invaiidating ld.so.cache, using LD_PRELOAD, etc.
# but all of these failed.
# So we will skip installing an empty postrm script, which prevents dpkg from
# running it.
# Without the postrm script, the downgrade process works fine.
AB_SKIP_MAINTSCRIPTS=('postrm')

LOCALEGENVER="20160914"

# Merges locale-gen at Core 4.
PKGREP="locale-gen<=20160429"
PKGBREAK="locale-gen<=20160429 glibc-legacy<=1"

# Needed by Afterglow, whereas FAIL_ARCH defaults to mainline-only.
FAIL_ARCH="!(mainline|retro)"
