Skip to content
Tcl Source Code Artifact [a42f1c411f]
Login

Artifact [a42f1c411f]

Artifact a42f1c411fd8c5b17016bcba762ac6fb2d9177b7c2deae77ab3b1d2692a5fcc2:

Ticket change [a42f1c411f] - Ticket [4663e0636f7a24b9|4663e0636f] <i>TIP 538 and Tcl extensions: &#39;tommath.h&#39; file not found</i> status still Open with 3 other changes by jan.nijtmans on 2020-05-18 13:42:09.
D 2020-05-18T13:42:09.475
J icomment Thanks,\sStefan,\sfor\sthis\sreport.\r\n\r\nThe\sfirst\sproblem\swith\sTIP\s#538\sis\sthat\s<tommath.h>\sis\sbinary\sincompatible\sin\sTcl\s8.7\scompared\sto\sTcl\s8.6.\sThis\sis\smainly\sdue\sto\sTcl's\sbad\sdecision\sto\smake\sthe\smp_digit\stype\s32-bit\salways:\sOn\s64bit\splatforms\sthis\sis\snot\soptimal,\sand\sit's\sdifferent\sfrom\show\slibtommath's\sbuild\sscripts\swork.\sSo,\sTIP\s#538\sfixes\sthis:\sThe\slibtommath\sincluded\sby\sTcl\sis\snow\sbinary\scompatible\swith\san\sexternally-built\slibtommath.\sThe\srecommended\sway\sfor\sextensions\swould\sbe\sto\sdo\sthe\ssame\sthing\sas\sTcl\sdoes.\sSo,\sif\sTcl\sis\scompiled\sagainst\san\sexternal\slibtommath,\sthe\sextension\sshould\sbe\slinked\sto\sthat\sexternal\slibtommath\sas\swell.\sThere\sis\sa\ssymbol\sTCL_WITH_EXTERNAL_TOMMATH\syou\scan\suse\sto\sdetect\sthe\sdifference.\sOn\smany\sLinux\ssystems\s(e.g.\sUbuntu\s20.4\sLTS,\sFocal\sFossa)\slibtommath\scan\sbe\sused\sby\s"sudo\sapt-get\sinstall\slibtommath-dev".\sThat\sshouldn't\sbe\stoo\sdifficult.\sI\sexpect\sthat\sTcl\s8.7\s-\sonce\sincluded\sin\sUbunto\s-\swill\suse\sthis\slibtommath\sin\sstead\sof\sit's\sown\sversion.\r\n\r\nSo,\snsf.c\sshould\sdo:\r\n<pre>\r\nifdef\sTCL_WITH_EXTERNAL_TOMMATH\r\n#\sinclude\s<tommath.h>\r\n#else\r\n#\sinclude\s<tclTomMath.h>\r\n#endif\r\n</pre>\r\nand\slater\sin\sthe\scode:\r\n<pre>\r\n#ifndef\sTCL_WITH_EXTERNAL_TOMMATH\r\n\s\sif\s(Tcl_TomMath_InitStubs(interp,\s"8.5")\s==\sNULL)\s{\r\n\s\s\s\sreturn\sTCL_ERROR;\r\n\s\s}\r\n#endif\r\n</pre>\r\n\r\nWhen\slinking\sthe\slibrary,\suse\s"-ltommath"\sas\sadditional\slink\soption.\r\n\r\nOf\scourse,\sNSF\scould\sdecide\sto\skeep\sit\sas-is,\sno\sproblem.\sThe\sonly\slimitation\sis\sthat\susing\s<tclTommath.h>,\sonly\sthe\sfunctions\sincluded\sby\sTcl\sare\susable.\sUsing\s<tommath.h>\sthe\sfull\slist\sof\slibtommath\sfunctions\scan\sbe\sused.\sSo,\sin\sthe\slong\srun,\susing\san\sexternal\slibtommath\sis\sbetter\salways.\r\n\r\nThat\sdoesn't\ssolve\sthe\sproblem\sdescribed\shere.\sWell,\sTcl\sdoesn't\sinstall\s<tommath.h>\sbecause\sit\scould\slead\sto\sa\sconflict\swith\sthe\sofficial\slibtommath\sversion.\sSo,\sif\syou\swant\sto\suse\sthe\sTcl-provided\slibtommath,\sone\sway\sto\sdo\sthat\sis\sadd\sa\s"compat"\sdirectory\sto\sNSF\sand\sput\sTcl's\s<tommath.h>\sthere.\sJust\sadd\s"-I\s../compat"\sto\sthe\scompiler\soptions\sand\severything\sshould\swork.\r\n\r\nIt\swould\shave\sbeen\snice\swhen\sTcl\scould\sprovide\sthe\s"mp_int"\stype\sfrom\stcl.h.\sBut\sthat\swould\scause\sa\sconflict\sbetween\stcl.h\sand\sthe\sexternal\stommath.h.\sA\stiny\spatch\sto\stommath.h\swould\sfix\sthis\s(See\s[https://github.com/libtom/libtommath/pull/473|See\slibtommath's\sPR\s473]),\sbut\sthis\sPR\swas\srejected\swith\sthe\sremark:\s"No,\ssuch\spatches,\swhich\sare\sonly\suseful\sfor\sTcl\swon't\shappen.".\r\n\r\nThe\stommath.h\sprovided\sin\sNSF's\s"/compat"\sdirectory\scould\sbe\sa\sstripped-down\sversion,\sif\syou\slike.\sOnly\sproviding\s"mp_int"\sand\s"mp_digit"\sis\salready\senough\s(I\sdidn't\stest\sthat).\r\n\r\nHope\sthis\shelps.\sI'll\skeep\sthis\sticket\sopen,\sso\syou\scan\sask\smore\squestions\sif\syou\slike.\sThat\scould\sbe\suseful\sfor\sother\sextensions\stoo.
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K 4663e0636f7a24b9363e67c7a3dd25e9e495be17
U jan.nijtmans
Z 7469135b91c5c0ed7791effe66b1cda2