Hi!

I'm trying to deploy a CHICKEN application as a self-contained macOS app
bundle, but I'm running into issues with module loading at runtime. I'd
appreciate any guidance on the correct approach.

The Setup:

- macOS (ARM64)
- CHICKEN 5.4.0
- Application with ~25 custom Scheme modules
- Dependencies on several eggs: srfi-1, srfi-4, srfi-13, srfi-18, medea,
http-client, sqlite3, etc.

How I'm building:

Each module is compiled as a unit:

    csc -c -J -unit mymodule mymodule.scm

The main app links everything together:

    csc -uses mymodule1 -uses mymodule2 ... app.scm -o app

This produces a working binary that runs fine from the project directory.

The Problem:

When I bundle the app and run it from a different location (e.g., via "open
MyApp.app" or from /tmp), I get:

    Error: cannot load extension: models

        Call history:
        video-window.scm:11: chicken.load#load-extension
        ...

The error occurs for my custom modules (like "models"), not for eggs.

What I've tried:

1. "-static" flag - The deployment docs say this isn't supported on macOS,
and indeed it produces a corrupted binary.
2. Copying .import.scm files to the bundle - No effect; CHICKEN still tries
to load extensions.
3. Compiling .import.scm to .import.so and copying to bundle - Same error.
4. Copying egg .so and .import.so files to bundle + setting
CHICKEN_REPOSITORY_PATH - The eggs are found, but my modules still fail
with "cannot load extension."
5. Using -private-repository - Same result.
6. Using -link for eggs - This embeds egg code, but CHICKEN still needs
import files at runtime.
7. Using -deployed - This causes linker errors (undefined symbol:
_C_models_toplevel).

My understanding of the issue:

With -uses, the module code is statically linked into the binary and the
toplevel runs at startup. However, when another module does (import
mymodule), CHICKEN's runtime still calls load-extension looking for
mymodule.so, which doesn't exist because the code is embedded in the binary.

For eggs, this works because the .so files exist in the repository. For my
modules, there are no .so files - only .o files that are linked into the
binary.

Questions:

1. What is the correct way to deploy a CHICKEN application with custom
modules on macOS?
2. Should I be creating .so files for my modules in addition to linking
them with -uses? If so, how do I handle inter-module dependencies?
3. Is there a way to tell CHICKEN at runtime that certain modules are
already loaded and don't need dynamic loading?
4. Am I missing something fundamental about how -uses and the module system
interact at runtime?

Any pointers to documentation, examples, or previous discussions about
macOS deployment would be very helpful.

Thanks in advance!
Rolando

Reply via email to