koga: make ninja install produce a usable libclasp.pc - #1822
Open
dg1sbg wants to merge 2 commits into
Open
Conversation
Every other install path defaults under /usr/local, but pkgconfig-path defaulted to /usr/lib/pkgconfig/. On macOS Catalina and later that directory sits on the sealed, read-only system volume and is protected by System Integrity Protection, so `ninja install` fails with install: /usr/lib/pkgconfig/INS@na30mW: Operation not permitted and sudo does not help -- root has no access there either. This left `ninja install` unable to run to completion on any recent Mac. /usr/local/lib/pkgconfig/ is in pkg-config's default search path on both Linux and macOS and matches bin-path, lib-path, dylib-path and share-path, so a default install now lands entirely under one prefix.
The installed pkg-config file passed an empty string as its Libs prefix, so it read Libs: -lclasp with no library search path, and anything built against it failed at link time with `ld: library 'clasp' not found`. The per-variant .pc written into the build tree does pass the variant ldflags, so only the installed copy was affected. Adding -L alone is not enough on macOS: libclasp.dylib has an @rpath install name, so a consumer that links successfully still dies at startup with "Library not loaded: @rpath/libclasp.dylib ... no LC_RPATH's found". Emit -Wl,-rpath as well so the flags work end to end. dylib-path had no entry in *root-paths* -- :install-bin, :install-share and :install-lib were all present -- so add :install-dylib alongside them and use it here. This deliberately uses the unresolved install path rather than the --package-path-resolved one, matching :install-share directly above: a staged package must still describe where the files will finally live.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent defects in koga's pkg-config handling, one commit each. Together they mean
ninja installcannot complete on macOS, and that the pkg-config file it installs cannot link anything on any platform.1.
pkgconfig-pathdefaults into a SIP-protected directorybin-path,lib-path,dylib-pathandshare-pathall default under/usr/local, butpkgconfig-pathdefaults to/usr/lib/pkgconfig/. On macOS Catalina and later/usr/libis on the sealed read-only system volume and is protected by System Integrity Protection, soninja -C build installends with:sudodoes not help — theEPERMis SIP, not ownership; root has no access to that directory either. Soninja installcannot run to completion out of the box on any recent Mac.Changed the default to
/usr/local/lib/pkgconfig/, which is in pkg-config's defaultpc_pathon both Linux and macOS and is consistent with the other four install paths.2. The installed
libclasp.pccannot link anythingprint-prologue (:libclasp-pc)passed""wherewrite-pcexpects theLibsprefix, producingLibs: -lclaspwith no library search path:The per-variant
.pc(:libclasp-pc-variant) does pass the variant ldflags, so only the installed copy was affected.-Lalone is not sufficient on macOS.otool -Dshowslibclasp.dylib's install name is@rpath/libclasp.dylib, so a consumer that now links successfully still dies at startup:so the fix emits
-Wl,-rpath,as well, and the flags work end to end.dylib-pathhad no entry in*root-paths*—:install-bin,:install-shareand:install-libare all present — so this adds:install-dylibalongside them. It deliberately uses the unresolved install path rather than the--package-path-resolved one, matching:install-sharedirectly above: a staged package must still describe where the files will finally live.One point you may want to push back on: putting
-Wl,-rpath,inLibs:is the pragmatic fix. The alternative is to give the installed dylib an absolute-install_nameso no rpath is needed at all, but that is a larger change and would diverge from the build tree, which relies on@rpath. Happy to split the rpath half out or rework it that way if you prefer.Testing
macOS 15 / Apple Silicon,
:build-mode :native, install prefix/opt/clasp.Before:
ninja installfails on the.pc; with the file installed by hand,pkg-config --libs libclaspyields-lclaspand linking fails withld: library 'clasp' not found.After:
ninja -C build installthen completes with exit 0, and a second run reportsno work to do.The new default was verified independently by removing the local
config.sexpoverride and re-running./koga:build.ninjathen targets/usr/local/lib/pkgconfig/libclasp.pc.Neither change triggers a rebuild. Regenerating with
./kogatouches onlybuild.ninja— koga's timestamp-preserving output streams leaveconfig.hand the generated headers byte-identical, soninja -n installafterwards shows a single pending edge.