Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable shared libraries with cyclic dependencies. #1949

Closed
bdbaddog opened this issue Jan 2, 2018 · 0 comments
Closed

Enable shared libraries with cyclic dependencies. #1949

bdbaddog opened this issue Jan 2, 2018 · 0 comments

Comments

@bdbaddog
Copy link
Contributor

bdbaddog commented Jan 2, 2018

This issue was originally created at: 2008-03-14 01:37:44.
This issue was reported by: manni51.
manni51 said at 2008-03-14 01:37:45

Currently SCons can't build shared libraries with cyclic dependencies.
Those libraries are commonly built in 2 steps.

SCons engine can resolve those cycles when you implement the "2 step solution"
in 2 SCons builders.

I would send you sample code for:

  • Definition of "pairs" of shared library builders for aix, hpux, sunos, win32.
    You will see the commands and link options you need.
  • A convenient interface to use the 2 builders in your SConscript files and
    handle more details of implementation.

I'm not familiar with coding standards of SCons, so there is no patch of SCons
in my code. It's python code we are using in our SConscript files.

Please let me know, if you need more information. We are using SCons for 2 years
to build our software.

gregnoel said at 2008-04-14 20:24:56

Bug party triage: Needs batch builder (issue 1086) to provide framework for
circular dependencies. Bill to collect test case, then assign to same milestone
and priority as 1086.

bdbaddog said at 2008-08-21 10:24:15

Manfred,

Can you create a small test case to illustrate this issue?
That will help is in creating a solution.

Thanks,
Bill

manni51 said at 2008-08-25 02:38:11

Created an attachment (id=484)
Sample of cyclic dependencies

manni51 said at 2008-08-25 02:41:12

Bill,
I have added a test case.
best regards, Manfred

bdbaddog said at 2008-10-28 23:14:59

Created an attachment (id=523)
Updated SConstruct to show how to create import library

bdbaddog said at 2008-10-28 23:19:59

You need to create an implementation library.
I've attached an example SConstruct to work with your sample .zip file.
Unfortunately I don't have a windows machine available at the moment.
So I can't verify that solution works. but I've based it off of some other
SConstructs I have from windows projects.
It should be close.

Take a look at:
http://msdn.microsoft.com/en-us/library/f0z8kac4(VS.71).aspx
For some more details.

Also look at the manpage for no_import_lib documentation.

I'm changing the bug back to unspecified so it will get retriaged.
I'm not sure it's a good idea to have scons unravel windows shared lib circular
dependency issues.

The thing to keep in mind is that .dll's aren't really the same animal as unix
shared libraries. Also that on windows .lib files aren't only static libraries,
they are used for unraveling circular dependencies as well.

manni51 said at 2008-10-29 02:11:50

Created an attachment (id=524)
SConstruct which solves Issue on Windows

manni51 said at 2008-10-29 02:27:53

OK. You have found a solution for MS Windows.
But this problem may also occur on HP, IBM, SUN or LINUX.
Some manufactures like "optimized" portability of shared libraries.
Means a shared libraries does not only know its dependence of libc, libm, libC etc
but also know names of other libraries needed for succesfully dynamic load of
this library. This simplifies dynamic loading of a library and shortens link
line of executables.

The commands to create shared libraries in 2 steps are different on all platforms.
If you want, I will attach these commands for HP, IBM and SUN. LINUX is
currently not investigated.

bdbaddog said at 2008-10-29 09:29:29

Manfred,

As far as I know if you want a shared library on a linux platform to depend on
another shared library, you simply add it to the list of -labc's on the link line.

If you want a general solution to what I consider a bad practice of having
shared libraries with circular dependencies, I don't think scons is the place
for it.

On the unix platform, the best way to resolve circular dependencies that I've
run into is to not create them at build time, but to register function pointers
(or equivalent) at runtime during initialization of the application.

While it is true that on each platform there are ways to tell the linker to
ignore certain unresolved symbols specifically (or all unresolved symbols), I'm
not sure this should be in scons, and instead the user can specify when needed.

That said we have had some talk on the mailing lists about abstractions with
regard to specifying a specific library to be linked to be forced to link as a
static lib, and others not. However I don't think this is equivalent.

Please attach examples for unix platforms for the issue you're trying to have
resolved.

manni51 said at 2008-10-30 02:09:17

Created an attachment (id=525)
Sample code for AIX

manni51 said at 2008-10-30 02:09:50

Created an attachment (id=526)
Sample code for HPUX

manni51 said at 2008-10-30 02:10:18

Created an attachment (id=527)
Sample code for SUNOS

manni51 said at 2008-10-30 02:10:37

Created an attachment (id=528)
Sample code for win32

manni51 said at 2008-10-30 02:12:55

Bob,
I agree your comments about cyclic dependencies.
But customers who want to move to SCons may have cyclic dependencies in their
Source Code and do not agree to change for SCons.

My idea is, improve possibilities of SCons:

  • I found that cyclic dependence can solved by creating those libraries in 2
    steps. The results of the first step are different on each platform, the second
    step always creates the shared library.
  • I wanted SCons to define SharedLibrary builder which runs internally in 2 steps.

best regards, Manfred

gregnoel said at 2008-11-06 15:54:26

Bug party triage. Outside SCons' scope.

manni51 attached cycle_dependency.zip at 2008-08-25 02:38:11.

Sample of cyclic dependencies

bdbaddog attached SConstruct at 2008-10-28 23:14:59.

Updated SConstruct to show how to create import library

manni51 attached SConstruct_new at 2008-10-29 02:11:50.

SConstruct which solves Issue on Windows

manni51 attached AIX_sample_python_code.py at 2008-10-30 02:09:17.

Sample code for AIX

manni51 attached HPUX_sample_python_code.py at 2008-10-30 02:09:50.

Sample code for HPUX

manni51 attached SUNOS_sample_python_code.py at 2008-10-30 02:10:18.

Sample code for SUNOS

manni51 attached Win32_sample_python_code.py at 2008-10-30 02:10:37.

Sample code for win32

gregnoel said this issue depends on #1086 at 2008-04-14 20:24:56.

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

No branches or pull requests

1 participant