How to downgrade tcl_platform(osVersion) to 6.1? - tcl

My tcl platform(osVersion) is v6.2
% puts $tcl_platform(osVersion)
6.2
How to downgrade tcl_platform(osVersion) to v6.1?
Thank you.
I try to find activetcl v8.5 on internet but the old version all links are invalid...

That value, which describes the version of the operating system that is running the script, is read out of a platform-specific location in your OS during the initialisation of an interpreter (technically, it is copied from data determined during startup of the first Tcl interpreter in a process, where that data is held in a location invisible to you). It is then free to be read or altered by your code... with whatever consequences that may entail.
Permanently changing that value is done by changing what OS is installed. That's totally out of scope for what an ordinary user script can do!
Tcl's implementation mostly doesn't use the OS version. It cares far more about whether API capabilities are exposed to it, and those are almost always at the more granular level of general platform (or transparently adapted around).

Related

Get configuration flags of a compiled tcl

I've a compiled tcl version 8.4 and want to check if --enable-threads was set when it was compiled or not ?
or if there is any another way to get the list of all passed flags.
Thanks
IMPORTANT NOTE!
Tcl 8.4 is out of long-term support. Absolutely no further changes will be forthcoming to it, not even if a catastrophic security error is discovered; if your issue isn't fixed by 8.4.20, you'll need to go to 8.5 or later. We don't know of any such security issues, but we aren't looking and won't fix them if they're found.
Support here is only on a “because we feel nice” basis. You should not create new work based on 8.4.
The global array element tcl_platform(threaded) is defined and set to 1 when the currently-used Tcl library is built with thread support. This is true from at least Tcl 8.4 onwards. Here's how to reliably get a nice boolean value you can check:
set isThreaded [expr {
[info exist tcl_platform(threaded)] && $tcl_platform(threaded)
}]
NB: Some platforms are virtually always threaded anyway (because of how they work internally; this is the case with Windows and OSX if I remember right). Future versions of Tcl (8.7 onwards) will default to threaded everywhere; this will be the only supported build mode from 9.0 on. You'll still need the Thread package to work with threads in your script, but that's a standard extension these days.
Starting with 8.5 (TIP 59), one can retrieve details about the build configuration using tcl::pkgconfig:
% tcl::pkgconfig get threaded
1
Note that this is not available in Tcl 8.4; if available, one does not have to protect against requesting an inexistent array entry tcl_platform(threaded).

Is there an alternative to the load command to import binary Tcl package

