Skip to content

Commit 0093a58

Browse files
committed
contrib: guix: More robust search paths, add checks
- store_path() previously only worked for cross compilation packages, we remove this assumption here - Add CROSS_GCC_LIB variable which points to where gcc libs/headers are located - Add gcc libs/headers to our CROSS_*_PATH environment variables - Check that all directories in CROSS_*_PATH are sane
1 parent 5e20238 commit 0093a58

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

contrib/guix/libexec/build.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,38 @@ fi
3030
# Given a package name and an output name, return the path of that output in our
3131
# current guix environment
3232
store_path() {
33-
grep --extended-regexp "/[^-]{32}-${1}-cross-${HOST}-[^-]+${2:+-${2}}" "${GUIX_ENVIRONMENT}/manifest" \
33+
grep --extended-regexp "/[^-]{32}-${1}-[^-]+${2:+-${2}}" "${GUIX_ENVIRONMENT}/manifest" \
3434
| head --lines=1 \
3535
| sed --expression='s|^[[:space:]]*"||' \
3636
--expression='s|"[[:space:]]*$||'
3737
}
3838

3939
# Determine output paths to use in CROSS_* environment variables
40-
CROSS_GLIBC="$(store_path glibc)"
41-
CROSS_GLIBC_STATIC="$(store_path glibc static)"
42-
CROSS_KERNEL="$(store_path linux-libre-headers)"
43-
CROSS_GCC="$(store_path gcc)"
40+
CROSS_GLIBC="$(store_path glibc-cross-${HOST})"
41+
CROSS_GLIBC_STATIC="$(store_path glibc-cross-${HOST} static)"
42+
CROSS_KERNEL="$(store_path linux-libre-headers-cross-${HOST})"
43+
CROSS_GCC="$(store_path gcc-cross-${HOST})"
44+
CROSS_GCC_LIBS=( "${CROSS_GCC}/lib/gcc/${HOST}"/* ) # This expands to an array of directories...
45+
CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one)
4446

4547
# Set environment variables to point Guix's cross-toolchain to the right
4648
# includes/libs for $HOST
47-
export CROSS_C_INCLUDE_PATH="${CROSS_GCC}/include:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include"
48-
export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include"
49-
export CROSS_LIBRARY_PATH="${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib:${CROSS_GCC}/lib:${CROSS_GCC}/${HOST}/lib:${CROSS_KERNEL}/lib"
49+
#
50+
# NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because
51+
# the limits.h in it is missing a '#include_next <limits.h>'
52+
#
53+
export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include"
54+
export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}"
55+
export CROSS_LIBRARY_PATH="${CROSS_GCC}/lib:${CROSS_GCC}/${HOST}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib"
56+
57+
# Sanity check CROSS_*_PATH directories
58+
IFS=':' read -ra PATHS <<< "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
59+
for p in "${PATHS[@]}"; do
60+
if [ ! -d "$p" ]; then
61+
echo "'$p' doesn't exist or isn't a directory... Aborting..."
62+
exit 1
63+
fi
64+
done
5065

5166
# Disable Guix ld auto-rpath behavior
5267
export GUIX_LD_WRAPPER_DISABLE_RPATH=yes

0 commit comments

Comments
 (0)