[Scons-users] Shared Versioned Libraries Problems
Russell, J.J.
russell at slac.stanford.edu
Wed May 14 12:22:27 EDT 2014
I have two problems when building the versioned shared libraries.
a) Unnecessary rebuilds
A rebuild happens immediately after a successful build)
This does not happen in non-versioned shareable builds/rebuilds
b) The --clean operation is suspicious/wrong
The details depend on whether the shareable is built in the 'natural' directory or whether the shareable target is specified as an absolute path.
The former happens in either case, but the --clean operation behaves differently:
a) When building the target in the 'natural directory',
the --clean works as expected,
but the messages indicating which files have been removed are erroneous
b) When building with the target specified as an absolute path,
the messages are erroneous and the --clean is incomplete
Here is the toy example:
example3/
| SConstruct
| pkg/
| | src/
| | | SConscript
| | | foo.c
I) NATURAL BUILD
The SConstruct file is:
env = Environment ()
env.SConscript ('pkg/src/SConscript', variant_dir = 'pkg/build', exports = 'env', duplicate = 0)
and the SConscript file is:
Import ('env')
obj = env.SharedObject ('foo.c')
so = env.SharedLibrary (obj, SHLIBVERSION = '1.2.3')
Building it produces the expected results
> scons -Q
gcc -o pkg/build/foo.os -c -fPIC pkg/src/foo.c
gcc -o pkg/build/libfoo.so.1.2.3 -shared -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1 pkg/build/foo.os
with the 'pkg/build' directory containing the expected files and links
> ls pkg/build
foo.os libfoo.so@ libfoo.so.1@ libfoo.so.1.2.3*
However, following this with an immediate rebuild produces an unnecessary rebuild
> scons -Q
> gcc -o pkg/build/libfoo.so.1.2.3 -shared -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1 pkg/build/foo.os
...and, the --clean, even though it does the right thing (i.e. all links/files have been removed), has suspicious looking output
> scons -Q --clean
Removed pkg/build/foo.os
Removed pkg/build/libfoo.so.1.2.3 <--- Duplicated
Removed pkg/build/libfoo.so.1.2.3 <---
Removed pkg/build/libfoo.so.1
II) ABSOLUTE TARGET BUILD
The SConstruct file is unchanged, but the SConscript file is modified to specify the target as an absolute path:
Import ('env')
obj = env.SharedObject ('foo.c')
so = env.SharedLibrary ('#build/libfoo.so', obj, SHLIBVERSION = '1.2.3')
Building:
> scons -Q
gcc -o pkg/build/foo.os -c -fPIC pkg/src/foo.c
gcc -o build/libfoo.so.1.2.3 -shared -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1 pkg/build/foo.os
with the expected files and links:
> ls build/
libfoo.so@ libfoo.so.1@ libfoo.so.1.2.3*
However the clean is wrong:
> scons -Q --clean
Removed pkg/build/foo.os
Removed build/libfoo.so.1.2.3
With the shareable and one link still lingering...
> ls build/
libfoo.so.1@ libfoo.so.1.2.3*
Note that even the one file (libfoo.so.1.2.3) it claimed to remove is still there, while the link 'libfoo.so' has been removed.
JJRussell
PS: While I send mail directly to scons-users at scons.org, what is the proper way to reply to a thread? You have a tough job fielding all these questions and do an admirable job, if there are a set of rules or general protocols that make your life easier, I would be glad to follow them.
Dr. James J. Russell
Stanford Linear Accelerator Center
650-926-2583
russell at slac.stanford.edu
More information about the Scons-users
mailing list