I am using a commercial tool interfaced with an homebrew tclsh(Synopsys EDA).
In their version, they removed the load command. Thus I cannot use third party libraries (Graphviz library in my case).
I wonder if there is a another way to import binary files (.so files)
The only command in standard Tcl that brings in a dynamic library is load. (OK, package require can do too, but that's because it can call load inside.) Without that command, you only have options like statically linking your own code in and creating the commands in the Tcl_AppInit function, but that's really unlikely to work if you're already using someone else's code that's already done that sort of thing.
The easiest approach might be to run a normal tclsh as a subprocess via exec tclsh script.tcl (run and wait for termination) or open |tclsh r+ (open pipeline). If they've not turned off those capabilities as well; you might be running in a safe interpreter where all those things are systematically disabled. I don't know of any way to break out of a standard safe interpreter (the mechanism for locking them down errs on the side of caution) so if that's the case, you'll just have to save the data you want to a file somewhere (by any mechanism that works; safe interpreters also can't touch the filesystem at all by default though that is often profiled back in in protected ways) and use a completely separate program to work with it.

TK GUI looks different on different linux machines but with same version

I have a Tk UI which when executed on different linux machine comes up with different UI. I checked tcl version is 8.6 for both platforms.
The UI looks like this.
invoke method : tclsh script name.tcl
I wanted to use 1st one as its more graphical and fonts are readable.
Can you point me to check what is the difference in the tcl version installed on machine B. I assume Tk package could be different, but i dont know how to check.
I think tk still uses good ol'resource databases for X11, which may be different on each platform. Check xrdb(1) for this. Also read ttk::intro(n) and ttk::style(n) to read about ttk widget styles.
System wide defaults go to
/usr/lib/X11/app-defaults/∗ Client resource specifications.
or similar (check /etc/X11 and /usr/share).
In your home directory there may be .Xdefaults for user specific defaults.
But the fonts are selected through fontconfig, which has other default directories. Check /etc/fonts.

Does CMake have a higher-level abstraction for detecting 32-bit/64-bit builds?

CMake's global property, FIND_LIBRARY_USE_LIB64_PATHS, has the following documentation:
FIND_LIBRARY_USE_LIB64_PATHS is a boolean specifying whether the
FIND_LIBRARY command should automatically search the lib64 variant of
directories called lib in the search path when building 64-bit
binaries.
Reading "when building 64-bit binaries" implies CMake somehow knows my target architecture, and automatically toggles the behavior on/off depending. Am I just reading too far into this, or does CMake have a higher-level abstraction for dealing with 32-bit/64-bit compilation?
If there is, how do I configure whatever mechanism is used by FIND_LIBRARY_USE_LIB64_PATHS, to force a 32-bit/64-bit compiliation?
I realize there are existing questions dealing with forcing 32-bit/64-bit, but they deal with CMAKE_C_FLAGS and the like. If CMake has a higher level abstraction, I'd prefer it to messing with CFLAGS.
tl;dr; CMake does not have a general mechanism for forcing 32- or 64-bit compilation. You do that with selection of compilers or compilation switches.
But CMake can actually find out if the compilation is for 64- or 32-bit (or probably many other word lengths too) target. As described in this answer and the CMake docs you should use:
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message (STATUS "Compiling for 64-bit")
endif()
That is probably the underlying mechanism for "when building 64-bit binaries". But there are no variables explicitly for this.
NOTE that the variable CMAKE_SIZEOF_VOID_P is cached so that if you alter compiler options, say CMAKE_C_FLAGS to use '-m32' for a 32-bit compile it won't affect CMAKE_SIZEOF_VOID_P unless you clean your build directory.
So, in a way there seems to be a somewhat general mechanism for 32/64-bit handling. It is used in some situations, but to use it more extensively you have to handle that in your CMakeLists, which is not great.

Multiple versions of Tcl

Are there any particular things to think about when building and installing (globally) a new version of Tcl from source, besides relinking /usr/local/bin/tclsh and wish to the new versions?
I know that the interpreter executables tclsh and wish are installed with different names, but what about the include and library files? When I build eggdrop, will it link with the latest version? How about the man pages - are the old ones overwritten by the new ones?
The usual approach for this case is to configure the build so that it's installed under a single directory (the Windows approach), say, under /opt/tcltk/8.6. You're then guaranteed against clashes with other versions and deinstallation is a matter of running rm -rf on that single directory. This approach has its downsides though:
You'll have to link (some) installed third-party Tcl libraries under your new hierarchy. This is because Tcl derives the set of paths to look for libraries from its own location.
/opt/tcltk/8.6/bin won't be listed in $PATH.
With certain OSes, another (possibly more sensible) approach is to do a "backport", that is, to take the source package of the required Tcl/Tk version and make it build for the installed version of the OS; then install the resulting packages in a normal way. On systems where various versions of Tcl/Tk are co-installable (for instance, Debian and its derivatives), this possibly provides the most sensible solution.
As to manual pages in the latter case, in Debian, they just end up being packaged in a separate package, installation of which is not required; so you just select one of the available documentation packages and install it.
In terms of having multiple versions present, this is a normal thing to do (do this by setting the --prefix option to configure when building) and has been so for quite a while. You'll probably want to avoid having multiple patchlevels of a single version if you can, but having, say, 8.4, 8.5 and 8.6 co-installed is entirely OK. You'll want to have the different installations in different directories too, and you're right about linking the unversioned tclsh name to the one you want normally (though I just use the versioned executable name instead).
The only way to have the manpages coexist nicely is to have them installed in separate directory trees and to update the MANPATH environment variable to point to the right one (unless you've got a man executable that will take paths to manpages directly — some do, some don't — and that is hardly as convenient). If you can bear being online, we've got official HTML builds of the documentation hosted at http://www.tcl.tk/man/ which includes all significant versions going back quite a long way.