Skip Menu |
 

This queue is for tickets about the Tcl CPAN distribution.

Report information
The Basics
Id: 6086
Status: resolved
Priority: 0/
Queue: Tcl

People
Owner: Nobody in particular
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.75
Fixed in: (no value)



Subject: Tcl module on FreeBSD
Download (untitled) / with headers
text/plain 120b
The attached patch changes the Tcl.pm Makefile.PL to autodetect the latest Tcl library on FreeBSD. Regards, Slaven
Download Tcl.patch
text/x-diff 2.8k
# # # To apply this patch: # STEP 1: Chdir to the source directory. # STEP 2: Run the 'applypatch' program with this patch file as input. # # If you do not have 'applypatch', it is part of the 'makepatch' package # that you can fetch from the Comprehensive Perl Archive Network: # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz # In the above URL, 'x' should be 2 or higher. # # To apply this patch without the use of 'applypatch': # STEP 1: Chdir to the source directory. # STEP 2: Run the 'patch' program with this file as input. # #### End of Preamble #### #### Patch data follows #### diff -up '../../build/Tcl-0.75/Makefile.PL' 'Makefile.PL' Index: ./Makefile.PL --- ./Makefile.PL Tue Mar 23 00:44:58 2004 +++ ./Makefile.PL Wed Apr 21 00:06:52 2004 @@ -1,10 +1,17 @@ # before running this script make sure you have 'tclsh' in your path, # and this 'tcl' distribution is required one. -# FreeBSD users may want to modify name of tcl interpreter (this is -# $tclsh variable below) as long as 'tclsh' does not work in their case my $tclsh = 'tclsh'; +if ($^O eq 'freebsd' && `$tclsh /dev/null 2>&1` =~ /named with a version/) { + for my $ver (qw(8.4 8.3 8.2 8.1 8.0)) { + if (is_in_path("$tclsh$ver")) { + $tclsh = "$tclsh$ver"; + last; + } + } +} + open TCLSH, "$tclsh tclcfg.tcl |"; my $tclcfg = join '', <TCLSH>; print $tclcfg; @@ -36,5 +43,44 @@ WriteMakefile( LIBS => ["$tclcfg{libpath} -l${libpref}tcl$tclver"], INC => "$tclcfg{incpath}", ); + +# Utility functions + +BEGIN { + if (eval { require File::Spec; defined &File::Spec::file_name_is_absolute }) { + *file_name_is_absolute = \&File::Spec::file_name_is_absolute; + } else { + *file_name_is_absolute = sub { + my $file = shift; + my $r; + if ($^O eq 'MSWin32') { + $r = ($file =~ m;^([a-z]:(/|\\)|\\\\|//);i); + } else { + $r = ($file =~ m|^/|); + } + $r; + }; + } +} + +sub is_in_path { + my($prog) = @_; + return $prog if (file_name_is_absolute($prog) and -f $prog and -x $prog); + require Config; + my $sep = $Config::Config{'path_sep'} || ':'; + foreach (split(/$sep/o, $ENV{PATH})) { + if ($^O eq 'MSWin32') { + # maybe use $ENV{PATHEXT} like maybe_command in ExtUtils/MM_Win32.pm? + return "$_\\$prog" + if (-x "$_\\$prog.bat" || + -x "$_\\$prog.com" || + -x "$_\\$prog.exe" || + -x "$_\\$prog.cmd"); + } else { + return "$_/$prog" if (-x "$_/$prog" && !-d "$_/$prog"); + } + } + undef; +} #EOS #### End of Patch data #### #### ApplyPatch data follows #### # Data version : 1.0 # Date generated : Wed Apr 21 00:08:24 2004 # Generated by : makepatch 2.00_05 # Recurse directories : Yes # p 'Makefile.PL' 998 1082498812 0100751 #### End of ApplyPatch data #### #### End of Patch kit [created: Wed Apr 21 00:08:24 2004] #### #### Patch checksum: 81 2277 36133 #### #### Checksum: 99 2901 22124 ####
Download (untitled) / with headers
text/plain 654b
[SREZIC - Wed Apr 21 11:43:06 2004]: Show quoted text
> The attached patch changes the Tcl.pm Makefile.PL to autodetect the > latest Tcl library on FreeBSD.
as long as starting from version 0.81 we drop support for Tcl/Tk elder than 8.4 (unfortunately), this means on FreeBSD better will be "tclsh8.4" taken directly. Additionally, it looks to me that growing Makefile.PL that much is not good, your algorithm "file_name_is_absolute" should be discussed, and better yet just excluded, yet is_in_path should go away because let's assume we either have right tclsh in path or right parameters to Makefile.PL will be given Thanks for your input. Best regards, Vadim.
Download (untitled) / with headers
text/plain 1.6k
Show quoted text
>> Additionally, it looks to me that growing Makefile.PL that much is not >> good,
Show quoted text
srdvR> Makefile.PL is meant exactly for configuration purposes. It's some srdvR> kind of autoconf-generated "configure" usually found in the Unix srdvR> world.
IMHO thin module must have small Makefile.PL (and Tcl, Tcl::Tk supposed to be thin as opposed to perlTk) The point is - I refer to it to make people know how to build Makefile for WinCE devices, and it was quite easy before it started to grow, and all people will think Makefile.PL is huge because of WinCE complexity. Actually earlier version had ceMakefile.PL separatedly, I should return to that. But must to take care of not installing that ceMakefile.PL on user's system, Show quoted text
>> your algorithm "file_name_is_absolute" should be discussed,
Show quoted text
srdvR> Basically it just calls File::Spec::file_name_is_absolute for current srdvR> perl versions. But this is not available in older File::Spec versions srdvR> (e.g. perl 5.00503) and File::Spec is not bundled with perl 5.004 and srdvR> older, so I usually use the few lines to add a reasonable fallback.
Surplrisingly, 5.00503 no longer supoprted. Let us bring module to good shape first, and then will return to supporting elder things: Tk 8.3, perl-5.005_03 and so on. Please do not include there own Perl modules! Show quoted text
>> and >> better yet just excluded, yet is_in_path should go away because let's >> assume we either have right tclsh in path or right parameters to >> Makefile.PL will be given
Show quoted text
srdvR> I am concerned about automatic install from CPAN.pm or CPANPLUS.pm, srdvR> where passing parameters to Makefile.PL is not easy.
That's a good point.
Download (untitled) / with headers
text/plain 209b
please see https://github.com/gisle/tcl.pm/commit/658d79354b4b7b8d0b95358ce4429a1ae99d2b17 and let me know whether that is okay for freebsd case; also, is the picture the same for openbsd and netbsd? thanks!
Download (untitled) / with headers
text/plain 3.7k
On 2018-07-01 08:17:23, VKON wrote: Show quoted text
> please see > https://github.com/gisle/tcl.pm/commit/658d79354b4b7b8d0b95358ce4429a1ae99d2b17 > and let me know whether that is okay for freebsd case;
Unfortunately what was valid 14 years ago is not anymore: there's no "tclsh" binary anymore in my FreeBSD installations. Something like this has to be done to run the Makefile.PL step successfully (rough diff only): diff --git a/Makefile.PL b/Makefile.PL index 6e1a805..22caaa8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -46,9 +46,10 @@ sub _die ($) { my $tclsh_default = 'tclsh'; # for FreeBSD users, according to ticket 6086, try to guess their name for tclsh -if ($^O eq 'freebsd' && `tclsh /dev/null 2>&1` =~ /named with a version/) { +if ($^O eq 'freebsd') { for my $ver (qw(8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0)) { - if (`tclsh$ver /dev/null 2>&1` !~ /named with a version/) { + system "which tclsh$ver >/dev/null 2>&1"; + if ($? == 0) { $tclsh_default = "tclsh$ver"; # ok will use that last; } Compilation is also successful, but all tests fail: PERL_DL_NONLAZY=1 "/usr/perl5.26.1p/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/call.t ............. Can't load '/tmp/tcl.pm/blib/arch/auto/Tcl/Tcl.so' for module Tcl: /tmp/tcl.pm/blib/arch/auto/Tcl/Tcl.so: Undefined symbol "Tcl_Init" at /usr/perl5.26.1p/lib/5.26.1/amd64-freebsd/DynaLoader.pm line 193. at t/call.t line 6. Compilation failed in require at t/call.t line 6. BEGIN failed--compilation aborted at t/call.t line 6. Undefined subroutine &Tcl::_Finalize called at /tmp/tcl.pm/blib/lib/Tcl.pm line 599. END failed--call queue aborted at t/call.t line 6. t/call.t ............. Dubious, test returned 22 (wstat 5632, 0x1600) No subtests run ... (etc) ... Tried with freebsd10.3 + perl 5.26.1 and freebsd1 + perl 5.28.0 Show quoted text
> > also, is the picture the same for openbsd and netbsd? >
I don't know the other BSDs. Probably it's better to get support from Alceu in the case of OpenBSD. Regards, Slaven
Download (untitled) / with headers
text/plain 543b
thank you, applied as f7730b9cc63804eece9cdb336261dc06f78bde10 indeed, we're getting FAILs that you've mentioned such as this - http://www.cpantesters.org/cpan/report/8c0b0318-7d7c-11e8-8f68-9fdccf1570f6 again, we're moving back default on FreeBSD to --usestubs but this is not cure, because we had similar "/home/cpansand/.cpan/build/2018062715/Tcl-1.09-0/blib/arch/auto/Tcl/Tcl.so: Undefined symbol "tclStubsPtr" at....." http://www.cpantesters.org/cpan/report/fe371178-7a54-11e8-8df7-db842dc43508 IOW, working on this problem further :)
Download (untitled) / with headers
text/plain 1.3k
On 2018-Jul-02 02:42:13 Mon,VKON wrote: Show quoted text
> again, we're moving back default on FreeBSD to --usestubs > > but this is not cure, because we had similar > "/home/cpansand/.cpan/build/2018062715/Tcl-1.09- > 0/blib/arch/auto/Tcl/Tcl.so: Undefined symbol "tclStubsPtr" at....." > http://www.cpantesters.org/cpan/report/fe371178-7a54-11e8-8df7- > db842dc43508
The above Tcl-1.09 problem in link "fe371178-7a54-...." was solved in RT#125701 https://rt.cpan.org/Ticket/Display.html?id=125701 The FreeBSD problem in Tcl-1.11 is another problem 'Undefined symbol "Tcl_Init"', which is basically the same as the one I encountered in Cygwin (RT#125597): https://rt.cpan.org/Ticket/Display.html?id=125597 Tcl_Init() is not a function. Rather, it is a macro. The root cause is that tcl8.5/8.6 changed the definition of Tcl_Init(). Then preprocessor failed to expand the following line. https://metacpan.org/source/VKON/Tcl-1.11/Tcl.xs#L126 The definition of Tcl_Init() is as follows: #define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp)) /* 8.5 */ #define Tcl_Init (tclStubsPtr->tcl_Init) /* 8.4 */ It is a general problem if we want to compile Tcl.xs and link it against tclstub8.5 and above. I proposed a patch to force redefine the macro back to tcl8.4 style. Please give it a try.
Subject: Tcl-StubMacro.patch
Download Tcl-StubMacro.patch
text/x-diff 619b
diff --git a/Tcl.xs b/Tcl.xs index 65fefab..17b2c68 100755 --- a/Tcl.xs +++ b/Tcl.xs @@ -32,6 +32,17 @@ #include <tcl.h> #ifdef USE_TCL_STUBS + +/* Let Tcl_Init() stub could be pointed by a function pointer. + * Since tcl8.5, Tcl_Init() is defined as a macro with an argument and + * unable to be assigned to a function pointer. We need to redefine it back + * to tcl8.4 style . + */ +#ifdef Tcl_Init +# undef Tcl_Init +# define Tcl_Init (tclStubsPtr->tcl_Init) +#endif + /* * If we use the Tcl stubs mechanism, this provides us Tcl version * and direct dll independence, but we must force the loading of
Subject: RE: [rt.cpan.org #6086] Tcl module on FreeBSD
Date: Sat, 14 Jul 2018 07:53:58 +0000
To: "bug-Tcl [...] rt.cpan.org" <bug-Tcl [...] rt.cpan.org>
From: "Konovalov, Vadim" <Vadim.Konovalov [...] dell.com>
Download (untitled) / with headers
text/plain 1.6k
Thanks, applied Will make a fresh release with your patch! Show quoted text
-----Original Message----- From: SJ Luo via RT [mailto:bug-Tcl@rt.cpan.org] Sent: Saturday, July 14, 2018 9:44 AM Subject: [rt.cpan.org #6086] Tcl module on FreeBSD Queue: Tcl Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=6086 > On 2018-Jul-02 02:42:13 Mon,VKON wrote:
> again, we're moving back default on FreeBSD to --usestubs > > but this is not cure, because we had similar > "/home/cpansand/.cpan/build/2018062715/Tcl-1.09- > 0/blib/arch/auto/Tcl/Tcl.so: Undefined symbol "tclStubsPtr" at....." > http://www.cpantesters.org/cpan/report/fe371178-7a54-11e8-8df7- > db842dc43508
The above Tcl-1.09 problem in link "fe371178-7a54-...." was solved in RT#125701 https://rt.cpan.org/Ticket/Display.html?id=125701 The FreeBSD problem in Tcl-1.11 is another problem 'Undefined symbol "Tcl_Init"', which is basically the same as the one I encountered in Cygwin (RT#125597): https://rt.cpan.org/Ticket/Display.html?id=125597 Tcl_Init() is not a function. Rather, it is a macro. The root cause is that tcl8.5/8.6 changed the definition of Tcl_Init(). Then preprocessor failed to expand the following line. https://metacpan.org/source/VKON/Tcl-1.11/Tcl.xs#L126 The definition of Tcl_Init() is as follows: #define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp)) /* 8.5 */ #define Tcl_Init (tclStubsPtr->tcl_Init) /* 8.4 */ It is a general problem if we want to compile Tcl.xs and link it against tclstub8.5 and above. I proposed a patch to force redefine the macro back to tcl8.4 style. Please give it a try.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.