On Wed, Jan 29, 2025 at 4:35 PM Marc Culler <
marc....@gmail.com> wrote:
>
> Looking back at the failed command I actually think this is a clang bug which has nothing to do with GAP. The relevant option is:
> -bundle_loader /private/var/tmp/sage-10.6-current/local/bin/gap
> I think that option is broken in the latest clang.
> I think that option means that the linker should not complain about a missing symbol if that symbol is defined in the executable which loads the library, or in any library loaded by that executable. In the case of local/bin/gap I see that (of course) it loads libgap:
Why does it load libgap? That's a bug in the gap's building by Sage I
think (no idea how it happens though).
Out of the Sage tree build has the following linkage; see - no libgap linked.
% otool -L gap
gap:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 1351.0.0)
/opt/homebrew/opt/gmp/lib/libgmp.10.dylib (compatibility
version 16.0.0, current version 16.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.2.12)
/opt/homebrew/opt/readline/lib/libreadline.8.dylib
(compatibility version 8.2.0, current version 8.2.0)
as opposed to Sage's build:
% otool -L sage/local/bin/gap
sage/local/bin/gap:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 1351.0.0)
/opt/homebrew/opt/gmp/lib/libgmp.10.dylib (compatibility
version 16.0.0, current version 16.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.2.12)
/opt/homebrew/opt/readline/lib/libreadline.8.dylib
(compatibility version 8.2.0, current version 8.2.0)
/Volumes/dima/sage/local/lib/libgap.9.dylib (compatibility
version 10.0.0, current version 10.0.0)
Dima
> LC_LOAD_DYLIB: /usr/lib/libSystem.B.dylib
> LC_LOAD_DYLIB: @rpath/libgmp.10.dylib
> LC_LOAD_DYLIB: @rpath/libz.1.dylib
> LC_LOAD_DYLIB: @rpath/libreadline.8.dylib
> LC_LOAD_DYLIB: @rpath/libgap.9.dylib
> So the linker should not have complained about those missing symbols, much less have raised an error. And, in fact, there was no error on my Intel system with an older clang. However, I think that linking against libgap accomplishes the same thing, It lets the linker know that the symbol will exist when the crypting library is loaded. So I don't think that is a bad workaround, and I think it will not be necessary after the next release of XCode. GAP is doing nothing wrong, except to assume that the -bundle-loader option will work as advertised.
>
> - Marc.
>
> On Wed, Jan 29, 2025 at 3:21 PM Dima Pasechnik <
dim...@gmail.com> wrote:
>>
>>
>>
>> On 29 January 2025 14:43:17 GMT-06:00, Marc Culler <
marc....@gmail.com> wrote:
>> >On Wed, Jan 29, 2025 at 1:33 PM Dima Pasechnik <
dim...@gmail.com> wrote:
>> >
>> >>
>> >> libgap is not really involved here;
>> >>
>> >cypring's GAP kernel module
>> >> (that's what's compiled here) can be loaded either in libgap, or in
>> >> gap executable - and the latter
>> >> isn't linked to libgap.
>> >
>> >
>> >I am no expert in GAP. But the code in crypting.c references symbols which
>> >are defined in libgap. So to build crypting.so from crypting.o you have to
>> >link against libgap or something else which defines those same symbols.
>>
>> GAP does dynamic symbol resolution when it loads an extension module.
>> On macOS, GAP does not link libgap; one can check with "otool -L".
>>
>> libgap does contain the internal symbols needed for kernel extension modules available in GAP the executable, and is equally able to load a GAP kernel extension module.
>>
>> If you link a GAP kernel module to libgap, and load it into GAP, the latter will also load libgap, and the hell can potentially break loose.
>> Even if it doesn't, an extra unneeded library would be loaded.
>>
>> crypting.so, the GAP kernel extension module, normally only links to a macOS system library, and nothing else.
>>
>> Dima