Skip to content

Commit 3751da6

Browse files
committed
scripts/bootstrap-prefix: fix linking on macOS platforms with a real /
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]>
1 parent 343d4f7 commit 3751da6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/bootstrap-prefix.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,21 @@ bootstrap_profile() {
433433
if [[ ${CHOST} == *-darwin* ]] ; then
434434
# setup MacOSX.sdk symlink for GCC, this should probably be
435435
# managed using an eselect module in the future
436+
# FWIW, just use system (/) if it seems OK, for some reason
437+
# early versions of TAPI-based SDKs did not include some symbols
438+
# like fclose, which ld64 is able to resolve from the dylibs
439+
# although they are unvisible using e.g. nm.
436440
rm -f "${ROOT}"/MacOSX.sdk
437-
local SDKPATH=$(xcrun --show-sdk-path --sdk macosx)
438-
if [[ ! -e ${SDKPATH} ]] ; then
439-
SDKPATH=$(xcodebuild -showsdks | sort -nr \
440-
| grep -o "macosx.*" | head -n1)
441-
SDKPATH=$(xcode-select -print-path)/SDKs/MacOSX${SDKPATH#macosx}.sdk
441+
local SDKPATH
442+
if [[ -e /usr/lib/libSystem.B.dylib && -d /usr/include ]] ; then
443+
SDKPATH=/
444+
else
445+
SDKPATH=$(xcrun --show-sdk-path --sdk macosx)
446+
if [[ ! -e ${SDKPATH} ]] ; then
447+
SDKPATH=$(xcodebuild -showsdks | sort -nr \
448+
| grep -o "macosx.*" | head -n1)
449+
SDKPATH=$(xcode-select -print-path)/SDKs/MacOSX${SDKPATH#macosx}.sdk
450+
fi
442451
fi
443452
( cd "${ROOT}" && ln -s "${SDKPATH}" MacOSX.sdk )
444453
einfo "using system sources from ${SDKPATH}"

0 commit comments

Comments
 (0)