Skip to content

Conversation

lazka
Copy link
Member

@lazka lazka commented Jul 4, 2025

wip

A test to see if we could load cairo symbols at runtime only when needed, so a pycairo doesn't need to be rebuilt if cairo is rebuilt with a different config.

I've never done something like this, so not sure how portable that all is. With some macro magic we could make it optional if that turns out to be tricky.

@lazka lazka force-pushed the dynamic-symbol-lookup branch 3 times, most recently from 99eec9d to 2b01240 Compare July 4, 2025 12:19
@lazka
Copy link
Member Author

lazka commented Jul 4, 2025

The main thing is that statically linking on non-Windows will fail with this, and I wonder if there is a way to detect that automatically.

@stuaxo
Copy link
Collaborator

stuaxo commented Jul 4, 2025

I wonder if this could solve a few issues: One I use case I think is really interesting, is having parallel builds of cairo with different --enable flags (built at the same time).

Another is cairo built in a virtualenv vs in the system.

@lazka
Copy link
Member Author

lazka commented Jul 5, 2025

Yeah, the combination of distros changing something with cairo + cached wheels from previous pycairo installs is one source of conflicts.

@lazka
Copy link
Member Author

lazka commented Jul 5, 2025

The main thing is that statically linking on non-Windows will fail with this, and I wonder if there is a way to detect that automatically.

I doesn't seem there is. So we might have to add an option to disable this in case someone wants to link statically (rare on non-Windows). On Windows we can use CAIRO_WIN32_STATIC_BUILD to detect that case, since the user is required to set that for static linking.

@eli-schwartz
Copy link

For example, vim has:

  --enable-luainterp=OPTS      Include Lua interpreter.  default=no OPTS=no/yes/dynamic
  --enable-mzschemeinterp      Include MzScheme interpreter.
  --enable-perlinterp=OPTS     Include Perl interpreter.  default=no OPTS=no/yes/dynamic
  --enable-pythoninterp=OPTS   Include Python interpreter. default=no OPTS=no/yes/dynamic
  --enable-python3interp=OPTS  Include Python3 interpreter. default=no OPTS=no/yes/dynamic
  --enable-tclinterp=OPTS      Include Tcl interpreter. default=no OPTS=no/yes/dynamic
  --enable-rubyinterp=OPTS     Include Ruby interpreter.  default=no OPTS=no/yes/dynamic

You could make it an error to static link while also setting it to dlopen? The distinguishing factor is basically "did the user set -static in LDFLAGS", right? You could check this via a cc.run() check perhaps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants