Skip to content

Commit

Permalink
scripts/bootstrap-prefix: fix linking on macOS platforms with a real /
Browse files Browse the repository at this point in the history
Systems that just have /usr/lib populated by dylibs and /usr/include can
just use that instead of an SDK, which is safer under certain
conditions.  A knowledgable user can modify the symlink easily to use
an SDK or something else in this case.

Signed-off-by: Fabian Groffen <[email protected]>
  • Loading branch information
grobian committed Jan 27, 2024
1 parent 343d4f7 commit 3751da6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/bootstrap-prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,21 @@ bootstrap_profile() {
if [[ ${CHOST} == *-darwin* ]] ; then
# setup MacOSX.sdk symlink for GCC, this should probably be
# managed using an eselect module in the future
# FWIW, just use system (/) if it seems OK, for some reason
# early versions of TAPI-based SDKs did not include some symbols
# like fclose, which ld64 is able to resolve from the dylibs
# although they are unvisible using e.g. nm.
rm -f "${ROOT}"/MacOSX.sdk
local SDKPATH=$(xcrun --show-sdk-path --sdk macosx)
if [[ ! -e ${SDKPATH} ]] ; then
SDKPATH=$(xcodebuild -showsdks | sort -nr \
| grep -o "macosx.*" | head -n1)
SDKPATH=$(xcode-select -print-path)/SDKs/MacOSX${SDKPATH#macosx}.sdk
local SDKPATH
if [[ -e /usr/lib/libSystem.B.dylib && -d /usr/include ]] ; then
SDKPATH=/
else
SDKPATH=$(xcrun --show-sdk-path --sdk macosx)
if [[ ! -e ${SDKPATH} ]] ; then
SDKPATH=$(xcodebuild -showsdks | sort -nr \
| grep -o "macosx.*" | head -n1)
SDKPATH=$(xcode-select -print-path)/SDKs/MacOSX${SDKPATH#macosx}.sdk
fi
fi
( cd "${ROOT}" && ln -s "${SDKPATH}" MacOSX.sdk )
einfo "using system sources from ${SDKPATH}"
Expand Down

0 comments on commit 3751da6

Please sign in to comment.