Skip to content

Commit d77c2dc

Browse files
committed
Install baselayout rather than duplicating dir/symlink behaviour here
crossdev environments need to support merged-usr now, especially now that the profile can be selected. The logic around this is messy and best handled by the baselayout package when it is supported by the arch. This package now gets installed immediately before binutils. It means a few small extra files get installed, but that's a small price to pay. We could INSTALL_MASK them, but that would just add more complexity. Signed-off-by: James Le Cuirot <chewi@gentoo.org>
1 parent e76f567 commit d77c2dc

3 files changed

Lines changed: 38 additions & 70 deletions

File tree

.github/workflows/crossdev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ jobs:
6666
- target: powerpc64-unknown-linux-musl
6767
- target: powerpc64le-unknown-linux-gnu
6868
- target: riscv32-unknown-linux-gnu
69+
args: --profile default/linux/riscv/23.0/rv32/ilp32
6970
# busybox fails to build: `‘SYS_settimeofday’ undeclared`.
7071
# - target: riscv32-unknown-linux-musl
7172
- target: riscv64-unknown-linux-gnu
73+
args: --profile default/linux/riscv/23.0/rv64/lp64
7274
- target: riscv64-unknown-linux-musl
75+
args: --profile default/linux/riscv/23.0/rv64/lp64d/musl
7376
# glibc fails to build: `no support for pre-v8 sparc`.
7477
# - target: sparc-unknown-linux-gnu
7578
- target: sparc64-unknown-linux-gnu

crossdev

Lines changed: 28 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,52 +1616,6 @@ hr
16161616
xmkdir -p "${EPREFIX}"/usr/${CTARGET}
16171617
LLVM="${LLVM}" emerge-wrapper --target "${CTARGET}" --init --profile "${PROFILE}" || exit 1
16181618

1619-
#############################################################
1620-
### Create directories usually created by sys-apps/baselayout
1621-
###
1622-
### Why we do that at all:
1623-
### For multilib-aware targets (ppc64, s390x, sparc64, x86_64), Gentoo
1624-
### normally uses libdir=lib64.
1625-
### For crossdev, it means /lib and /usr/lib does not get created at all
1626-
### but gcc relies on their presence by refering to =/lib64 as
1627-
### =/usr/lib/../lib64 when builds itself (see https://bugs.gentoo.org/652724)
1628-
###
1629-
### Thus we create non-symlinked layout early.
1630-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib
1631-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib
1632-
###
1633-
### We need some special riscv sauce here similar as in baselayout. Ugly.
1634-
### step 1: set up all multilib libdirs
1635-
### step 2: set up the compat symlink of the default abi for non-multilib
1636-
case ${CTARGET} in
1637-
riscv*)
1638-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib64
1639-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib64/lp64
1640-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib64/lp64d
1641-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib64
1642-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib64/lp64
1643-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib64/lp64d
1644-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib32
1645-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib32/ilp32
1646-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/lib32/ilp32d
1647-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib32
1648-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib32/ilp32
1649-
xmkdir -p "${EPREFIX}"/usr/${CTARGET}/usr/lib32/ilp32d
1650-
;;&
1651-
riscv64*)
1652-
rmdir "${EPREFIX}"/usr/${CTARGET}/lib64/${DEFAULT_ABI}
1653-
ln -s . "${EPREFIX}"/usr/${CTARGET}/lib64/${DEFAULT_ABI}
1654-
rmdir "${EPREFIX}"/usr/${CTARGET}/usr/lib64/${DEFAULT_ABI}
1655-
ln -s . "${EPREFIX}"/usr/${CTARGET}/usr/lib64/${DEFAULT_ABI}
1656-
;;
1657-
riscv32*)
1658-
rmdir "${EPREFIX}"/usr/${CTARGET}/lib32/${DEFAULT_ABI}
1659-
ln -s ../lib "${EPREFIX}"/usr/${CTARGET}/lib32/${DEFAULT_ABI}
1660-
rmdir "${EPREFIX}"/usr/${CTARGET}/usr/lib32/${DEFAULT_ABI}
1661-
ln -s ../lib "${EPREFIX}"/usr/${CTARGET}/usr/lib32/${DEFAULT_ABI}
1662-
;;
1663-
esac
1664-
16651619
# HOSTCC is used by linux-headers to compile fixdeps program for CBUILD
16661620
if [[ "${LLVM}" == "yes" ]] ; then
16671621
cat <<-EOF > "${CONFIGROOT}/env/${CROSSDEV_OVERLAY_CATEGORY}/llvm.conf"
@@ -1706,30 +1660,31 @@ set_eopts_on_pkg_status() {
17061660
EOPTS=${EOPTS_UP}
17071661
}
17081662

