Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw-w64-riscv64-unknown-elf-newlib: Add support for 'ucrt64' and #13403

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions mingw-w64-riscv64-unknown-elf-newlib/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

_realname=newlib
_target=riscv64-unknown-elf
_gccver=10.1.0
_gccver=12.1.0

pkgbase=mingw-w64-${_target}-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_target}-${_realname}")
pkgver=3.3.0
pkgrel=2
pkgrel=3
pkgdesc='GNU Tools for RISC-V Embedded Processors - Newlib (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
url="https://sourceware.org/newlib/"
license=('Various')
groups=("${MINGW_PACKAGE_PREFIX}-${_target}-toolchain")
depends=("${MINGW_PACKAGE_PREFIX}-${_target}-binutils")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
options=('staticlibs' '!strip' '!emptydirs')
source=(
"https://sourceware.org/pub/newlib/newlib-${pkgver}.tar.gz"
"https://ftp.gnu.org/gnu/gcc/gcc-${_gccver}/gcc-${_gccver}.tar.xz"
)
sha256sums=(
'58dd9e3eaedf519360d92d84205c3deef0b3fc286685d1c562e245914ef72c66'
'b6898a23844b656f1b68691c5c012036c2e694ac4b53a8918d4712ad876e7ea2'
'62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b'
)
noextract=("newlib-${pkgver}.tar.gz")

Expand All @@ -34,19 +34,19 @@ prepare() {
tar -xf newlib-${pkgver}.tar.gz

cd ${srcdir}/gcc-${_gccver}
mkdir gcc-build-${MINGW_CHOST}
mkdir gcc-install-${MINGW_CHOST}
mkdir gcc-build-${MSYSTEM}
mkdir gcc-install-${MSYSTEM}

cd ${srcdir}/newlib-${pkgver}
mkdir {newlib,nano}-build-${MINGW_CHOST}
mkdir {newlib,nano}-build-${MSYSTEM}
}

# Newlib is required to build GCC, but GCC is also required to compile newlib
# So we must build a minimal GCC first, to avoid the circular dependency
_build_gcc() {
cd ${srcdir}/gcc-${_gccver}/gcc-build-${MINGW_CHOST}
cd ${srcdir}/gcc-${_gccver}/gcc-build-${MSYSTEM}

cp -a ${MINGW_PREFIX}/${_target} ${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}
cp -a ${MINGW_PREFIX}/${_target} ${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}

local _GCC_LDFLAGS="${LDFLAGS} -Wl,--disable-dynamicbase"
if [ "${CARCH}" = 'x86_64' ]; then
Expand Down Expand Up @@ -80,21 +80,21 @@ _build_gcc() {
--enable-multilib \
--with-host-libstdcxx="-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm" \
--with-sysroot=${MINGW_PREFIX} \
--with-build-sysroot=${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST} \
--with-build-sysroot=${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM} \
--with-build-time-tools=${MINGW_PREFIX}/${_target}/bin \
LDFLAGS="${_GCC_LDFLAGS}"

make all-gcc
make DESTDIR=${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST} install-gcc
make DESTDIR=${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM} install-gcc
}

build() {
_build_gcc

cd ${srcdir}/newlib-${pkgver}/newlib-build-${MINGW_CHOST}
cd ${srcdir}/newlib-${pkgver}/newlib-build-${MSYSTEM}

../configure \
PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}" \
PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}" \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--target=${_target} \
Expand All @@ -104,12 +104,12 @@ build() {
--enable-newlib-io-c99-formats \
--enable-newlib-register-fini \
--disable-nls
make PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}"
make PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}"

cd ${srcdir}/newlib-${pkgver}/nano-build-${MINGW_CHOST}
cd ${srcdir}/newlib-${pkgver}/nano-build-${MSYSTEM}

../configure \
PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}" \
PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}" \
--build=${MINGW_CHOST} \
--host=${MINGW_CHOST} \
--target=${_target} \
Expand All @@ -125,22 +125,22 @@ build() {
--enable-newlib-nano-formatted-io \
--disable-newlib-supplied-syscalls \
--disable-nls
make PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}"
make PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}"
}

package() {
cd ${pkgdir}

cd ${srcdir}/newlib-${pkgver}/nano-build-${MINGW_CHOST}
cd ${srcdir}/newlib-${pkgver}/nano-build-${MSYSTEM}

make DESTDIR=${pkgdir} PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}" install
make DESTDIR=${pkgdir} PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}" install

find ${pkgdir} -regex ".*/lib\(c\|g\|rdimon\|gloss\)\.a" -exec rename .a _nano.a '{}' \;
install -Dm644 -t ${pkgdir}${MINGW_PREFIX}/${_target}/include/newlib-nano ${pkgdir}${MINGW_PREFIX}/${_target}/include/newlib.h

cd ${srcdir}/newlib-${pkgver}/newlib-build-${MINGW_CHOST}
cd ${srcdir}/newlib-${pkgver}/newlib-build-${MSYSTEM}

make DESTDIR=${pkgdir} PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MINGW_CHOST}/bin:${PATH}" install
make DESTDIR=${pkgdir} PATH="${srcdir}/gcc-${_gccver}/gcc-install-${MSYSTEM}/bin:${PATH}" install

find ${pkgdir}${MINGW_PREFIX}/${_target}/lib \( -name "*.a" -or -name "*.o" \) -exec ${_target}-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
}