Skip Menu |

This queue is for tickets about the Tcl CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: sjaluo [...] gmail.com
Cc: tcltk [...] perl.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.05
Fixed in: (no value)



CC: tcltk [...] perl.org
Subject: Compilation problem applying Makefile.PL --tclconfig
Hi, My system is Cygwin 2.10 and I have tcl 8.6 installed. When compile with 'perl Makefile.pl --tclconfig' there is a problem (In fact, Makefile.PL forces --tclconfig option turned on on Cygwin, https://metacpan.org/source/VKON/Tcl-1.05/Makefile.PL#L48 ): $ perl Makefile.PL --tclconfig /usr/lib/tclConfig.tcl $ make : g++ --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong Tcl.o -o blib/arch/auto/Tcl/Tcl.dll \ /usr/lib/perl5/5.26/x86_64-cygwin-threads/CORE/cygperl5_26.dll -ltclstub8.6 \ Tcl.o: In function `NpInitialize': /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:475: undefined reference to `Tcl_Init' /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:475:(.text+0x45d3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Tcl_Init' Tcl.o:Tcl.c:(.rdata$.refptr.Tcl_Init[.refptr.Tcl_Init]+0x0): undefined reference to `Tcl_Init' collect2: error: ld returned 1 exit status make: *** [Makefile:482: blib/arch/auto/Tcl/Tcl.dll] Error 1 The root cause is that the preprocessor failed to expand the Tcl_Init() macro (https://metacpan.org/source/VKON/Tcl-1.05/Tcl.xs#L374 ), which is defined in tclDecls.h. When I apply --tclconfig option, the system-provided header file is used. The definition of macro 'Tcl_Init' in newer version of tcl is ( https://github.com/tcltk/tcl/blob/e058389c65a7df317144676413d8d3dcf3c2e252/generic/tclDecls.h#L3735 ): #define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp)) The original definition (comes with Tcl module tcl-core/include/tclDecls.h) is: #define Tcl_Init (tclStubsPtr->tcl_Init) In a statement like 'func_ptr=Tcl_Init', the macro 'Tcl_Init' can be expanded properly; in new version of declaration, the preprocessor does not recognize 'Tcl_Init' (but Tcl_Init()) and leave it to the compiler. Compiler then fails to find a real Tcl_Init() function for the pointer assignment. The attachment is a patch to workaround this. It seems not decent. Maybe there is a better solution.
Subject: Tcl-StubMacro.patch
--- Tcl-1.05-SJ/Tcl.xs 2018-06-16 08:03:07.415797200 +0800 +++ Tcl-1.05-patched/Tcl.xs 2018-06-16 09:55:16.218662700 +0800 @@ -30,9 +30,13 @@ #undef JOIN /* - * Let Tcl_Init() stub could be pointed by a function pointer + * Let Tcl_Init() stub could be pointed by a function pointer. + * Since tcl 8.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. */ #include <tcl.h> +#undef Tcl_Init +#define Tcl_Init (tclStubsPtr->tcl_Init) #ifdef USE_TCL_STUBS /*
RT-Send-CC: tcltk [...] perl.org
在 2018-六月-15 22:41:39 星期五 時,sjaluo@gmail.com 寫到: Show quoted text
> The root cause is that the preprocessor failed to expand the > Tcl_Init() macro (https://metacpan.org/source/VKON/Tcl- > 1.05/Tcl.xs#L374 ), which is defined in tclDecls.h.
I found a typo for the URL of Tcl_Init usage in Tcl.xs. It should be here https://metacpan.org/source/VKON/Tcl-1.05/Tcl.xs#L450
Hi, There is another issue when doing Makefile.PL with --tclconfig. In my system (Cygwin), the LIBS argument apply to MakeMaker is "-Wl,-ltclstub8.6" or "-Wl,/usr/lib/libtclstub8.6.a" rather than something like "-ltclstub8.6". The lib path option won't apply to ld correctly. ---------- $ cat /usr/lib/tclConfig.sh : TCL_BUILD_STUB_LIB_SPEC='-Wl,/usr/lib/libtclstub8.6.a' TCL_STUB_LIB_SPEC='-Wl,-ltclstub8.6' : $ perl Makefile.PL --tclconfig /usr/lib/tclConfig.sh Using config data in /usr/lib/tclConfig.sh LIBS = -Wl,-ltclstub8.6 INC = -I/usr/include DEFINE = -DUSE_TCL_STUBS -DLIB_RUNTIME_DIR=\"/usr/lib\" -DTCL_LIB_FILE=\"libtcl8.6.dll\" Generating a Unix-style Makefile Writing Makefile for Tcl Writing MYMETA.yml and MYMETA.json % make : g++ --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong Tcl.o -o blib/arch/auto/Tcl/Tcl.dll \ /usr/lib/perl5/5.26/x86_64-cygwin-threads/CORE/cygperl5_26.dll \ Tcl.o: In function `NpInitialize': /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:446: undefined reference to `Tcl_InitStubs' /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:446:(.text+0x4571): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Tcl_InitStubs' Tcl.o:Tcl.c:(.rdata$.refptr.tclStubsPtr[.refptr.tclStubsPtr]+0x0): undefined reference to `tclStubsPtr' collect2: error: ld returned 1 exit status make: *** [Makefile:479: blib/arch/auto/Tcl/Tcl.dll] Error 1 ---------- The linker cannot find Tcl_InitStubs() because -ltclstub8.6 is missed. Here I am also trying to do a workaround fix for it.
Subject: Tcl-libpath2.patch
--- Tcl-1.05-UjbRn3/Makefile.PL 2016-06-29 00:48:16.000000000 +0800 +++ Tcl-1.05-SJ/Makefile.PL 2018-06-16 23:39:09.770237300 +0800 @@ -199,6 +199,16 @@ @extraargs = (dynamic_lib => {OTHERLDFLAGS => $libpath}); $libpath = ""; } +} else { + # MakeMaker LIBS argument only workable for string with + # the format "-ltclstub" or "-L/lib/path". When apply --tclconfig option, + # the $libpath would be something like "-Wl,-ltclstub.a"; or something like + # "-Wl,/usr/lib/libtclstub.a" when apply --buildspec + # We need other method to specify lib path + if ($libpath =~ /^-Wl,/) { + @extraargs = (dynamic_lib => {OTHERLDFLAGS => $libpath}); + $libpath = ""; + } } #print <<"#EOS";
CC: "tcltk [...] perl.org" <tcltk [...] perl.org>
Subject: RE: [rt.cpan.org #125597] Compilation problem applying Makefile.PL --tclconfig
Date: Sat, 16 Jun 2018 18:30:18 +0000
To: "bug-Tcl [...] rt.cpan.org" <bug-Tcl [...] rt.cpan.org>
From: "Konovalov, Vadim" <Vadim.Konovalov [...] dell.com>
Mostly we should be fine with just default parameters on Cygwin, or whatever else platform; Is it happening that default Cygwin build broken without your patch? The problem is that you want to overwrite "8.4" with "8.6"? I think we need to elaborate better way to deal with lib path, exactly as you specified in your comments :) IMO we should just remove 'tcl-core' directory at all, it is outdated. This will allow us to remove many related lines from Makefile.PL as well; My Cygwin install comes with "C:\cygwin\lib\libtclstub8.5.a", so it just must be allowed to be detected during build process, then correctly used, and that's it Show quoted text
-----Original Message----- From: SJ Luo via RT [mailto:bug-Tcl@rt.cpan.org] Sent: Saturday, June 16, 2018 7:30 PM Subject: [rt.cpan.org #125597] Compilation problem applying Makefile.PL --tclconfig Queue: Tcl Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125597 > Hi, There is another issue when doing Makefile.PL with --tclconfig. In my system (Cygwin), the LIBS argument apply to MakeMaker is "-Wl,-ltclstub8.6" or "-Wl,/usr/lib/libtclstub8.6.a" rather than something like "-ltclstub8.6". The lib path option won't apply to ld correctly. ---------- $ cat /usr/lib/tclConfig.sh : TCL_BUILD_STUB_LIB_SPEC='-Wl,/usr/lib/libtclstub8.6.a' TCL_STUB_LIB_SPEC='-Wl,-ltclstub8.6' : $ perl Makefile.PL --tclconfig /usr/lib/tclConfig.sh Using config data in /usr/lib/tclConfig.sh LIBS = -Wl,-ltclstub8.6 INC = -I/usr/include DEFINE = -DUSE_TCL_STUBS -DLIB_RUNTIME_DIR=\"/usr/lib\" -DTCL_LIB_FILE=\"libtcl8.6.dll\" Generating a Unix-style Makefile Writing Makefile for Tcl Writing MYMETA.yml and MYMETA.json % make : g++ --shared -Wl,--enable-auto-import -Wl,--export-all-symbols g++ -Wl,--enable-auto-image-base -fstack-protector-strong Tcl.o -o g++ blib/arch/auto/Tcl/Tcl.dll \ /usr/lib/perl5/5.26/x86_64-cygwin-threads/CORE/cygperl5_26.dll \ Tcl.o: In function `NpInitialize': /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:446: undefined reference to `Tcl_InitStubs' /home/user/.cpan/build/Tcl-1.05-SJ/Tcl.xs:446:(.text+0x4571): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Tcl_InitStubs' Tcl.o:Tcl.c:(.rdata$.refptr.tclStubsPtr[.refptr.tclStubsPtr]+0x0): undefined reference to `tclStubsPtr' collect2: error: ld returned 1 exit status make: *** [Makefile:479: blib/arch/auto/Tcl/Tcl.dll] Error 1 ---------- The linker cannot find Tcl_InitStubs() because -ltclstub8.6 is missed. Here I am also trying to do a workaround fix for it.
Vadim.Konovalov@dell.com wrote: Show quoted text
> Mostly we should be fine with just default parameters on Cygwin, or > whatever else platform; > Is it happening that default Cygwin build broken without your patch?
Yes, this problem happens with default Cygwin build without my patch. My tcl 8.6 comes from official Cygwin package. And my Cygwin version is almost up-to-date(2.10). Show quoted text
> The problem is that you want to overwrite "8.4" with "8.6"?
Yes, in Makefile.PL, the default setting is forcing applying '--tclconfig /usr/lib/tclConfig.sh' parameter (https://metacpan.org/source/VKON/Tcl-1.05/Makefile.PL#L48 ). Now Cygwin by default comes with tcl 8.6. There is no choice but apply 8.6. Show quoted text
> I think we need to elaborate better way to deal with lib path, exactly > as you specified in your comments :)
Show quoted text
> IMO we should just remove 'tcl-core' directory at all, it is outdated. > This will allow us to remove many related lines from Makefile.PL as > well;
Well I just say tcl-core works well on my Linux system. At least I do not need to install tcl-devel package to compile Tcl.xs. :) Show quoted text
> My Cygwin install comes with "C:\cygwin\lib\libtclstub8.5.a", so it > just must be allowed to be detected during build process, then > correctly used, and that's it
I think I got the problem. With your comment I checked tcl-8.6 source again and found that Cygwin binary package mysteriously patched '/usr/lib/tclConfig.sh' (Patching code http://chiselapp.com/user/pooryorick/repository/distpatches/artifact?ln=on&name=bca5ddd570a97141 , Cygwin package http://mirrors.kernel.org/sourceware/cygwin/x86/release/tcl/tcl-8.6.8-1.tar.xz ). In my Cygwin, 'tclConfig.sh' is (as attached): : TCL_BUILD_STUB_LIB_SPEC='-Wl,/usr/lib/libtclstub8.6.a' TCL_STUB_LIB_SPEC='-Wl,-ltclstub8.6' : If I download tcl source and compile by myself, it is: : TCL_BUILD_STUB_LIB_SPEC='-L/tmp/tcl-8.6.8-1.src/tcl8.6.8/unix -ltclstub8.6' TCL_STUB_LIB_SPEC='-L/usr/local/lib -ltclstub8.6' : That's the problem. Then Perl MakeMaker failed to accept library option like '-Wl,-llibname' or '-Wl,/lib/file/path'. I think Makefile.PL shall do something to deal with '-Wl,...' lib path form. Any opinion?
Subject: tclConfig.sh
Download tclConfig.sh
application/octet-stream 7.3k

Message body not shown because it is not plain text.

Subject: RE: [rt.cpan.org #125597] Compilation problem applying Makefile.PL --tclconfig
Date: Mon, 18 Jun 2018 11:36:29 +0000
To: "bug-Tcl [...] rt.cpan.org" <bug-Tcl [...] rt.cpan.org>
From: "Konovalov, Vadim" <Vadim.Konovalov [...] dell.com>
From: SJ Luo via RT [mailto:bug-Tcl@rt.cpan.org] Show quoted text
> Yes, in Makefile.PL, the default setting is forcing applying '--tclconfig /usr/lib/tclConfig.sh' parameter (https://metacpan.org/source/VKON/Tcl-1.05/Makefile.PL#L48 ). Now Cygwin by default comes with tcl 8.6. There is no choice but apply 8.6.
BTW is it possible to have Cygwin to behave much like linux? I'll look into this now. Show quoted text
> I think we need to elaborate better way to deal with lib path, exactly > as you specified in your comments :)
Show quoted text
> IMO we should just remove 'tcl-core' directory at all, it is outdated. > This will allow us to remove many related lines from Makefile.PL as > well;
Show quoted text
> Well I just say tcl-core works well on my Linux system. At least I do not need to install tcl-devel package to compile Tcl.xs. :)
So linking against libstub8.4.a is actually sufficient to run against libtcl8.6.so? or maybe your linux system contains bot libtcl8.4 and libtcl8.6.so? That's the problem. Then Perl MakeMaker failed to accept library option like '-Wl,-llibname' or '-Wl,/lib/file/path'. I think Makefile.PL shall do something to deal with '-Wl,...' lib path form. Any opinion?
Subject: RE: [rt.cpan.org #125597] Compilation problem applying Makefile.PL --tclconfig
Date: Mon, 18 Jun 2018 11:36:29 +0000
To: "bug-Tcl [...] rt.cpan.org" <bug-Tcl [...] rt.cpan.org>
From: "Konovalov, Vadim" <Vadim.Konovalov [...] dell.com>
From: SJ Luo via RT [mailto:bug-Tcl@rt.cpan.org] Show quoted text
> Yes, in Makefile.PL, the default setting is forcing applying '--tclconfig /usr/lib/tclConfig.sh' parameter (https://metacpan.org/source/VKON/Tcl-1.05/Makefile.PL#L48 ). Now Cygwin by default comes with tcl 8.6. There is no choice but apply 8.6.
BTW is it possible to have Cygwin to behave much like linux? I'll look into this now. Show quoted text
> I think we need to elaborate better way to deal with lib path, exactly > as you specified in your comments :)
Show quoted text
> IMO we should just remove 'tcl-core' directory at all, it is outdated. > This will allow us to remove many related lines from Makefile.PL as > well;
Show quoted text
> Well I just say tcl-core works well on my Linux system. At least I do not need to install tcl-devel package to compile Tcl.xs. :)
So linking against libstub8.4.a is actually sufficient to run against libtcl8.6.so? or maybe your linux system contains bot libtcl8.4 and libtcl8.6.so? That's the problem. Then Perl MakeMaker failed to accept library option like '-Wl,-llibname' or '-Wl,/lib/file/path'. I think Makefile.PL shall do something to deal with '-Wl,...' lib path form. Any opinion?
RT-Send-CC: tcltk [...] perl.org
Vadim.Konovalov wrote: Show quoted text
> BTW is it possible to have Cygwin to behave much like linux? > I'll look into this now.
Yes I think so. We will need libtclstub.a for 32/64 bit Cygwin and do a little patch on Makefile.PL. I'd like to provide them if you prefer. Show quoted text
> So linking against libstub8.4.a is actually sufficient to run against > libtcl8.6.so? or maybe your linux system contains bot libtcl8.4 and > libtcl8.6.so?
Yes, linking against libstub8.4.a works fine. My Linux system comes with tcl8.5. There is no tcl8.4 installed.
Hi, My patch for Cygwin as well as needed libtclstub8.4.a are attached. It makes Cygwin build method much more like Linux: No longer forcing --telconfig and no tcl-devel package necessary to compile it. Note that the directory structure and names in tclstub84_cyg.tar.gz have to be kept. Though the stub lib is 8.4, they are well compiled on both 32/64bit Cygwin 2.10 with tcl-8.6 pre-installed and passed all 'make test' items. SJ
Subject: Tcl-cygwin.patch
--- Tcl-1.05-UjbRn3/Makefile.PL 2016-06-29 00:48:16.000000000 +0800 +++ Tcl-1.05-SJ/Makefile.PL 2018-06-22 22:50:36.943227700 +0800 @@ -45,7 +45,8 @@ $arch = "$^O-ia64" if ($Config{archname} =~ /ia64/i); $arch = "$^O-x86_64" if ($Config{archname} =~ /x86_64/); } elsif ($^O eq "cygwin") { - $tclconfig = '/usr/lib/tclConfig.sh'; + $arch = "$^O-i686" if ($Config{archname} =~ /i\d86/); + $arch = "$^O-x86_64" if ($Config{archname} =~ /x86_64/); } sub _die ($) {
Subject: tclstub84_cyg.tar.gz
Download tclstub84_cyg.tar.gz
application/gzip 1.2k

Message body not shown because it is not plain text.

RT-Send-CC: tcltk [...] perl.org
I even made change more like this: diff --git a/Makefile.PL b/Makefile.PL index 0529e13..3d14db0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -38,12 +38,10 @@ if ($^O eq "MSWin32") { } elsif ($^O eq "hpux") { $arch = "$^O-ia64" if ($Config{archname} =~ /ia64/i); $arch = "$^O-parisc" if ($Config{archname} =~ /pa-risc/i); -} elsif ($^O eq "linux") { +} elsif ($^O eq "linux" or $^O eq "cygwin") { $arch = "$^O-i686" if ($Config{archname} =~ /i\d86/); $arch = "$^O-ia64" if ($Config{archname} =~ /ia64/i); $arch = "$^O-x86_64" if ($Config{archname} =~ /x86_64/); -} elsif ($^O eq "cygwin") { - $tclconfig = '/usr/lib/tclConfig.sh'; } sub _die ($) { thank you! soon to release
I've checked the head branch on github. There is no problem compiling on my Cygwin with default configuration now. Thanks for the apply. SJ
nice. makefile.pl even became a bit shorter. closing the ticket