1709-
doemerge() {
1663+
do_emerge_cross() {
17101664
local category="${CROSSDEV_OVERLAY_CATEGORY}"
17111665
local pn=$1
17121666
local atom="${category}/${pn}"
17131667

17141668
[[ ${pn} == "[none]" ]] && return 0
1715-
17161669
set_use ${pn} ${USE} $( [[ ${MULTILIB_USE} == "no" ]] && echo - )multilib
1670+
do_emerge "${atom}" "${CROSSDEV_OVERLAY_CATEGORY_PREFIX}${2:-${pn}}"
1671+
}
17171672

1718-
[[ ${INIT_TARGET_ONLY} == "yes" ]] && return 0
1673+
do_emerge() {
1674+
local atom=$1
1675+
local pn=${1##*/}
17191676

1720-
local logfile=${PORT_LOGDIR}/${category}
1721-
[[ -z $2 ]] \
1722-
&& logfile=${logfile}-${pn}.log \
1723-
|| logfile=${logfile}-$2.log
1677+
[[ ${INIT_TARGET_ONLY} == "yes" ]] && return 0
17241678

1679+
local logfile="${PORT_LOGDIR}/cross-${CTARGET}-${2:-${pn}}.log"
17251680
einfo "Log: ${logfile}"
1726-
ebegin "Emerging ${CROSSDEV_OVERLAY_CATEGORY_PREFIX}${2:-${pn}}"
1681+
ebegin "Emerging ${2:-${pn}}"
17271682

17281683
if has -v ${UOPTS} || has -p ${UOPTS} || has -vp ${UOPTS} || has -pv ${UOPTS} ; then
17291684
SHOW_FAIL_LOG="no"
1730-
emerge ${atom} ${EOPTS} 2>&1 | tee "${logfile}"
1685+
${EMERGE:-emerge} ${atom} ${EOPTS} 2>&1 | tee "${logfile}"
17311686
else
1732-
emerge ${atom} ${EOPTS} >& "${logfile}"
1687+
${EMERGE:-emerge} ${atom} ${EOPTS} >& "${logfile}"
17331688
fi
17341689
local _pipestatus=${PIPESTATUS[*]}
17351690
if [[ "${_pipestatus// /}" -ne 0 ]] ; then
@@ -1759,7 +1714,7 @@ doemerge() {
17591714
# gcc wanting updated mpfr/gmp). Don't use --oneshot anymore to
17601715
# follow normal emerge behavior; people can pass the -1 to portage
17611716
# themselves if they want that.
1762-
EOPTS_DEF="${UOPTS}"
1717+
EOPTS_DEF="--buildpkg=n ${UOPTS}"
17631718
EOPTS_UP="${EOPTS_DEF} -u"
17641719
EOPTS=${EOPTS_UP}
17651720
# keep things like --ask from screwing us up
@@ -1794,6 +1749,10 @@ USE="${USE} -selinux"
17941749

17951750
if ! ex_fast ; then
17961751

1752+
# stage 0: baselayout
1753+
PORTAGE_CONFIGROOT="${EROOT}/usr/${CTARGET}" portageq best_visible "${EROOT}/usr/${CTARGET}" sys-apps/baselayout >/dev/null &&
1754+
USE+=" build" EMERGE="${CTARGET}-emerge" do_emerge sys-apps/baselayout
1755+
17971756
# stage 0: binutils
17981757
if [[ "${LLVM}" == "yes" ]] ; then
17991758
if ! portageq has_version / "llvm-core/llvm" ; then
@@ -1826,9 +1785,9 @@ if ! ex_fast ; then
18261785

18271786
[[ ${supported_arch} -eq 0 ]] && die "Target architecture not supported by installed LLVM toolchain"
18281787

1829-
USE="${CUSE}" doemerge ${CPKG}
1788+
USE="${CUSE}" do_emerge_cross ${CPKG}
18301789
else
1831-
USE="${BUSE}" doemerge ${BPKG}
1790+
USE="${BUSE}" do_emerge_cross ${BPKG}
18321791
fi
18331792

18341793
# stage1: bare C compiler
@@ -1839,7 +1798,7 @@ if ! ex_fast ; then
18391798
# install kernel headers (since the C library often uses them)
18401799
USE="${KUSE} ${USE} headers-only" \
18411800
CROSSCOMPILE_OPTS="headers-only" \
1842-
doemerge ${KPKG} ${KPKG}-quick
1801+
do_emerge_cross ${KPKG} ${KPKG}-quick
18431802

18441803
if [[ -n ${LPKG} ]] ; then
18451804
# install C library headers
@@ -1849,7 +1808,7 @@ if ! ex_fast ; then
18491808
USE="${LUSE} ${USE} ${LUSE_DISABLE} headers-only" \
18501809
CROSSCOMPILE_OPTS="headers-only" \
18511810
EOPTS="${EOPTS} --nodeps" \
1852-
doemerge ${LPKG} ${LPKG}-headers
1811+
do_emerge_cross ${LPKG} ${LPKG}-headers
18531812
fi
18541813
fi
18551814

@@ -1858,11 +1817,11 @@ if ! ex_fast ; then
18581817
# Compile compiler-rt
18591818
USE="${RUSE} ${USE}" \
18601819
CROSSCOMPILE_OPTS="" \
1861-
doemerge ${RPKG}
1820+
do_emerge_cross ${RPKG}
18621821
else
18631822
USE="${GUSE} ${USE} ${GUSE_DISABLE_STAGE_1}" \
18641823
CROSSCOMPILE_OPTS="" \
1865-
doemerge ${GPKG} ${GPKG}-stage1
1824+
do_emerge_cross ${GPKG} ${GPKG}-stage1
18661825
fi
18671826

18681827
fi
@@ -1873,7 +1832,7 @@ if ! ex_fast ; then
18731832

18741833
USE="${KUSE} ${USE}" \
18751834
CROSSCOMPILE_OPTS="" \
1876-
doemerge ${KPKG}
1835+
do_emerge_cross ${KPKG}
18771836
fi
18781837

18791838
# stage3: full C library (headers/libs/etc...)
@@ -1884,24 +1843,24 @@ if ! ex_fast ; then
18841843

18851844
USE="${LUSE} ${USE} ${LUSE_DISABLE}" \
18861845
CROSSCOMPILE_OPTS="" \
1887-
doemerge ${LPKG}
1846+
do_emerge_cross ${LPKG}
18881847
fi
18891848

18901849
# stage4: full compiler (C/C++/etc...)
18911850
if is_s4 && [[ "${LLVM}" != "yes" ]] ; then
18921851
EOPTS="${EOPTS_UP} --newuse" \
18931852
USE="${GUSE} ${USE} ${GUSE_DISABLE_STAGE_2}" \
1894-
doemerge ${GPKG} ${GPKG}-stage2
1853+
do_emerge_cross ${GPKG} ${GPKG}-stage2
18951854
fi
18961855
fi
18971856

18981857
# all the extra things (like debuggers)
18991858
EOPTS="${EOPTS_UP} --newuse"
1900-
ex_gcc && USE="${GUSE} ${USE}" doemerge ${GPKG} ${GPKG}-extra
1901-
ex_gdb && USE="${DUSE} ${USE}" doemerge ${DPKG}
1859+
ex_gcc && USE="${GUSE} ${USE}" do_emerge_cross ${GPKG} ${GPKG}-extra
1860+
ex_gdb && USE="${DUSE} ${USE}" do_emerge_cross ${DPKG}
19021861
if ex_pkgs ; then
19031862
for pkg in "${XPKGS[@]}" ; do
1904-
doemerge "${pkg#*/}"
1863+
do_emerge_cross "${pkg#*/}"
19051864
done
19061865
fi
19071866

scripts/container_test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Options:
99
--skip-system Skip emerging the @system set after setting up crossdev.
1010
--tag <tag> Specify the container tag to use. Default is 'latest'.
1111
--target <target> Specify the target architecture for crossdev. Required.
12+
--profile <profile> Specify the Portage profile for crossdev. Default is 'embedded'.
1213
-h, --help Show this help message and exit.
1314
1415
Environment Variables:
@@ -55,6 +56,7 @@ CONTAINER_URI=${CONTAINER_URI:-"docker.io/gentoo/stage3"}
5556
CONTAINER_TAG="latest"
5657
EMERGE_SYSTEM=1
5758
TOPDIR=$(git rev-parse --show-toplevel)
59+
unset PROFILE
5860

5961
remove_container || true
6062
trap "remove_container" EXIT
@@ -65,6 +67,10 @@ while [[ $# -gt 0 ]]; do
6567
print_help
6668
exit 0
6769
;;
70+
--profile)
71+
PROFILE="$2"
72+
shift 2
73+
;;
6874
--skip-system)
6975
EMERGE_SYSTEM=0
7076
shift 1
@@ -97,7 +103,7 @@ run_in_container getuto
97103
run_in_container emerge --getbinpkg app-eselect/eselect-repository sys-apps/config-site
98104
run_in_container make install
99105
run_in_container eselect repository create crossdev
100-
run_in_container crossdev --show-fail-log --target "${TARGET}"
106+
run_in_container crossdev --show-fail-log --target "${TARGET}" ${PROFILE+--profile "${PROFILE}"}
101107
if [[ "${EMERGE_SYSTEM}" -eq 1 ]]; then
102108
run_in_container "${TARGET}-emerge" @system
103109
fi

0 commit comments

Comments
 (0)