Skip to content
Tcl Source Code View Ticket
Login

View Ticket

RFE: linux : dynamic location of the tcl zipfs

Closed / Fixedf8608fc4209e5949aae34cf2a8e82bfc377e2ed3Created 5 years agoUpdated 5 years ago
Descriptionplain2021-06-09 16:15:00
bll-g7:bll$ ./linux/64/tcl/bin/tclsh
application-specific initialization failed: Can't find a usable init.tcl in the following directories: 
    /home/bll/t/localB/lib/tcl8.7 {} /home/bll/s/ballroomdj/linux/64/tcl/lib/tcl8.7 /home/bll/s/ballroomdj/linux/64/lib/tcl8.7 /home/bll/s/ballroomdj/linux/64/tcl/library /home/bll/s/ballroomdj/linux/64/library /home/bll/s/ballroomdj/linux/64/tcl8.7/library /home/bll/s/ballroomdj/linux/64/tcl8.7a5/library /home/bll/s/ballroomdj/linux/tcl8.7a5/library



This probably means that Tcl wasn't installed properly.

% exit

bll-g7:bll$ unzip -v linux/64/tcl/lib/libtcl8.7.so | grep init.tcl
   23498  Defl:N     7645  68% 2021-06-07 08:40 a8bd027e  tcl_library/init.tcl
bll-g7:bll$
Referenced by2
bllplain2021-06-09 17:35:57
I should mention that this installation is relocated.
jan.nijtmanswiki2021-06-09 19:07:39

I'm not sure something can be done here, since it's not designed to be easily relocatable. But I'll give it a try.

bllplain2021-06-09 19:19:06
Is Tcl able to determine where the shared library is located?

If relocation is not possible, I will need to know how to start Tcl such
that it can find the shared library.  TCLLIBPATH?
bllplain2021-06-10 13:29:35
I wrote a binary editor to fix the paths and adjusted some things in the
build so that this will be possible.

I really dislike hard-coded paths.
bllplain2021-06-10 13:45:52
But I can't use a binary editor written in tcl, as the relocated tcl
can't run.  Sigh.
jan.nijtmansplain2021-06-10 13:50:59
The code trying to locate the shared library where init.tcl is going to be found is here:

[https://core.tcl-lang.org/tcl/file?udc=1&ln=3911-3913&ci=tip&name=generic%2FtclZipfs.c]

You can see there is only one place being searched (on UNIX):
    CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE

This won't work if the shared library is not in CFG_RUNTIME_LIBDIR. This could be elaborated more, e.g. by looping over all paths in env(LD_LIBRARY_PATH).

For now, make sure that CFG_RUNTIME_LIBDIR during build is the actual directory where the shared library will be installed eventually.

I changed this issue into an RFE, since - actually - it's not a bug. I agree that the current search is rather limited, so it should be extended.
jan.nijtmanswiki2021-06-10 14:11:26

Even better: on Linux there is the function dladdr() which can locate the absolute path of the shared library .... That's much better than a hardcoded CFG_RUNTIME_LIBDIR!

jan.nijtmanswiki2021-06-10 15:01:32

Highly experimental solution [here]

bllplain2021-06-10 15:10:07
I got my work-arounds and binary edits all working.
My package can be installed anywhere again.

I think the use of dladdr() would be great, it would allow 
better relocatability again.

An [info tclzipfs] to display the path to the tcl zipfs would be nice.

A command line option or environment variable 
to set the location of the file containing the tcl zipfs
would be nice.  This would allow separation of the executable
and the tcl zipfs file if wanted.

re-titled the RFE.
jan.nijtmanswiki2021-06-18 19:51:15

Fixed in core-8-branch

fvogelwiki2021-06-19 10:14:36

Reopening. The fix prevents the build on Windows with MSVC or gcc:

https://github.com/tcltk/tcl/runs/2863899941?check_suite_focus=true.

https://github.com/tcltk/tcl/runs/2863900391?check_suite_focus=true

Confirmed on my setup (with MSVC) too.

jan.nijtmanswiki2021-06-19 23:24:53

Windows build fixed now. Thanks!

fvogelplain2021-06-20 07:33:40
Confirmed, thanks !
Log in (anonymous is fine) to add a comment.