如何从源代码编译TCL以在tclsh中启用内存命令 [英] How to compile TCL from source code to enable memory command in tclsh
问题描述
我正在尝试查找使用TCL编写的守护程序的内存泄漏问题,并且该守护程序在OSX上运行并继续监视SAN系统.
I am trying to find a memory leak problem of a daemon writing with TCL, and the daemon is running on OSX continue to monitor the systems of a SAN system.
在搜索了网络之后,我发现TCL专家说我必须使用TCL_MEM_DEBUG进行专门编译,该代码在 生成文件(CFLAGS中带有-DTCL_MEM_DEBUG).然后,Tcl将具有内存"命令来记录内存使用情况的状态.
After googling the Net, I found that TCL experts said that I have to compile with TCL_MEM_DEBUG specifically defined in the makefile (with -DTCL_MEM_DEBUG in the CFLAGS). Then Tcl will have the ‘memory’ command to log the status for memory usage.
根据TCL的手册页,要启用内存调试,应使用以下命令重新编译Tcl: 定义了TCL_MEM_DEBUG(例如通过将--enable-symbols = mem标志传递给 构建时配置脚本).这也将以非 Tcl_InitMemory的存根版本,将memory命令添加到Tcl.
According to the TCL’s man page, To enable memory debugging, Tcl should be recompiled from scratch with TCL_MEM_DEBUG defined (e.g. by passing the --enable-symbols=mem flag to the configure script when building). This will also compile in a non- stub version of Tcl_InitMemory to add the memory command to Tcl.
因此,我从SourceForge下载了源代码tcl8.6.1-src.tar.gz.解压到目录并更改为macosx子目录.但是用以下命令编译后
So, I downloaded the source code tcl8.6.1-src.tar.gz from SourceForge. Extracted to a directory and change to macosx subdirectory. But after compiling with following commands
sudo ./configure --enable-symbols=mem
sudo make
sudo make install NATIVE_TCLSH="/usr/local/bin/tclsh8.6"
尽管创建了新的tclsh(v8.6),但内存"命令仍然无法使用.深入研究该过程后,我发现在config.log中创建了一些错误消息
Although new tclsh (v8.6) was created, but the ‘memory’ command still can not work. After digging into the process, I found that some error messages were created in config.log
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME "tcl"
| #define PACKAGE_TARNAME "tcl"
| #define PACKAGE_VERSION "8.6"
| #define PACKAGE_STRING "tcl 8.6"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
我也无法通过find命令找到"confdefs.h"文件.我怎么了?
I also can not find the 'confdefs.h' file by find command. What's wrong with me?
这是我的MBP的环境
MacBookPro8,2内存:4 GB,15英寸,2011年初,OS X 10.9.1(13B42)
MacBookPro8,2 Memory:4 GB, 15-inch, Early 2011, OS X 10.9.1 (13B42)
declare -x DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
declare -x PATH="/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
如何解决该问题? 还是可以在启用TCL_MEM_DEBUG的情况下下载tcl软件包?
How to fix the problem? Or Is there any place to download a tcl package with TCL_MEM_DEBUG enable?
推荐答案
首先,您需要确保安装了正确的编译器.如果您还没有的话,请从Apple Store获得Xcode,因为其中包含了可靠的命令行编译器. (在配置过程中失败的测试是检查编译器的行为是否正常;您的行为不是!)
First of all, you need to make sure you have a working compiler installation. If you haven't already, get Xcode from the Apple Store as that includes a sane command-line compiler. (The test that is failing during configuration is a check that the compiler is behaving sanely; yours is not!)
做了吗?好.
接下来,仅安装到磁盘上的某些位置需要sudo
(但是默认位置/usr/local
是其中之一).您不应对其进行配置或编译.我将用来在OSX上构建和安装启用调试的Tcl的命令序列为:
Next, only installation to some locations on disk requires sudo
(but the default location, /usr/local
, is one of those places). You should not configure or compile with it. The sequence of commands that I would use to build and install a debug-enabled Tcl on OSX would be:
cd $the_unpacked_tcl_dir
cd unix
./configure --enable-symbols=mem
make
sudo make install
可调整项/注释:
- 您可以在使用
--prefix=/the/base/install/dir
为这些位置配置Tcl的位置中安装Tcl(这会将tclsh
放在/the/base/install/dir/bin
中,并将Tcl共享库放置在/the/base/install/dir/lib
中).如果默认情况下您选择的位置是可写的,则不需要sudo
. - 您可以(也许应该)在
make
和make install
之间运行测试套件.使用make test
执行此操作.不要不以管理用户身份运行make test
;这会使某些测试失败(例如,那些检查是否检测到不可写文件并将其报告为不可写的测试). - 您可以使用
all
而不是mem
来启用更多的调试选项,尤其是在字节码编译器方面. - 完全使用
--enable-symbols
可能会大大降低性能,禁用更高级的C编译器选项,导致使用不同的内存跟踪,并为字节码引擎增加额外的开销以启用指令级跟踪.如果您想提高速度,请完全不用. - 如果您以前尝试过
make
,则应在./configure
之后和make
之前运行make clean
. (您可以通过执行make clean all
组合这些步骤;默认的make
目标为all
.)
- You can install Tcl in locations provided you configure it for those locations with
--prefix=/the/base/install/dir
(which would puttclsh
in/the/base/install/dir/bin
and the Tcl shared library in/the/base/install/dir/lib
). If the place you choose is writable by you by default, you do not needsudo
. - You can (and maybe should) run the test suite between the
make
and themake install
. Do this usingmake test
. Do not runmake test
as the administrative user; this makes some tests fail (e.g., those that check that unwritable files are detected and reported as unwritable). - You can use
all
instead ofmem
to enable further debugging options, especially in relation to the bytecode compiler. - Using
--enable-symbols
at all may well reduce performance substantially, disabling the more advanced C compiler options, causing different memory tracking to be used, and adding additional overhead to the bytecode engine to enable instruction-level tracing. If you want speed, do not use it at all. - If you have tried to do
make
before, you should runmake clean
after./configure
and beforemake
. (You can combine these steps by doingmake clean all
; the defaultmake
target isall
.)
请注意,我在OSX(现在为Lion)上使用了很多启用调试功能的Tcl.这是经过测试的配置.发生的一切不是Tcl的错误.
Be aware that I use debug-enabled builds of Tcl on OSX (Mountain Lion right now) a lot; this is a tested configuration. Whatever is going on is not a bug with Tcl.
这篇关于如何从源代码编译TCL以在tclsh中启用内存命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!