我正在尝试编写一个可以在linux和mac上使用的makefile,它使用地址清理程序构建。这适用于我的流浪者实例:
CC = gcc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
ASAN_LIBS = -static-libasan
CFLAGS := -Wall -Werror --std=gnu99 -g3
LDFLAGS += -lpthread
all: hello
hello: tiny_queue.o hello.o
$(CC) -o $@ $(CFLAGS) $(ASAN_FLAGS) $(CURL_CFLAGS) $^ $(LDFLAGS) $(CURL_LIBS) $(ASAN_LIBS)
这适用于ubuntu/trusty64
但在我的Mac上失败
$ make
gcc -Wall -Werror --std=gnu99 -g3 -I/opt/X11/include -c -o hello.o hello.c
gcc -o hello -Wall -Werror --std=gnu99 -g3 -fsanitize=address -fno-omit-frame-pointer -Wno-format-security tiny_queue.o hello.o -lpthread -static-libasan
clang: error: unknown argument: '-static-libasan'
make: *** [hello] Error 1
有谁知道如何为mac和linux编写兼容的makefile?
P.S。我对C很新,对不起,如果这个问题是超级基本的话。
答案 0 :(得分:1)
export class Component implements OnDestroy { private subscription: Subscription; user: string; constructor(private store: UserStore) { this.subscription = store.select(fromUsers.getUser) .subscribe(user => this.user = user); } ngOnDestroy(): void { this.subscription.unsubscribe(); } logout(): void { this.store.dispatch({ type: LOGOUT, payload: { user: this.user } }) } }
你应该不指定一个Asan库(或UBsan库)。由于您使用编译器驱动程序来驱动链接,因此只需使用CC = gcc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
ASAN_LIBS = -static-libasan
CFLAGS := -Wall -Werror --std=gnu99 -g3
LDFLAGS += -lpthread
all: hello
hello: tiny_queue.o hello.o
$(CC) -o $@ $(CFLAGS) $(ASAN_FLAGS) $(CURL_CFLAGS) $^ $(LDFLAGS) $(CURL_LIBS) $(ASAN_LIBS)
(这是推荐的方法)。 不添加-fsanitize=address
。编译器驱动程序将为您添加适当的库。