问题描述
我需要使用自动工具禁用单个文件的优化标志.最好的方法是什么?
I need to disable optimization flag for a individual file using autotools.What is the best way to do it?
推荐答案
您是指单个源文件还是单个可执行文件?
Do you mean an individual source file or an individual executable?
禁用可执行文件的优化很简单:
To disable optimization for an executable is simple:
bin_PROGRAMS = myprog
myprog_SOURCES = foo.c bar.c
myprog_CFLAGS = -O0
如果您要暂时禁用单个源文件的优化(例如出于调试目的),则可以在提示符下重新制作该文件:(例如,来自自动制作手册) /p>
If you mean that you want to disable the optimization for a single source file temporarily, say for debugging purposes, you can just remake that file at the prompt: (example from the automake manual)
rm bar.o
make CFLAGS=-O0 bar.o
make
要永久地对单个源文件 进行操作不是那么简单,最好通过创建一个便捷库来实现:
To do it for an individual source file permanently is not so simple, and probably best done by creating a convenience library:
noinst_LIBRARIES = libnoopt.a
libnoopt_a_SOURCES = bar.c
libnoopt_a_CFLAGS = -O0
bin_PROGRAMS = myprog
myprog_SOURCES = foo.c
myprog_CFLAGS = -O2
myprog_LDADD = libnoopt.a
这篇关于使用GCC和自动工具为单个源文件设置编译标志的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!