【发布时间】:2018-02-12 10:29:57
【问题描述】:
我试图通过 python distutils 构建 c。我想用 gcc 替换 CC 并关注这个page
CC=gcc python setup.py build
然后我得到了
gcc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat - Werror=format-security -fPIC -I/usr/include/python2.7 -c hello.c -o build/temp.linux-x86_64-2.7/hello.o
创建 build/lib.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-严格别名 -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl ,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/hello.o -o build/lib.linux- x86_64-2.7/hello.so
第一阶段CC只改成gcc,会变成原来的x86_64-linux-gnu-gcc,不知道有没有遗漏,谢谢。
【问题讨论】:
-
用LD定义链接器怎么样?
-
没用,不过我找到了答案,是需要定义LDSHARED