我的代码有一个错误:
*** 检测到堆栈粉碎 ***: ./mummergpu 终止
我在stackoverflow上搜索了一下,解决方法是在环境变量中添加-fno-stack-protector
,但是我不知道怎么添加?谁能帮我 ?
nakefile 如下:
all: clean mummergpu
.SUFFIXES : .cu .cu_dbg_o .c_dbg_o .cpp_dbg_o .cu_rel_o .c_rel_o .cpp_rel_o .cubin
## Reenable this for testing all variations
#include ../experiments/test_rule.mk
CUDA_INSTALL_PATH := /usr/local/cuda-8.0
# Compilers
NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc
CXX := g++ $(PROFILE)
CC := gcc
LINK := g++ $(PROFILE)
# Add source files here
STATIC_LIB := libmummergpu.a
# Cuda source files (compiled with cudacc)
CUFILES := mummergpu.cu
# C/C++ source files (compiled with gcc / c++)
CCFILES := \
mummergpu_gold.cpp suffix-tree.cpp PoolMalloc.cpp
最佳答案
考虑使用“-fstack-protector-strong”而不是“all”。 通过“-fstack-protector-all”,它可以对所有功能应用保护,而不管它们实际上是否需要这种保护,从而对性能产生更大的影响。
在此处查找更多详细信息:https://lwn.net/Articles/584225/
“Strong”堆栈保护器旨在仅向那些实际上可能需要此保护的函数添加堆栈保护。
您可以使用其他参数来 ./configure 命令以包括堆栈保护:
./configure [options] CFLAGS='-fstack-protector-strong' CXXFLAGS='-fstack-protector-strong'
但是,某些软件包稍后可能会覆盖它。
这是在 Makefile 中为 CFLAGS 应用堆栈保护的命令: 运行:
sed '/^.*CFLAGS = / s/$/ -fstack-protector-strong' /path/to/Makefile
一旦输出被验证并且可以接受在 Makefile 上应用更改,运行带有 -i 开关的 sed,如下所示:
sed -i '/^.*CFLAGS = / s/$/ -fstack-protector-strong' /path/to/Makefile
关于linux - 如何将 "-fstack-protector-all"添加到 makefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54284907/