开发者

Building sse switches for GCC from /proc/cpuinfo

开发者 https://www.devze.com 2023-02-09 07:47 出处:网络
I\'ve got a Makefile that\'s I\'d like to parse the flags in /proc/cpuinfo and build up a list of available sse instruction sets to pass to gcc (-msse -msse2, e开发者_如何学编程tc).This is the best I\

I've got a Makefile that's I'd like to parse the flags in /proc/cpuinfo and build up a list of available sse instruction sets to pass to gcc (-msse -msse2, e开发者_如何学编程tc). This is the best I've come up with so far, which Make isn't happy with at all:

DUMM     = $(foreach tag,$(SSE_TAGS),
            ifneq ($(shell cat /proc/cpuinfo | grep $(tag) | wc -l),"") 
            OPT_FLAG += -m$(tag) 
            endif)

So I thought I'd see here if anyone had any ideas.


For anyone that comes after me, this does what I want:

SSE_TAGS = $(shell /bin/grep -m 1 flags /proc/cpuinfo | /bin/grep -o \    
    'sse\|sse2\|sse3\|ssse3\|sse4a\|sse4.1\|sse4.2\|sse5')
NUM_PROC = $(shell cat /proc/cpuinfo | grep processor | wc -l)

ifneq (${SSE_TAGS},) 
    CCOPTS += -mfpmath=sse
    CCOPTS += $(foreach tag,$(SSE_TAGS),-m$(tag))
endif
0

精彩评论

暂无评论...
验证码 换一张
取 消