我的代码中有一个错误:我在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发布于 2019-09-24 20:41:49
考虑使用"-fstack-protector-strong“而不是"all”。通过"-fstack-protector- all“,它将保护应用到所有函数,而不管它们实际上是否需要这种保护,从而对性能产生更大的影响。
在这里找到更多详细信息:https://lwn.net/Articles/584225/
“强”堆栈保护器旨在将堆栈保护仅添加到那些函数,这些函数实际上可能需要这种保护。
您可以使用./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/Makefilehttps://stackoverflow.com/questions/54284907
复制相似问题