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

WIP freebsd: fix sysroot layout #1412

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
43 changes: 11 additions & 32 deletions docker/freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ main() {
cd ..

curl --retry 3 -sSfL "${bsd_url}/base.txz" -O
tar -C "${td}/freebsd" -xJf base.txz ./usr/include ./usr/lib ./lib

cd binutils-build
../binutils/configure \
Expand All @@ -183,37 +182,17 @@ main() {
cd ..

local destdir="/usr/local/${target}"
cp -r "${td}/freebsd/usr/include" "${destdir}"
cp -r "${td}/freebsd/lib/"* "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libc++.so.1" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libc++.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libcxxrt.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib/libcompiler_rt.a" "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/lib{c,util,m,ssp_nonshared,memstat}.a "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/lib{rt,execinfo,procstat}.so.1 "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/libmemstat.so.3 "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/{crt1,Scrt1,crti,crtn}.o "${destdir}/lib"
cp "${td}/freebsd/usr/lib"/libkvm.a "${destdir}/lib"

local lib=
local base=
local link=
for lib in "${destdir}/lib/"*.so.*; do
base=$(basename "${lib}")
link="${base}"
# not strictly necessary since this will always work, but good fallback
while [[ "${link}" == *.so.* ]]; do
link="${link%.*}"
done

# just extra insurance that we won't try to overwrite an existing file
local dstlink="${destdir}/lib/${link}"
if [[ -n "${link}" ]] && [[ "${link}" != "${base}" ]] && [[ ! -f "${dstlink}" ]]; then
ln -s "${base}" "${dstlink}"
fi
done

ln -s libthr.so.3 "${destdir}/lib/libpthread.so"
tar -C "${destdir}" -xJf base.txz ./usr/include ./usr/lib ./lib

# gcc build needs everything in /include and /lib, and clang wants
# them in their standard locations, so we have to merge /lib and
# /usr/lib until someone fixes gcc. Further more, /usr/lib
# contains symlinks to ../../lib so /usr/lib has to be the
# physical location and /lib the symlink.
mv "${destdir}/lib"/* "${destdir}/usr/lib/"
rmdir "${destdir}/lib"
ln -sr "${destdir}/usr/lib/" "${destdir}/"
ln -sr "${destdir}/usr/include/" "${destdir}/"

cd gcc-build
../gcc/configure \
Expand Down
Loading